|
|||||||||
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.Generator<R> net.sf.jga.fn.adaptor.ConditionalGenerator<R>
public class ConditionalGenerator<R>
Generator that tests a condition, executes one of two given functors, and
returns the result. The argument 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 |
ConditionalGenerator.Visitor
Interface for classes that may interpret a ConditionalGenerator functor. |
Constructor Summary | |
---|---|
ConditionalGenerator(Generator<java.lang.Boolean> test,
Generator<R> trueFn,
Generator<R> falseFn)
Builds a ConditionalGenerator 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(ConditionalGenerator) method, if it
implements the nested Visitor interface. |
R |
fn()
Given argument x, evaluates test(x); if true, returns trueFn(x), otherwise, returns falseFn(x). |
Generator<java.lang.Boolean> |
getCondition()
Returns the test functors |
Generator<R> |
getFalseFunctor()
Returns the functor that is executed when the condition is false |
Generator<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.Generator |
---|
bind0th, bindNth, eval |
Methods inherited from class net.sf.jga.fn.Functor |
---|
composeNth, composeNth, generateNth |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ConditionalGenerator(Generator<java.lang.Boolean> test, Generator<R> trueFn, Generator<R> falseFn)
java.lang.IllegalArgumentException
- if any of the functors is missingMethod Detail |
---|
public Generator<java.lang.Boolean> getCondition()
public Generator<R> getTrueFunctor()
public Generator<R> getFalseFunctor()
public R fn()
fn
in class Generator<R>
public void accept(Visitor v)
visit(ConditionalGenerator)
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 |