org.apache.commons.collections.functors
Class AnyPredicate<T>

java.lang.Object
  extended by org.apache.commons.collections.functors.AnyPredicate<T>
All Implemented Interfaces:
Serializable, PredicateDecorator<T>, Predicate<T>

public final class AnyPredicate<T>
extends Object
implements Predicate<T>, PredicateDecorator<T>, Serializable

Predicate implementation that returns true if any of the predicates return true.

Since:
Commons Collections 3.0
Version:
$Revision: 1.1.1.1 $ $Date: 2005/05/23 04:34:13 $
Author:
Matt Hall, John Watkinson, Stephen Colebourne
See Also:
Serialized Form

Constructor Summary
AnyPredicate(Predicate<? super T>[] predicates)
          Constructor that performs no validation.
 
Method Summary
 boolean evaluate(T object)
          Evaluates the predicate returning true if any predicate returns true.
static
<T> Predicate<T>
getInstance(Collection<Predicate<? super T>> predicates)
          Factory to create the predicate.
static
<T> Predicate<T>
getInstance(Predicate<? super T>[] predicates)
          Factory to create the predicate.
 Predicate<? super T>[] getPredicates()
          Gets the predicates, do not modify the array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnyPredicate

public AnyPredicate(Predicate<? super T>[] predicates)
Constructor that performs no validation. Use getInstance if you want that.

Parameters:
predicates - the predicates to check, not cloned, not null
Method Detail

getInstance

public static <T> Predicate<T> getInstance(Predicate<? super T>[] predicates)
Factory to create the predicate.

Parameters:
predicates - the predicates to check, cloned, not null
Returns:
the any predicate
Throws:
IllegalArgumentException - if the predicates array is null
IllegalArgumentException - if the predicates array has less than 2 elements
IllegalArgumentException - if any predicate in the array is null

getInstance

public static <T> Predicate<T> getInstance(Collection<Predicate<? super T>> predicates)
Factory to create the predicate.

Parameters:
predicates - the predicates to check, cloned, not null
Returns:
the all predicate
Throws:
IllegalArgumentException - if the predicates array is null
IllegalArgumentException - if any predicate in the array is null
IllegalArgumentException - if the predicates array has less than 2 elements

evaluate

public boolean evaluate(T object)
Evaluates the predicate returning true if any predicate returns true.

Specified by:
evaluate in interface Predicate<T>
Parameters:
object - the input object
Returns:
true if any decorated predicate return true

getPredicates

public Predicate<? super T>[] getPredicates()
Gets the predicates, do not modify the array.

Specified by:
getPredicates in interface PredicateDecorator<T>
Returns:
the predicates
Since:
Commons Collections 3.1


Copyright © 2005-2005 Apache Software Foundation, Matt Hall, John Watkinson. All Rights Reserved.