Created
June 23, 2017 01:04
-
-
Save iamthiago/83c2e5c333e1a47dc8ed54fa162ac2b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private Predicate createAdvancedSearchQuery(Long maxPrice, Long minPrice, Integer beds, Integer baths, String province) { | |
QProperty property = QProperty.property; | |
BooleanBuilder booleanBuilder = new BooleanBuilder(); | |
if(maxPrice != null && minPrice != null) { | |
booleanBuilder.and(property.price.between(minPrice, maxPrice)); | |
} else if (maxPrice != null) { | |
booleanBuilder.and(property.price.loe(maxPrice)); | |
} else if (minPrice != null) { | |
booleanBuilder.and(property.price.goe(minPrice)); | |
} | |
if(beds != null){ | |
booleanBuilder.and(property.beds.eq(beds)); | |
} | |
if(baths != null){ | |
booleanBuilder.and(property.baths.eq(baths)); | |
} | |
if(!StringUtils.isEmpty(province)) { | |
booleanBuilder.and(property.provinces.contains(Province.valueOf(province))); | |
} | |
return booleanBuilder.getValue(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment