Source:
private List<Predicate> buildParamPredicates(ChargeSearchParams params, CriteriaBuilder cb, Root<ChargeEntity> charge) { List<Predicate> predicates = new ArrayList<>(); if (params.getCardHolderName() != null && StringUtils.isNotBlank(params.getCardHolderName().toString())) predicates.add(likePredicate(cb, charge.get(CARD_DETAILS).get("cardHolderName"), params.getCardHolderName().toString().toLowerCase())); if (params.getLastDigitsCardNumber() != null && StringUtils.isNotBlank(params.getLastDigitsCardNumber().toString())) predicates.add(cb.equal(charge.get(CARD_DETAILS).get("lastDigitsCardNumber"), params.getLastDigitsCardNumber().toString())); if (params.getGatewayAccountId() != null) predicates.add(cb.equal(charge.get(GATEWAY_ACCOUNT).get("id"), params.getGatewayAccountId())); if (params.getReference() != null && StringUtils.isNotBlank(params.getReference().toString())) predicates.add(likePredicate(cb, charge.get(REFERENCE), params.getReference().toString())); if (StringUtils.isNotBlank(params.getEmail())) predicates.add(likePredicate(cb, charge.get(EMAIL), params.getEmail())); if (params.getInternalStates() != null && !params.getInternalStates().isEmpty()) predicates.add(charge.get(STATUS).in(params.getInternalStates())); if (!params.getCardBrands().isEmpty()) { predicates.add(charge.get(CARD_DETAILS).get("cardBrand").in(params.getCardBrands())); } if (params.getFromDate() != null) predicates.add(cb.greaterThanOrEqualTo(charge.get(CREATED_DATE), params.getFromDate())); if (params.getToDate() != null) predicates.add(cb.lessThan(charge.get(CREATED_DATE), params.getToDate())); return predicates; }

Target:
private List<Predicate> buildParamPredicates(ChargeSearchParams params, CriteriaBuilder cb, Root<ChargeEntity> charge) { List<Predicate> predicates = new ArrayList<>(); if (params.getCardHolderName() != null && StringUtils.isNotBlank(params.getCardHolderName().toString())) predicates.add(likePredicate(cb, charge.get(CARD_DETAILS).get("cardHolderName"), params.getCardHolderName().toString())); if (params.getLastDigitsCardNumber() != null && StringUtils.isNotBlank(params.getLastDigitsCardNumber().toString())) predicates.add(cb.equal(charge.get(CARD_DETAILS).get("lastDigitsCardNumber"), params.getLastDigitsCardNumber().toString())); if (params.getGatewayAccountId() != null) predicates.add(cb.equal(charge.get(GATEWAY_ACCOUNT).get("id"), params.getGatewayAccountId())); if (params.getReference() != null && StringUtils.isNotBlank(params.getReference().toString())) predicates.add(likePredicate(cb, charge.get(REFERENCE), params.getReference().toString())); if (StringUtils.isNotBlank(params.getEmail())) predicates.add(likePredicate(cb, charge.get(EMAIL), params.getEmail())); if (params.getInternalStates() != null && !params.getInternalStates().isEmpty()) predicates.add(charge.get(STATUS).in(params.getInternalStates())); if (!params.getCardBrands().isEmpty()) { predicates.add(charge.get(CARD_DETAILS).get("cardBrand").in(params.getCardBrands())); } if (params.getFromDate() != null) predicates.add(cb.greaterThanOrEqualTo(charge.get(CREATED_DATE), params.getFromDate())); if (params.getToDate() != null) predicates.add(cb.lessThan(charge.get(CREATED_DATE), params.getToDate())); return predicates; }