class InstrumentTypeRepository {

    @Transactional
    public List<InstrumentType> update(List<InstrumentType> instrumentTypes, RequestInfo requestInfo) {

        InstrumentTypeMapper mapper = new InstrumentTypeMapper();

        if (persistThroughKafka != null && !persistThroughKafka.isEmpty()
                && persistThroughKafka.equalsIgnoreCase("yes")) {

            InstrumentTypeRequest request = new InstrumentTypeRequest();
            request.setRequestInfo(requestInfo);
            request.setInstrumentTypes(new ArrayList<>());

            for (InstrumentType iac : instrumentTypes)
                request.getInstrumentTypes().add(mapper.toContract(iac));

            instrumentTypeQueueRepository.addToQue(request);

            return instrumentTypes;
        } else {

            List<InstrumentType> resultList = new ArrayList<InstrumentType>();

            for (InstrumentType iac : instrumentTypes)
                resultList.add(update(iac));

            InstrumentTypeRequest request = new InstrumentTypeRequest();
            request.setRequestInfo(requestInfo);
            request.setInstrumentTypes(new ArrayList<>());

            for (InstrumentType iac : resultList)
                request.getInstrumentTypes().add(mapper.toContract(iac));

            instrumentTypeQueueRepository.addToSearchQue(request);

            return resultList;
        }

    }

    @Autowired public  InstrumentTypeRepository(InstrumentTypeJdbcRepository instrumentTypeJdbcRepository,
            InstrumentTypeQueueRepository instrumentTypeQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentTypeESRepository instrumentTypeESRepository);

}