Search in sources :

Example 1 with NotPredicate

use of org.apache.commons.collections.functors.NotPredicate in project incubator-atlas by apache.

the class FilterUtil method getPredicateFromSearchFilter.

public static Predicate getPredicateFromSearchFilter(SearchFilter searchFilter) {
    List<Predicate> predicates = new ArrayList<>();
    final String type = searchFilter.getParam(SearchFilter.PARAM_TYPE);
    final String name = searchFilter.getParam(SearchFilter.PARAM_NAME);
    final String supertype = searchFilter.getParam(SearchFilter.PARAM_SUPERTYPE);
    final String notSupertype = searchFilter.getParam(SearchFilter.PARAM_NOT_SUPERTYPE);
    // Add filter for the type/category
    if (StringUtils.isNotBlank(type)) {
        predicates.add(getTypePredicate(type));
    }
    // Add filter for the name
    if (StringUtils.isNotBlank(name)) {
        predicates.add(getNamePredicate(name));
    }
    // Add filter for the supertype
    if (StringUtils.isNotBlank(supertype)) {
        predicates.add(getSuperTypePredicate(supertype));
    }
    // Add filter for the supertype negation
    if (StringUtils.isNotBlank(notSupertype)) {
        predicates.add(new NotPredicate(getSuperTypePredicate(notSupertype)));
    }
    return PredicateUtils.allPredicate(predicates);
}
Also used : ArrayList(java.util.ArrayList) NotPredicate(org.apache.commons.collections.functors.NotPredicate) Predicate(org.apache.commons.collections.Predicate) NotPredicate(org.apache.commons.collections.functors.NotPredicate)

Aggregations

ArrayList (java.util.ArrayList)1 Predicate (org.apache.commons.collections.Predicate)1 NotPredicate (org.apache.commons.collections.functors.NotPredicate)1