class InstrumentRepository {

    public Pagination<Instrument> search(InstrumentSearch domain) {

        if (financialConfigurationContractRepository.fetchDataFrom() != null
                && financialConfigurationContractRepository.fetchDataFrom().equalsIgnoreCase("es")) {

            InstrumentMapper mapper = new InstrumentMapper();
            InstrumentSearchContract instrumentSearchContract = new InstrumentSearchContract();
            instrumentSearchContract = mapper.toSearchContract(domain);
            Pagination<Instrument> instruments = instrumentESRepository.search(instrumentSearchContract);

            return instruments;

        } else
            return instrumentJdbcRepository.search(domain);

    }

    @Autowired public  InstrumentRepository(InstrumentJdbcRepository instrumentJdbcRepository,
            InstrumentQueueRepository instrumentQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            InstrumentESRepository instrumentESRepository,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            InstrumentVoucherJdbcRepository instrumentVoucherJdbcRepository);

}