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:
net.sf.staccatocommons.defs.Applicable<A,Boolean>, net.sf.staccatocommons.defs.Evaluable<A>, net.sf.staccatocommons.defs.predicate.Predicate<A>
Direct Known Subclasses:
AbstractPredicate.Soft, TopLevelPredicate

public abstract class AbstractPredicate<A>
extends Object
implements net.sf.staccatocommons.defs.predicate.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
 net.sf.staccatocommons.defs.predicate.Predicate<A> and(net.sf.staccatocommons.defs.Evaluable<? super A> other)
          Returns a predicate that performs a short-circuit logical-and between this AbstractPredicate's eval(Object) and other
 net.sf.staccatocommons.defs.predicate.Predicate<A> andNotNull()
           
 Boolean apply(A arg)
           
abstract  boolean eval(A argument)
           
 net.sf.staccatocommons.defs.predicate.Predicate<A> not()
           
<B> net.sf.staccatocommons.defs.predicate.Predicate<B>
of(net.sf.staccatocommons.defs.Applicable<? super B,? extends A> other)
           
 net.sf.staccatocommons.defs.predicate.Predicate<A> or(net.sf.staccatocommons.defs.Evaluable<? super A> other)
          Returns a predicate that, performs a short-circuit logical-or between this AbstractPredicate's eval(Object) and other
 net.sf.staccatocommons.defs.predicate.Predicate<A> orNull()
           
 String toString()
           
 net.sf.staccatocommons.defs.predicate.Predicate<A> withEffectOnFalse(net.sf.staccatocommons.defs.Executable<A> executable)
           
 net.sf.staccatocommons.defs.predicate.Predicate<A> withEffectOnTrue(net.sf.staccatocommons.defs.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 net.sf.staccatocommons.defs.Evaluable<A>

apply

public Boolean apply(A arg)
Specified by:
apply in interface net.sf.staccatocommons.defs.Applicable<A,Boolean>

not

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

or

public net.sf.staccatocommons.defs.predicate.Predicate<A> or(@NonNull
                                                             net.sf.staccatocommons.defs.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 net.sf.staccatocommons.defs.predicate.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 net.sf.staccatocommons.defs.predicate.Predicate<A> and(@NonNull
                                                              net.sf.staccatocommons.defs.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 net.sf.staccatocommons.defs.predicate.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 net.sf.staccatocommons.defs.predicate.Predicate<A> andNotNull()
Specified by:
andNotNull in interface net.sf.staccatocommons.defs.predicate.Predicate<A>

orNull

public final net.sf.staccatocommons.defs.predicate.Predicate<A> orNull()
Specified by:
orNull in interface net.sf.staccatocommons.defs.predicate.Predicate<A>

of

public <B> net.sf.staccatocommons.defs.predicate.Predicate<B> of(@NonNull
                                                                 net.sf.staccatocommons.defs.Applicable<? super B,? extends A> other)
Specified by:
of in interface net.sf.staccatocommons.defs.predicate.Predicate<A>

withEffectOnFalse

public net.sf.staccatocommons.defs.predicate.Predicate<A> withEffectOnFalse(net.sf.staccatocommons.defs.Executable<A> executable)
Specified by:
withEffectOnFalse in interface net.sf.staccatocommons.defs.predicate.Predicate<A>

withEffectOnTrue

public net.sf.staccatocommons.defs.predicate.Predicate<A> withEffectOnTrue(net.sf.staccatocommons.defs.Executable<A> executable)
Specified by:
withEffectOnTrue in interface net.sf.staccatocommons.defs.predicate.Predicate<A>

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2010-2012 Staccatocommons. All Rights Reserved.