작성
·
764
1
private BooleanExpression ageBetween(int ageLoe, int ageGoe) {
return ageGoe(ageGoe).and(ageLoe(ageLoe));
}
private BooleanBuilder usernameEq(String usernameCond) {
/*if (hasText(usernameCond)) {
return new BooleanBuilder().and(member.username.eq(usernameCond));
} else {
return new BooleanBuilder();
}*/
return nullSafeBuilder(() -> member.username.eq(usernameCond));
}
private BooleanBuilder teamNameEq(String teamNameCond) {
return nullSafeBuilder(() -> team.name.eq(teamNameCond));
}
private BooleanBuilder ageGoe(Integer ageGoeCond) {
/*if (ageGoeCond != null) {
return new BooleanBuilder().and(member.age.goe(ageGoeCond));
} else {
return new BooleanBuilder();
}*/
return nullSafeBuilder(() -> member.age.goe(ageGoeCond));
}
private BooleanBuilder ageLoe(Integer ageLoeCond) {
return nullSafeBuilder(() -> member.age.loe(ageLoeCond));
}
public static BooleanBuilder nullSafeBuilder(Supplier<BooleanExpression> f) {
try {
return new BooleanBuilder(f.get());
} catch (IllegalArgumentException e) {
return new BooleanBuilder();
} catch (NullPointerException e) {
return new BooleanBuilder();
}
}