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

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

public final class AnyPredicate<T>
extends AbstractQuantifierPredicate<T>
implements Serializable

Predicate implementation that returns true if any of the predicates return true. If the array of predicates is empty, then this predicate returns false.

NOTE: In versions prior to 3.2 an array size of zero or one threw an exception.

Since:
3.0
Version:
$Id: AnyPredicate.java 1479340 2013-05-05 15:37:41Z tn $
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.apache.commons.collections4.functors.AbstractQuantifierPredicate
iPredicates
 
Constructor Summary
AnyPredicate(Predicate<? super T>... predicates)
          Constructor that performs no validation.
 
Method Summary
static
<T> Predicate<T>
anyPredicate(Collection<? extends Predicate<T>> predicates)
          Factory to create the predicate.
static
<T> Predicate<T>
anyPredicate(Predicate<? super T>... predicates)
          Factory to create the predicate.
 boolean evaluate(T object)
          Evaluates the predicate returning true if any predicate returns true.
 
Methods inherited from class org.apache.commons.collections4.functors.AbstractQuantifierPredicate
getPredicates
 
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 anyPredicate if you want that.

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

anyPredicate

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

If the array is size zero, the predicate always returns false. If the array is size one, then that predicate is returned.

Type Parameters:
T - the type that the predicate queries
Parameters:
predicates - the predicates to check, cloned, not null
Returns:
the any predicate
Throws:
IllegalArgumentException - if the predicates array is null
IllegalArgumentException - if any predicate in the array is null

anyPredicate

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

If the collection is size zero, the predicate always returns false. If the collection is size one, then that predicate is returned.

Type Parameters:
T - the type that the predicate queries
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

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


Copyright © 2001–2013 The Apache Software Foundation. All rights reserved.