net.sf.collections15.functors.predicate
Class AllPredicate<E>

java.lang.Object
  extended by net.sf.collections15.functors.predicate.AbstractMultplePredicateDecorator<E>
      extended by net.sf.collections15.functors.predicate.AllPredicate<E>
All Implemented Interfaces:
java.io.Serializable, MultplePredicateDecorator<E>, Predicate<E>

public final class AllPredicate<E>
extends AbstractMultplePredicateDecorator<E>

Predicate implementation that returns true only if all the Predicates return true. i.e. it returns the logical AND of the wrapped Predicates.

More specifically, an AllPredicate will evaluate to true unless any of its wrapped Predicates evaluate to false. This implies that if its collection of wrapped Predicates is empty, an AllPredicate will always evaluate to true.

Since:
Collections15 1.0
Author:
Stephen Colebourne, Chris Lambrou (port to Java 5.0)
See Also:
Serialized Form

Field Summary
 
Fields inherited from class net.sf.collections15.functors.predicate.AbstractMultplePredicateDecorator
decoratedPredicates
 
Constructor Summary
protected AllPredicate(java.util.Collection<Predicate<? super E>> predicates)
          Creates a new instance that wraps the specified collection of Predicates.
 
Method Summary
 boolean evaluate(E object)
          Evaluates the Predicate, returning true unless any of the wrapped Predicates returns false.
static
<T> AllPredicate<T>
getInstance(java.util.Collection<Predicate<? super T>> predicates)
          Returns an instance that wraps the specified collection of Predicates.
 
Methods inherited from class net.sf.collections15.functors.predicate.AbstractMultplePredicateDecorator
getDecoratedPredicates
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AllPredicate

protected AllPredicate(java.util.Collection<Predicate<? super E>> predicates)
Creates a new instance that wraps the specified collection of Predicates.

Parameters:
predicates - The Predicates to wrap. The contents of the collection are defensively copied by the new instance.
Throws:
java.lang.IllegalArgumentException - Thrown if the collection, or any of its elements are null. The collection may be empty, however, in which case the resulting AllPredicate will always return true.
Method Detail

getInstance

public static <T> AllPredicate<T> getInstance(java.util.Collection<Predicate<? super T>> predicates)
Returns an instance that wraps the specified collection of Predicates.

Parameters:
predicates - The Predicates to wrap. The contents of the collection are defensively copied by the new instance.
Returns:
A Predicate instance that will evaluate to true unless any of the wrapped Predicates evaluate to false.
Throws:
java.lang.IllegalArgumentException - Thrown if the collection, or any of its elements are null. The collection may be empty, however, in which case the resulting AllPredicate will always return true.

evaluate

public boolean evaluate(E object)
Evaluates the Predicate, returning true unless any of the wrapped Predicates returns false.

Parameters:
object - The input object to evaluate.
Returns:
true unless any of the wrapped Predicates evaluates to false.


Copyright © 2001-2005 SourceForge.net. All Rights Reserved.