|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jpaul.Misc.ActionPredicate<T>
public abstract class ActionPredicate<T>
ActionPredicate
is a combination of an
Action
and a Predicate
. Intuitively, one
may say that ActionPredicate
is an impure predicate,
but one should be aware of the fact that
ActionPredicate
and Predicate
are not iin
any subclassing relationship (in general, it is a bad software
engineering practice to have subclassing between pure and impure
varieties of the same concept). Still, we provide a static method
(fromPredicate(jpaul.Misc.Predicate
) that converts a Predicate
into an ActionPredicate
.
Action
,
Predicate
Constructor Summary | |
---|---|
ActionPredicate()
|
Method Summary | ||
---|---|---|
void |
action(T obj)
Action: executes actionPredicate(T) only for its
side-effects, ignoring its result. |
|
abstract boolean |
actionPredicate(T obj)
A boolean predicate WITH possible side-effects. |
|
static
|
fromAction(Action<T> action,
boolean predicateResult)
Creates an ActionPredicate whose
actionPredicate method first invokes the action
from action and next returns the constant boolean
value predicateResult . |
|
static
|
fromPredicate(Predicate<T> predicate)
Creates an ActionPredicate wrapper around a
Predicate : it does not perform any side-effect,
it just returns the boolean value of teh predicate. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ActionPredicate()
Method Detail |
---|
public abstract boolean actionPredicate(T obj)
public final void action(T obj)
actionPredicate(T)
only for its
side-effects, ignoring its result.
action
in interface Action<T>
public static <T> ActionPredicate<T> fromAction(Action<T> action, boolean predicateResult)
ActionPredicate
whose
actionPredicate
method first invokes the action
from action
and next returns the constant boolean
value predicateResult
.
public static <T> ActionPredicate<T> fromPredicate(Predicate<T> predicate)
ActionPredicate
wrapper around a
Predicate
: it does not perform any side-effect,
it just returns the boolean value of teh predicate.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |