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

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

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

Predicate implementation that transforms the given object before invoking another Predicate.

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

Constructor Summary
TransformedPredicate(Transformer<? super T,? extends T> transformer, Predicate<? super T> predicate)
          Constructor that performs no validation.
 
Method Summary
 boolean evaluate(T object)
          Evaluates the predicate returning the result of the decorated predicate once the input has been transformed
 Predicate<? super T>[] getPredicates()
          Gets the predicate being decorated.
 Transformer<? super T,? extends T> getTransformer()
          Gets the transformer in use.
static
<T> Predicate<T>
transformedPredicate(Transformer<? super T,? extends T> transformer, Predicate<? super T> predicate)
          Factory to create the predicate.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformedPredicate

public TransformedPredicate(Transformer<? super T,? extends T> transformer,
                            Predicate<? super T> predicate)
Constructor that performs no validation. Use transformedPredicate if you want that.

Parameters:
transformer - the transformer to use
predicate - the predicate to decorate
Method Detail

transformedPredicate

public static <T> Predicate<T> transformedPredicate(Transformer<? super T,? extends T> transformer,
                                                    Predicate<? super T> predicate)
Factory to create the predicate.

Type Parameters:
T - the type that the predicate queries
Parameters:
transformer - the transformer to call
predicate - the predicate to call with the result of the transform
Returns:
the predicate
Throws:
IllegalArgumentException - if the transformer or the predicate is null

evaluate

public boolean evaluate(T object)
Evaluates the predicate returning the result of the decorated predicate once the input has been transformed

Specified by:
evaluate in interface Predicate<T>
Parameters:
object - the input object which will be transformed
Returns:
true if decorated predicate returns true

getPredicates

public Predicate<? super T>[] getPredicates()
Gets the predicate being decorated.

Specified by:
getPredicates in interface PredicateDecorator<T>
Returns:
the predicate as the only element in an array
Since:
3.1

getTransformer

public Transformer<? super T,? extends T> getTransformer()
Gets the transformer in use.

Returns:
the transformer


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