net.sf.jga.fn.adaptor
Class ChainFunctor<F,R>

java.lang.Object
  extended by net.sf.jga.fn.Functor<R>
      extended by net.sf.jga.fn.adaptor.ChainFunctor<F,R>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class ChainFunctor<F,R>
extends Functor<R>

Functor that passes the results of a nested Functor as the argument to a UnaryFunctor.

Copyright © 2009 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface ChainFunctor.Visitor
          Interface for classes that may interpret a ChainBinary functor.
 
Constructor Summary
ChainFunctor(UnaryFunctor<F,R> f, Functor<F> g)
          Builds a ChainBinary functor, given outer functor f and inner functor g.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(ChainBinary) method, if it implements the nested Visitor interface.
 R eval(java.lang.Object... args)
          Passes arguments x and y to the inner functor, and passes the result to the outer functor.
 Functor<F> getInnerFunctor()
          Returns the inner functor
 UnaryFunctor<F,R> getOuterFunctor()
          Returns the outer functor
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.Functor
bind0th, bindNth, composeNth, composeNth, generateNth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ChainFunctor

public ChainFunctor(UnaryFunctor<F,R> f,
                    Functor<F> g)
Builds a ChainBinary functor, given outer functor f and inner functor g.

Throws:
java.lang.IllegalArgumentException - if any of the functors is missing
Method Detail

getOuterFunctor

public UnaryFunctor<F,R> getOuterFunctor()
Returns the outer functor

Returns:
the outer functor

getInnerFunctor

public Functor<F> getInnerFunctor()
Returns the inner functor

Returns:
the inner functor

eval

public R eval(java.lang.Object... args)
Passes arguments x and y to the inner functor, and passes the result to the outer functor.

Specified by:
eval in class Functor<R>
Returns:
f(g(args))

accept

public void accept(Visitor v)
Calls the Visitor's visit(ChainBinary) method, if it implements the nested Visitor interface.

Specified by:
accept in interface Visitable
Overrides:
accept in class Functor<R>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2006 David A. Hall. All Rights Reserved.