net.sf.staccatocommons.lang.predicate
Class AbstractPredicate<A>

java.lang.Object
  extended by net.sf.staccatocommons.lang.predicate.AbstractPredicate<A>
Type Parameters:
A - the type of argument to evaluate
All Implemented Interfaces:
Applicable<A,Boolean>, Evaluable<A>, Predicate<A>
Direct Known Subclasses:
AbstractPredicate.Soft

public abstract class AbstractPredicate<A>
extends Object
implements Predicate<A>

A AbstractPredicate is an abstract Evaluable.

Predicates in addition understand the basic boolean logic messages not(), and(Evaluable) and or(Evaluable) that perform those operations on evaluation result.

Author:
flbulgarelli

Nested Class Summary
static class AbstractPredicate.Soft<A>
          AbstractPredicate that handles exceptions by softening them using SoftException.soften(Throwable)
 
Constructor Summary
AbstractPredicate()
           
 
Method Summary
 Predicate<A> and(Evaluable<? super A> other)
          Returns a predicate that performs a short-circuit logical-and between this AbstractPredicate's eval(Object) and other
 Predicate<A> andNotNull()
           
 Boolean apply(A arg)
           
abstract  boolean eval(A argument)
           
 Predicate<A> not()
           
<B> Predicate<B>
of(Applicable<? super B,? extends A> other)
           
 Predicate<A> or(Evaluable<? super A> other)
          Returns a predicate that, performs a short-circuit logical-or between this AbstractPredicate's eval(Object) and other
 Predicate<A> orNull()
           
 String toString()
           
 Predicate<A> withEffectOnFalse(Executable<A> executable)
           
 Predicate<A> withEffectOnTrue(Executable<A> executable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AbstractPredicate

public AbstractPredicate()
Method Detail

eval

public abstract boolean eval(@NonNull
                             A argument)
Specified by:
eval in interface Evaluable<A>

apply

public Boolean apply(A arg)
Specified by:
apply in interface Applicable<A,Boolean>

not

public Predicate<A> not()
Specified by:
not in interface Predicate<A>
Returns:
a AbstractPredicate that negates this AbstractPredicate's result. Non Null.

or

public Predicate<A> or(@NonNull
                       Evaluable<? super A> other)
Returns a predicate that, performs a short-circuit logical-or between this AbstractPredicate's eval(Object) and other

Specified by:
or in interface Predicate<A>
Parameters:
other - another Evaluable. Non null.
Returns:
A new predicate that performs the short circuited or between this and other when evaluated. Non Null

and

public Predicate<A> and(@NonNull
                        Evaluable<? super A> other)
Returns a predicate that performs a short-circuit logical-and between this AbstractPredicate's eval(Object) and other

Specified by:
and in interface Predicate<A>
Parameters:
other - another Evaluable. Non null.
Returns:
A new predicate that performs the short circuited logical-and between this and other when evaluated. Non Null

andNotNull

public final Predicate<A> andNotNull()
Specified by:
andNotNull in interface Predicate<A>

orNull

public final Predicate<A> orNull()
Specified by:
orNull in interface Predicate<A>

of

public <B> Predicate<B> of(@NonNull
                           Applicable<? super B,? extends A> other)
Specified by:
of in interface Predicate<A>

withEffectOnFalse

public Predicate<A> withEffectOnFalse(Executable<A> executable)
Specified by:
withEffectOnFalse in interface Predicate<A>

withEffectOnTrue

public Predicate<A> withEffectOnTrue(Executable<A> executable)
Specified by:
withEffectOnTrue in interface Predicate<A>

toString

public String toString()
Overrides:
toString in class Object


Get Staccatocommons at SourceForge.net. Fast, secure and Free Open Source software downloads