/** * Evaluates the predicate returning the opposite to the stored predicate. * * @param object the input object * @return true if predicate returns false */ @Override public boolean evaluate(final T object) { 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 */ @Override public boolean evaluate(final T object) { if (object == null) { return true; } 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, false if input is null */ @Override public boolean evaluate(final T object) { if (object == null) { return false; } return iPredicate.evaluate(object); }
/** * Evaluates the predicate returning true if any predicate returns true. * * @param object the input object * @return true if any decorated predicate return true */ @Override public boolean evaluate(final T object) { for (final Predicate<? super T> iPredicate : iPredicates) { if (iPredicate.evaluate(object)) { return true; } } return false; }
/** * Evaluates the predicate returning true if all predicates return true. * * @param object the input object * @return true if all decorated predicates return true */ @Override public boolean evaluate(final T object) { for (final Predicate<? super T> iPredicate : iPredicates) { if (!iPredicate.evaluate(object)) { return false; } } return true; }
/** * Evaluates the predicate returning false if any stored predicate returns false. * * @param object the input object * @return true if none of decorated predicates return true */ @Override public boolean evaluate(final T object) { for (final Predicate<? super T> iPredicate : iPredicates) { if (iPredicate.evaluate(object)) { return false; } } return true; }
/** * Transforms the input to result by calling a predicate. * * @param input the input object to transform * @return the transformed result */ @Override public Boolean transform(final T input) { return Boolean.valueOf(iPredicate.evaluate(input)); }
/** * Validates a key value pair. * * @param key the key to validate * @param value the value to validate * @throws IllegalArgumentException if invalid */ protected void validate(final K key, final V value) { if (keyPredicate != null && keyPredicate.evaluate(key) == false) { throw new IllegalArgumentException("Cannot add key - Predicate rejected it"); } if (valuePredicate != null && valuePredicate.evaluate(value) == false) { throw new IllegalArgumentException("Cannot add value - Predicate rejected it"); } }
/** * 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(final E object) { if (predicate.evaluate(object) == false) { throw new IllegalArgumentException("Cannot add Object '" + object + "' - Predicate '" + predicate + "' rejected it"); } }
/** * Override to validate an object set into the map via <code>setValue</code>. * * @param value the value to validate * @return the value itself * @throws IllegalArgumentException if invalid * @since 3.1 */ @Override protected V checkSetValue(final V value) { if (valuePredicate.evaluate(value) == false) { throw new IllegalArgumentException("Cannot set value - Predicate rejected it"); } return value; }
/** * Set nextObject to the next object. If there are no more * objects then return false. Otherwise, return true. */ private boolean setNextObject() { while (iterator.hasNext()) { final E object = iterator.next(); if (predicate.evaluate(object)) { nextObject = object; nextObjectSet = true; return true; } } return false; }
/** * 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 */ @Override public boolean evaluate(final T object) { final T result = iTransformer.transform(object); return iPredicate.evaluate(result); }
private <T extends Abi.Entry> T find(Class<T> resultClass, final Abi.Entry.Type type, final Predicate<T> searchPredicate) { return (T) CollectionUtils.find(this, entry -> entry.type == type && searchPredicate.evaluate((T) entry)); }
/** * 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 */ @Override public boolean evaluate(final T object) { if (object == null) { throw new FunctorException("Input Object must not be null"); } return iPredicate.evaluate(object); }
/** * Executes the closure whose matching predicate returns true * * @param input the input object */ @Override public void execute(final E input) { for (int i = 0; i < iPredicates.length; i++) { if (iPredicates[i].evaluate(input) == true) { iClosures[i].execute(input); return; } } iDefault.execute(input); }
/** * Transforms the input using the true or false transformer based to the result of the predicate. * * @param input the input object to transform * @return the transformed result */ @Override public O transform(final I input) { if(iPredicate.evaluate(input)){ return iTrueTransformer.transform(input); } return iFalseTransformer.transform(input); }
/** * Executes the true or false closure according to the result of the predicate. * * @param input the input object */ @Override public void execute(final E input) { if (iPredicate.evaluate(input)) { iTrueClosure.execute(input); } else { iFalseClosure.execute(input); } }
/** * Executes the closure until the predicate is false. * * @param input the input object */ @Override public void execute(final E input) { if (iDoLoop) { iClosure.execute(input); } while (iPredicate.evaluate(input)) { iClosure.execute(input); } }