/** * Evaluates the predicate returning the opposite to the stored predicate. * * @param object the input object * @return true if predicate returns false */ public boolean evaluate(Object object) { return !(iPredicate.evaluate(object)); }
/** * Transforms the input to result by calling a predicate. * * @param input the input object to transform * @return the transformed result */ public Object transform(Object input) { return (iPredicate.evaluate(input) ? Boolean.TRUE : Boolean.FALSE); }
/** * Evaluates the predicate returning the result of the decorated predicate * once a null check is performed. * * @param object the input object * @return true if decorated predicate returns true, false if input is null */ public boolean evaluate(Object object) { if (object == null) { return false; } return iPredicate.evaluate(object); }
/** * Evaluates the predicate returning the result of the decorated predicate * once a null check is performed. * * @param object the input object * @return true if decorated predicate returns true or input is null */ public boolean evaluate(Object object) { if (object == null) { return true; } return iPredicate.evaluate(object); }
/** * {@inheritDoc} * * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object) */ public boolean evaluate( final Object object ) { return !EMPTY_MAP.evaluate( object ); }
/** * {@inheritDoc} * * @see org.apache.commons.collections.Predicate#evaluate(java.lang.Object) */ public boolean evaluate( final Object object ) { return object != null && !EMPTY_ARRAY.evaluate( object ); }
/** * Override to validate an object set into the map via <code>setValue</code>. * * @param value the value to validate * @throws IllegalArgumentException if invalid * @since Commons Collections 3.1 */ protected Object checkSetValue(Object value) { if (valuePredicate.evaluate(value) == false) { throw new IllegalArgumentException("Cannot set value - Predicate rejected it"); } return value; }
/** * Validates the object being added to ensure it matches the predicate. * <p> * The predicate itself should not throw an exception, but return false to * indicate that the object cannot be added. * * @param object the object being added * @throws IllegalArgumentException if the add is invalid */ protected void validate(Object object) { if (predicate.evaluate(object) == false) { throw new IllegalArgumentException("Cannot add Object '" + object + "' - Predicate rejected it"); } }
/** * Evaluates the predicate returning the result of the decorated predicate * once the input has been transformed * * @param object the input object which will be transformed * @return true if decorated predicate returns true */ public boolean evaluate(Object object) { Object result = iTransformer.transform(object); return iPredicate.evaluate(result); }
/** * Evaluates the predicate returning the result of the decorated predicate * once a null check is performed. * * @param object the input object * @return true if decorated predicate returns true * @throws FunctorException if input is null */ public boolean evaluate(Object object) { if (object == null) { throw new FunctorException("Input Object must not be null"); } return iPredicate.evaluate(object); }
/** * Executes the true or false closure accoring to the result of the predicate. * * @param input the input object */ public void execute(Object input) { if (iPredicate.evaluate(input) == true) { iTrueClosure.execute(input); } else { iFalseClosure.execute(input); } }
/** * Executes the closure until the predicate is false. * * @param input the input object */ public void execute(Object input) { if (iDoLoop) { iClosure.execute(input); } while (iPredicate.evaluate(input)) { iClosure.execute(input); } }
/** * Executes the closure whose matching predicate returns true * * @param input the input object */ public void execute(Object input) { for (int i = 0; i < iPredicates.length; i++) { if (iPredicates[i].evaluate(input) == true) { iClosures[i].execute(input); return; } } iDefault.execute(input); }
public void testUniquePredicate() { Predicate p = PredicateUtils.uniquePredicate(); assertEquals(true, p.evaluate(new Object())); assertEquals(true, p.evaluate(new Object())); assertEquals(true, p.evaluate(new Object())); assertEquals(true, p.evaluate(cString)); assertEquals(false, p.evaluate(cString)); assertEquals(false, p.evaluate(cString)); }
public void testInvokerPredicate2() { List list = new ArrayList(); assertEquals(false, PredicateUtils.invokerPredicate( "contains", new Class[] {Object.class}, new Object[] {cString}).evaluate(list)); list.add(cString); assertEquals(true, PredicateUtils.invokerPredicate( "contains", new Class[] {Object.class}, new Object[] {cString}).evaluate(list)); }
public void testInvokerPredicateEx3() { try { PredicateUtils.invokerPredicate("noSuchMethod").evaluate(new Object()); } catch (FunctorException ex) { return; } fail(); }
public void testInvokerPredicate2Ex3() { try { PredicateUtils.invokerPredicate( "noSuchMethod", new Class[] {Object.class}, new Object[] {cString}).evaluate(new Object()); } catch (FunctorException ex) { return; } fail(); }