|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.jga.fn.Functor<R> net.sf.jga.fn.BinaryFunctor<T1,T2,R> net.sf.jga.fn.adaptor.ConditionalBinary<T1,T2,R>
public class ConditionalBinary<T1,T2,R>
BinaryFunctor that tests a condition, executes one of two given functors, and
returns the result. The arguments used to evaluate the condition will also
be passed to whichever functor is executed. This functor implements the
traditional ?:
operator.
Copyright © 2003-2005 David A. Hall
Nested Class Summary | |
---|---|
static interface |
ConditionalBinary.Visitor
Interface for classes that may interpret a ConditionalBinary functor. |
Constructor Summary | |
---|---|
ConditionalBinary(BinaryFunctor<T1,T2,java.lang.Boolean> test,
BinaryFunctor<T1,T2,R> trueFn,
BinaryFunctor<T1,T2,R> falseFn)
Builds a ConditionalBinary functor, given the condition to test, and the two functors that may be executed. |
Method Summary | |
---|---|
void |
accept(Visitor v)
Calls the Visitor's visit(ConditionalBinary) method, if it
implements the nested Visitor interface. |
R |
fn(T1 x,
T2 y)
Given arguments x and x evaluates test(x,y); if true, returns trueFn(x,y), otherwise, returns falseFn(x,y). |
BinaryFunctor<T1,T2,java.lang.Boolean> |
getCondition()
Returns the test functors |
BinaryFunctor<T1,T2,R> |
getFalseFunctor()
Returns the functor that is executed when the condition is false |
BinaryFunctor<T1,T2,R> |
getTrueFunctor()
Returns the functor that is executed when the condition is true |
java.lang.String |
toString()
|
Methods inherited from class net.sf.jga.fn.BinaryFunctor |
---|
bind, bind0th, bind1st, bind2nd, bindNth, compose, compose, composeNth, distribute, eval, generate, generate1st, generate2nd, generateNth |
Methods inherited from class net.sf.jga.fn.Functor |
---|
composeNth |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConditionalBinary(BinaryFunctor<T1,T2,java.lang.Boolean> test, BinaryFunctor<T1,T2,R> trueFn, BinaryFunctor<T1,T2,R> falseFn)
java.lang.IllegalArgumentException
- if any of the functors is missingMethod Detail |
---|
public BinaryFunctor<T1,T2,java.lang.Boolean> getCondition()
public BinaryFunctor<T1,T2,R> getTrueFunctor()
public BinaryFunctor<T1,T2,R> getFalseFunctor()
public R fn(T1 x, T2 y)
fn
in class BinaryFunctor<T1,T2,R>
public void accept(Visitor v)
visit(ConditionalBinary)
method, if it
implements the nested Visitor interface.
accept
in interface Visitable
accept
in class Functor<R>
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |