Skip to content

Commit

Permalink
Merge pull request #20 from elwyncrestha/department
Browse files Browse the repository at this point in the history
Department Filter
  • Loading branch information
elwyncrestha committed Jul 1, 2020
2 parents 8c63da2 + a9c7854 commit a4a238a
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
*/
public class DepartmentSpec implements Specification<Department> {

private static final String FILTER_BY_NAME = "name";

private final String property;
private final String value;

Expand All @@ -25,6 +27,10 @@ public DepartmentSpec(String property, String value) {
@Override
public Predicate toPredicate(Root<Department> root, CriteriaQuery<?> criteriaQuery,
CriteriaBuilder criteriaBuilder) {
switch (property) {
case FILTER_BY_NAME:
return criteriaBuilder.like(root.get(FILTER_BY_NAME), "%" + value + "%");
}
return null;
}
}

0 comments on commit a4a238a

Please sign in to comment.