class RecoveryRepository {

    @Transactional
    public List<Recovery> save(List<Recovery> recoveries,
                               RequestInfo requestInfo) {

        ModelMapper mapper = new ModelMapper();
        RecoveryContract contract;

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

            RecoveryRequest request = new RecoveryRequest();
            request.setRequestInfo(requestInfo);
            request.setRecoverys(new ArrayList<>());

            for (Recovery f : recoveries) {

                contract = new RecoveryContract();
                contract.setCreatedDate(new Date());
                mapper.map(f, contract);
                request.getRecoverys().add(contract);

            }

            addToQue(request);

            return recoveries;
        } else {

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

            for (Recovery f : recoveries) {

                resultList.add(save(f));
            }

            RecoveryRequest request = new RecoveryRequest();
            request.setRequestInfo(requestInfo);
            request.setRecoverys(new ArrayList<>());

            for (Recovery f : resultList) {

                contract = new RecoveryContract();
                contract.setCreatedDate(new Date());
                mapper.map(f, contract);
                request.getRecoverys().add(contract);

            }

            addToSearchQueue(request);

            return resultList;
        }

    }

    @Autowired public  RecoveryRepository(MastersQueueRepository recoveryQueueRepository, FinancialConfigurationService financialConfigurationService,
                              @Value("${persist.through.kafka}") String persistThroughKafka,
                              RecoveryJdbcRepository recoveryJdbcRepository,
                              RecoveryESRepository recoveryESRepository);

}