net.sf.collections15.functors.predicate
Class TransformerPredicate<E>

java.lang.Object
  extended by net.sf.collections15.functors.predicate.TransformerPredicate<E>
All Implemented Interfaces:
java.io.Serializable, Predicate<E>

public final class TransformerPredicate<E>
extends java.lang.Object
implements Predicate<E>, java.io.Serializable

Predicate implementation that wraps a Transformer whose output type is Boolean. The Predicate evaluates true if the Transformer returns Boolean.TRUE, and evaluates to false if the Transformer returns Boolean.False or null.

Since:
Collections15 1.0
Author:
Stephen Colebourne, Chris Lambrou (port to Java 5.0)
See Also:
Serialized Form

Constructor Summary
protected TransformerPredicate(Transformer<E,java.lang.Boolean> transformer)
          Creates a new instance that evaluates input objects using the specified Transformer.
 
Method Summary
 boolean evaluate(E object)
          Evaluates the Predicate returning the result of the wrapped Transformer.
static
<T> Predicate<T>
getInstance(Transformer<T,java.lang.Boolean> transformer)
          Returns an instance that evaluates input objects using the specified Transformer.
 Transformer<E,java.lang.Boolean> getTransformer()
          Returns the underlying Transformer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TransformerPredicate

protected TransformerPredicate(Transformer<E,java.lang.Boolean> transformer)
Creates a new instance that evaluates input objects using the specified Transformer.

Parameters:
transformer - The Transformer to use.
Throws:
java.lang.IllegalArgumentException - Thrown if the transformer argument is null.
Method Detail

getInstance

public static <T> Predicate<T> getInstance(Transformer<T,java.lang.Boolean> transformer)
Returns an instance that evaluates input objects using the specified Transformer.

Parameters:
transformer - The Transformer to use.
Returns:
A Predicate that evaluates input objects using the specified Transformer.
Throws:
java.lang.IllegalArgumentException - Thrown if the transformer argument is null.

evaluate

public boolean evaluate(E object)
Evaluates the Predicate returning the result of the wrapped Transformer.

Specified by:
evaluate in interface Predicate<E>
Parameters:
object - The input object yo evaluate.
Returns:
true if the underlying Transformer returns Boolean.TRUE. false if the underlying Transformer returns Boolean.FALSE or null.

getTransformer

public Transformer<E,java.lang.Boolean> getTransformer()
Returns the underlying Transformer.

Returns:
The underlying Transformer.
Since:
Collections15 1.0


Copyright © 2001-2005 SourceForge.net. All Rights Reserved.