/** * Create a new Predicate that returns true if one, but not both, of the * specified predicates are true. * * @see org.apache.commons.collections.functors.OnePredicate * * @param predicate1 the first predicate, may not be null * @param predicate2 the second predicate, may not be null * @return the <code>either</code> predicate * @throws IllegalArgumentException if either predicate is null */ public static Predicate eitherPredicate(Predicate predicate1, Predicate predicate2) { return onePredicate(new Predicate[] { predicate1, predicate2 }); }
/** * Create a new Predicate that returns true if one, but not both, of the * specified predicates are true. * * @see org.apache.commons.collections.functors.OnePredicate * * @param predicate1 the first predicate, may not be null * @param predicate2 the second predicate, may not be null * @return the <code>either</code> predicate * @throws IllegalArgumentException if either predicate is null */ public static Predicate eitherPredicate(Predicate predicate1, Predicate predicate2) { return onePredicate(new Predicate[] { predicate1, predicate2 }); }
public void testOnePredicateEx5() { PredicateUtils.onePredicate(Collections.EMPTY_LIST); }
public void testOnePredicateEx6() { try { Collection coll = new ArrayList(); coll.add(null); coll.add(null); PredicateUtils.onePredicate(coll); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testOnePredicateEx1() { try { PredicateUtils.onePredicate((Predicate[]) null); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testOnePredicateEx2() { try { PredicateUtils.onePredicate(new Predicate[] {null}); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testOnePredicateEx3() { try { PredicateUtils.onePredicate(new Predicate[] {null, null}); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testOnePredicateEx4() { try { PredicateUtils.onePredicate((Collection) null); } catch (IllegalArgumentException ex) { return; } fail(); }
public void testOnePredicate() { assertFalse(PredicateUtils.onePredicate( new Predicate[] {}).evaluate(null)); assertEquals(false, PredicateUtils.onePredicate(new Predicate[] { PredicateUtils.truePredicate(), PredicateUtils.truePredicate(), PredicateUtils.truePredicate()}).evaluate(null)); assertEquals(false, PredicateUtils.onePredicate(new Predicate[] { PredicateUtils.truePredicate(), PredicateUtils.falsePredicate(), PredicateUtils.truePredicate()}).evaluate(null)); assertEquals(true, PredicateUtils.onePredicate(new Predicate[] { PredicateUtils.truePredicate(), PredicateUtils.falsePredicate(), PredicateUtils.falsePredicate()}).evaluate(null)); assertEquals(true, PredicateUtils.onePredicate(new Predicate[] { PredicateUtils.falsePredicate(), PredicateUtils.truePredicate(), PredicateUtils.falsePredicate()}).evaluate(null)); assertEquals(true, PredicateUtils.onePredicate(new Predicate[] { PredicateUtils.falsePredicate(), PredicateUtils.falsePredicate(), PredicateUtils.truePredicate()}).evaluate(null)); assertEquals(false, PredicateUtils.onePredicate(new Predicate[] { PredicateUtils.falsePredicate(), PredicateUtils.falsePredicate(), PredicateUtils.falsePredicate()}).evaluate(null)); Collection coll = new ArrayList(); coll.add(PredicateUtils.truePredicate()); coll.add(PredicateUtils.truePredicate()); assertEquals(false, PredicateUtils.onePredicate(coll).evaluate(null)); coll.clear(); coll.add(PredicateUtils.truePredicate()); coll.add(PredicateUtils.falsePredicate()); coll.add(PredicateUtils.truePredicate()); assertEquals(false, PredicateUtils.onePredicate(coll).evaluate(null)); coll.clear(); coll.add(PredicateUtils.falsePredicate()); coll.add(PredicateUtils.falsePredicate()); coll.add(PredicateUtils.truePredicate()); assertEquals(true, PredicateUtils.onePredicate(coll).evaluate(null));
/** * Create a new Predicate that returns true if one, but not both, of the * specified predicates are true. * * @see org.apache.commons.collections.functors.OnePredicate * * @param predicate1 the first predicate, may not be null * @param predicate2 the second predicate, may not be null * @return the <code>either</code> predicate * @throws IllegalArgumentException if either predicate is null */ public static Predicate eitherPredicate(Predicate predicate1, Predicate predicate2) { return onePredicate(new Predicate[] { predicate1, predicate2 }); }
/** * Create a new Predicate that returns true if one, but not both, of the * specified predicates are true. * * @see org.apache.commons.collections.functors.OnePredicate * * @param predicate1 the first predicate, may not be null * @param predicate2 the second predicate, may not be null * @return the <code>either</code> predicate * @throws IllegalArgumentException if either predicate is null */ public static Predicate eitherPredicate(Predicate predicate1, Predicate predicate2) { return onePredicate(new Predicate[] { predicate1, predicate2 }); }
/** * Create a new Predicate that returns true if one, but not both, of the * specified predicates are true. * * @see org.apache.commons.collections.functors.OnePredicate * * @param predicate1 the first predicate, may not be null * @param predicate2 the second predicate, may not be null * @return the <code>either</code> predicate * @throws IllegalArgumentException if either predicate is null */ public static Predicate eitherPredicate(Predicate predicate1, Predicate predicate2) { return onePredicate(new Predicate[] { predicate1, predicate2 }); }
/** * Create a new Predicate that returns true if one, but not both, of the * specified predicates are true. * * @see org.apache.commons.collections.functors.OnePredicate * * @param predicate1 the first predicate, may not be null * @param predicate2 the second predicate, may not be null * @return the <code>either</code> predicate * @throws IllegalArgumentException if either predicate is null */ public static Predicate eitherPredicate(Predicate predicate1, Predicate predicate2) { return onePredicate(new Predicate[] { predicate1, predicate2 }); }
/** * Create a new Predicate that returns true if one, but not both, of the * specified predicates are true. * * @see org.apache.commons.collections.functors.OnePredicate * * @param predicate1 the first predicate, may not be null * @param predicate2 the second predicate, may not be null * @return the <code>either</code> predicate * @throws IllegalArgumentException if either predicate is null */ public static Predicate eitherPredicate(Predicate predicate1, Predicate predicate2) { return onePredicate(new Predicate[] { predicate1, predicate2 }); }