class BankBranchRepository {

	@Transactional
	public List<BankBranch> save(List<BankBranch> bankBranches, RequestInfo requestInfo) {

		ModelMapper mapper = new ModelMapper();
		BankBranchContract contract;

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

			BankBranchRequest request = new BankBranchRequest();
			request.setRequestInfo(requestInfo);
			request.setBankBranches(new ArrayList<>());

			for (BankBranch b : bankBranches) {

				contract = new BankBranchContract();
				contract.setCreatedDate(new Date());
				mapper.map(b, contract);
				request.getBankBranches().add(contract);

			}

			addToQue(request);

			return bankBranches;
		} else {

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

			for (BankBranch b : bankBranches) {

				resultList.add(save(b));
			}

			BankBranchRequest request = new BankBranchRequest();
			request.setRequestInfo(requestInfo);
			request.setBankBranches(new ArrayList<>());

			for (BankBranch b : resultList) {

				contract = new BankBranchContract();
				contract.setCreatedDate(new Date());
				mapper.map(b, contract);
				request.getBankBranches().add(contract);

			}

			addToSearchQueue(request);

			return resultList;
		}

	}

	@Autowired public  BankBranchRepository(BankBranchJdbcRepository bankBranchJdbcRepository,
			MastersQueueRepository bankBranchQueueRepository,
			FinancialConfigurationService financialConfigurationService, BankBranchESRepository bankBranchESRepository,
			@Value("${persist.through.kafka}") String persistThroughKafka);

}