com.infomancers.collections.util
Class PredicateCollection<T>

java.lang.Object
  extended by com.infomancers.collections.util.PredicateCollection<T>
All Implemented Interfaces:
Predicate<T>

public final class PredicateCollection<T>
extends java.lang.Object
implements Predicate<T>

Used to evaluate an item against a collection of predicates.


Nested Class Summary
static class PredicateCollection.Type
           
 
Constructor Summary
PredicateCollection(PredicateCollection.Type type)
           
 
Method Summary
 void add(Predicate<T> pred)
           
 boolean evaluate(T item)
          Evaluates the item against all predicates in the collection.
 void remove(Predicate<T> pred)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PredicateCollection

public PredicateCollection(PredicateCollection.Type type)
Method Detail

add

public void add(Predicate<T> pred)

evaluate

public boolean evaluate(T item)
Evaluates the item against all predicates in the collection.

If needsAll is set to true, the collection will behave like an "AND" chain. Otherwise, the collection will behave like an "OR" chain.

Specified by:
evaluate in interface Predicate<T>
Parameters:
item - The item to evaluate.
Returns:
Whether the item fits all the collection's predicates.

remove

public void remove(Predicate<T> pred)