I building a search query for area, whether it's just greater than start bound, lesser than end bound or between them. I am refactoring the method and wrapping if statements inside the single Specification predicate body. Before that an Specification was returned in each if statement.
private Specification<Listing> whereArea(Specification<Listing> spec, ListingSearchDTO dto) {
return (root, _, builder) -> {
Path<Integer> area = root.get("apartment").get("area");
if (dto.getM2From() != null && dto.getM2To() != null)
return builder.between(area, dto.getM2From(), dto.getM2To());
if (dto.getM2From() != null)
return builder.ge(area, dto.getM2From());
if (dto.getM2To() != null)
return builder.le(area, dto.getM2To());
return builder.; // return something here
};
}
What should I return as the default result? I can't seem to find anything about that in the docs.