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

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

public final class NullIsTruePredicate<E>
extends AbstractPredicateDecorator<E>

Predicate implementation that decorates an existing Predicate, returning true if the input is null, and otherwise delegating to the decorated Predicate.

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

Field Summary
 
Fields inherited from class net.sf.collections15.functors.predicate.AbstractPredicateDecorator
decoratedPredicate
 
Constructor Summary
protected NullIsTruePredicate(Predicate<? super E> predicate)
          Creates a new instance whose evaluate(E) method evaluates to true if the input is null, and otherwise delegates to the decorated Predicate.
 
Method Summary
 boolean evaluate(E object)
          Evaluates the Predicate, returning true if the input object is null, or delegating to the decorated Predicate if the input is non-null.
static
<E> NullIsTruePredicate<E>
getInstance(Predicate<? super E> predicate)
          Returns an instance whose evaluate(E) method evaluates to true if the input is null, and otherwise delegates to the decorated Predicate.
 
Methods inherited from class net.sf.collections15.functors.predicate.AbstractPredicateDecorator
getDecoratedPredicate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

NullIsTruePredicate

protected NullIsTruePredicate(Predicate<? super E> predicate)
Creates a new instance whose evaluate(E) method evaluates to true if the input is null, and otherwise delegates to the decorated Predicate.

Parameters:
predicate - The decorated Predicate.
Throws:
java.lang.IllegalArgumentException - Thrown if the Predicate is null.
Method Detail

getInstance

public static <E> NullIsTruePredicate<E> getInstance(Predicate<? super E> predicate)
Returns an instance whose evaluate(E) method evaluates to true if the input is null, and otherwise delegates to the decorated Predicate.

Parameters:
predicate - The decorated Predicate.
Returns:
A Predicate that evaluates to true for a null input object, or delegates to the specified Predicate for non-null input.
Throws:
java.lang.IllegalArgumentException - Thrown if the Predicate is null.

evaluate

public boolean evaluate(E object)
Evaluates the Predicate, returning true if the input object is null, or delegating to the decorated Predicate if the input is non-null.

Parameters:
object - The input object to evaluate.
Returns:
true if the input if null, or the result of the decorated Predicate if the input is non-null.


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