public void testAllPredicateEx5() { PredicateUtils.allPredicate(Collections.EMPTY_LIST); }
public void testAllPredicateEx4() { try { PredicateUtils.allPredicate((Collection) null); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testAllPredicateEx2() { try { PredicateUtils.allPredicate(new Predicate[] {null}); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testAllPredicateEx1() { try { PredicateUtils.allPredicate((Predicate[]) null); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testAllPredicateEx3() { try { PredicateUtils.allPredicate(new Predicate[] {null, null}); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testAllPredicateEx6() { try { Collection coll = new ArrayList(); coll.add(null); coll.add(null); PredicateUtils.allPredicate(coll); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testAllPredicate() { assertTrue(PredicateUtils.allPredicate( new Predicate[] {}).evaluate(null)); assertEquals(true, PredicateUtils.allPredicate(new Predicate[] { PredicateUtils.truePredicate(), PredicateUtils.truePredicate(), PredicateUtils.truePredicate()}).evaluate(null)); assertEquals(false, PredicateUtils.allPredicate(new Predicate[] { PredicateUtils.truePredicate(), PredicateUtils.falsePredicate(), PredicateUtils.truePredicate()}).evaluate(null)); assertEquals(false, PredicateUtils.allPredicate(new Predicate[] { PredicateUtils.falsePredicate(), PredicateUtils.falsePredicate(), PredicateUtils.truePredicate()}).evaluate(null)); assertEquals(false, PredicateUtils.allPredicate(new Predicate[] { PredicateUtils.falsePredicate(), PredicateUtils.falsePredicate(), PredicateUtils.falsePredicate()}).evaluate(null)); Collection coll = new ArrayList(); coll.add(PredicateUtils.truePredicate()); coll.add(PredicateUtils.truePredicate()); assertEquals(true, PredicateUtils.allPredicate(coll).evaluate(null)); coll.clear(); coll.add(PredicateUtils.truePredicate()); coll.add(PredicateUtils.falsePredicate()); coll.add(PredicateUtils.truePredicate()); assertEquals(false, PredicateUtils.allPredicate(coll).evaluate(null)); coll.clear(); coll.add(PredicateUtils.falsePredicate()); coll.add(PredicateUtils.falsePredicate()); coll.add(PredicateUtils.truePredicate()); assertEquals(false, PredicateUtils.allPredicate(coll).evaluate(null)); coll.clear(); coll.add(PredicateUtils.falsePredicate()); coll.add(PredicateUtils.falsePredicate()); coll.add(PredicateUtils.falsePredicate());
public boolean evaluate(Object arg0) { Predicate judgement = new NullPredicate(); if (predicates.size() == 1) { judgement = predicates.get(0); } else { if (conj == Conjunction.AND) { judgement = PredicateUtils.allPredicate(predicates); } else if (conj == Conjunction.OR) { judgement = PredicateUtils.anyPredicate(predicates); } } return judgement.evaluate(arg0); }
public boolean evaluate(Object arg0) { Predicate judgement = new NullPredicate(); if (predicates.size() == 1) { judgement = predicates.get(0); } else { if (conj == Conjunction.AND) { judgement = PredicateUtils.allPredicate(predicates); } else if (conj == Conjunction.OR) { judgement = PredicateUtils.anyPredicate(predicates); } } return judgement.evaluate(arg0); }
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); }
public static DescribableList<GhprbExtension, GhprbExtensionDescriptor> matchesAll( DescribableList<GhprbExtension, GhprbExtensionDescriptor> extensions, Class<?>... types ) { Predicate predicate = PredicateUtils.allPredicate(createPredicate(types)); DescribableList<GhprbExtension, GhprbExtensionDescriptor> copyExtensions = new DescribableList<>(Saveable.NOOP); copyExtensions.addAll(extensions); filterList(copyExtensions, predicate); return copyExtensions; }
return PredicateUtils.allPredicate(predicates);
private Predicate toInMemoryPredicate(AtlasStructType type, FilterCriteria criteria, Set<String> indexAttributes) { if (criteria.getCondition() != null && CollectionUtils.isNotEmpty(criteria.getCriterion())) { List<Predicate> predicates = new ArrayList<>(); for (FilterCriteria filterCriteria : criteria.getCriterion()) { Predicate predicate = toInMemoryPredicate(type, filterCriteria, indexAttributes); if (predicate != null) { predicates.add(predicate); } } if (CollectionUtils.isNotEmpty(predicates)) { if (criteria.getCondition() == Condition.AND) { return PredicateUtils.allPredicate(predicates); } else { return PredicateUtils.anyPredicate(predicates); } } } else if (indexAttributes.contains(criteria.getAttributeName())){ return toInMemoryPredicate(type, criteria.getAttributeName(), criteria.getOperator(), criteria.getAttributeValue()); } return null; }