class SurrenderReasonRepository {

    @Transactional
    public List<SurrenderReason> save(List<SurrenderReason> surrenderReasons, RequestInfo requestInfo) {

        SurrenderReasonMapper mapper = new SurrenderReasonMapper();

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

            SurrenderReasonRequest request = new SurrenderReasonRequest();
            request.setRequestInfo(requestInfo);
            request.setSurrenderReasons(new ArrayList<>());

            for (SurrenderReason iac : surrenderReasons)
                request.getSurrenderReasons().add(mapper.toContract(iac));

            surrenderReasonQueueRepository.addToQue(request);

            return surrenderReasons;
        } else {

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

            for (SurrenderReason iac : surrenderReasons)
                resultList.add(save(iac));

            SurrenderReasonRequest request = new SurrenderReasonRequest();
            request.setRequestInfo(requestInfo);
            request.setSurrenderReasons(new ArrayList<>());

            for (SurrenderReason iac : resultList)
                request.getSurrenderReasons().add(mapper.toContract(iac));

            surrenderReasonQueueRepository.addToSearchQue(request);

            return resultList;
        }

    }

    @Autowired public  SurrenderReasonRepository(SurrenderReasonJdbcRepository surrenderReasonJdbcRepository,
            SurrenderReasonQueueRepository surrenderReasonQueueRepository,
            @Value("${persist.through.kafka}") String persistThroughKafka,
            FinancialConfigurationContractRepository financialConfigurationContractRepository,
            SurrenderReasonESRepository surrenderReasonESRepository);

}