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

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

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

Predicate implementation that returns true if both the predicates return true.

Since:
3.0
Version:
$Id: AndPredicate.java 1476582 2013-04-27 14:13:54Z tn $
See Also:
Serialized Form

Constructor Summary
AndPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
          Constructor that performs no validation.
 
Method Summary
static
<T> Predicate<T>
andPredicate(Predicate<? super T> predicate1, Predicate<? super T> predicate2)
          Factory to create the predicate.
 boolean evaluate(T object)
          Evaluates the predicate returning true if both predicates return true.
 Predicate<? super T>[] getPredicates()
          Gets the two predicates being decorated as an array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AndPredicate

public AndPredicate(Predicate<? super T> predicate1,
                    Predicate<? super T> predicate2)
Constructor that performs no validation. Use andPredicate if you want that.

Parameters:
predicate1 - the first predicate to check, not null
predicate2 - the second predicate to check, not null
Method Detail

andPredicate

public static <T> Predicate<T> andPredicate(Predicate<? super T> predicate1,
                                            Predicate<? super T> predicate2)
Factory to create the predicate.

Type Parameters:
T - the type that the predicate queries
Parameters:
predicate1 - the first predicate to check, not null
predicate2 - the second predicate to check, not null
Returns:
the and predicate
Throws:
IllegalArgumentException - if either predicate is null

evaluate

public boolean evaluate(T object)
Evaluates the predicate returning true if both predicates return true.

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

getPredicates

public Predicate<? super T>[] getPredicates()
Gets the two predicates being decorated as an array.

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


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