org.apache.commons.collections.functors.NotPredicate Java Examples
The following examples show how to use
org.apache.commons.collections.functors.NotPredicate.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FilterUtil.java From incubator-atlas with Apache License 2.0 | 5 votes |
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); }
Example #2
Source File: FilterUtil.java From atlas with Apache License 2.0 | 4 votes |
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 serviceType = searchFilter.getParam(SearchFilter.PARAM_SERVICETYPE); final String notSupertype = searchFilter.getParam(SearchFilter.PARAM_NOT_SUPERTYPE); final String notServiceType = searchFilter.getParam(SearchFilter.PARAM_NOT_SERVICETYPE); final List<String> notNames = searchFilter.getParams(SearchFilter.PARAM_NOT_NAME); // 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 serviceType if(StringUtils.isNotBlank(serviceType)) { predicates.add(getServiceTypePredicate(serviceType)); } // 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))); } // Add filter for the serviceType negation // NOTE: Creating code for the exclusion of multiple service types is currently useless. // In fact the getSearchFilter in TypeREST.java uses the HttpServletRequest.getParameter(key) // that if the key takes more values it takes only the first the value. Could be useful // to change the getSearchFilter to use getParameterValues instead of getParameter. if (StringUtils.isNotBlank(notServiceType)) { predicates.add(new NotPredicate(getServiceTypePredicate(notServiceType))); } // Add filter for the type negation if (CollectionUtils.isNotEmpty(notNames)) { for (String notName : notNames) { predicates.add(new NotPredicate(getNamePredicate(notName))); } } return PredicateUtils.allPredicate(predicates); }
Example #3
Source File: PredicateUtils.java From Penetration_Testing_POC with Apache License 2.0 | 2 votes |
/** * Create a new Predicate that returns true if the specified predicate * returns false and vice versa. * * @see org.apache.commons.collections.functors.NotPredicate * * @param predicate the predicate to not * @return the <code>not</code> predicate * @throws IllegalArgumentException if the predicate is null */ public static Predicate notPredicate(Predicate predicate) { return NotPredicate.getInstance(predicate); }