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

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

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

Predicate implementation that decorates an existing Predicate. The evaluate(E) method throws an exception if the input is null, and otherwise defers to the decorated Predicate.

Since:
Commons 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 NullIsExceptionPredicate(Predicate<? super E> predicate)
          Creats a new instance that decorates the specified Predicate.
 
Method Summary
 boolean evaluate(E object)
          Evaluates the Predicate, throwing an exception if the input object is null or otherwise delegating to the decorated Predicate.
static
<E> NullIsExceptionPredicate<E>
getInstance(Predicate<? super E> predicate)
          Creates a new instance that decorates the specified 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

NullIsExceptionPredicate

protected NullIsExceptionPredicate(Predicate<? super E> predicate)
Creats a new instance that decorates the specified Predicate.

Parameters:
predicate - The decorated Predicate that is delgated to if the null check doesn't throw an exception.
Throws:
java.lang.IllegalArgumentException - Thrown if the specified Predicate to decorate is null.
Method Detail

getInstance

public static <E> NullIsExceptionPredicate<E> getInstance(Predicate<? super E> predicate)
Creates a new instance that decorates the specified Predicate.

Parameters:
predicate - The decorated Predicate that is delgated to if the null check doesn't throw an exception.
Returns:
A new instance that decorates the specified Predicate.
Throws:
java.lang.IllegalArgumentException - Thrown if the specified Predicate to decorate is null.

evaluate

public boolean evaluate(E object)
Evaluates the Predicate, throwing an exception if the input object is null or otherwise delegating to the decorated Predicate.

Parameters:
object - The input object to evaluate.
Returns:
true if the decorated Predicate returns true. false if the decorated Predicate returns false.
Throws:
FunctorException - Thrown if the input object is null.


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