class BankBranchService {

	public BindingResult validate(BankBranchContractRequest bankBranchContractRequest, String method,
			BindingResult errors) {

		try {
			switch (method) {
			case "update":
				Assert.notNull(bankBranchContractRequest.getBankBranch(), "BankBranch to edit must not be null");
				validator.validate(bankBranchContractRequest.getBankBranch(), errors);
				break;
			case "view":
				// validator.validate(bankBranchContractRequest.getBankBranch(),
				// errors);
				break;
			case "create":
				Assert.notNull(bankBranchContractRequest.getBankBranches(), "BankBranches to create must not be null");
				for (BankBranchContract b : bankBranchContractRequest.getBankBranches()) {
					validator.validate(b, errors);
				}
				break;
			case "updateAll":
				Assert.notNull(bankBranchContractRequest.getBankBranches(), "BankBranches to update must not be null");
				for (BankBranchContract b : bankBranchContractRequest.getBankBranches()) {
					validator.validate(b, errors);
				}
				break;
			default:
				validator.validate(bankBranchContractRequest.getRequestInfo(), errors);
			}
		} catch (IllegalArgumentException e) {
			errors.addError(new ObjectError("Missing data ", e.getMessage()));
		}
		return errors;

	}

	@Autowired public  BankBranchService(final BankBranchRepository bankBranchRepository,
			BankBranchQueueRepository bankBranchQueueRepository,BankService bankService,SmartValidator validator);

}