net.sf.jga.fn.adaptor
Class ComposeBinaryNth<R>

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

public class ComposeBinaryNth<R>
extends Functor<R>

Functor that uses a Generator to produce the Nth argument to a given Functor. The generated result is inserted into the argument list given to this functor with the modified list being passed to the nested functor.

Copyright © 2009 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface ComposeBinaryNth.Visitor
          Interface for classes that may interpret a Generate2nd functor.
 
Constructor Summary
ComposeBinaryNth(Functor<R> fn, int idx, BinaryFunctor<?,?,?> bf)
           
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(Generate2nd) method, if it implements the nested Visitor interface.
 R eval(java.lang.Object... args)
          Returns the results of the functor, using the nested generator to produce the Nth argument.
 BinaryFunctor<?,?,?> getBinaryFunctor()
          Returns the generator that produces the indicated argument.
 Functor<R> getFunctor()
          Returns the Functor that is invoked
 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

ComposeBinaryNth

public ComposeBinaryNth(Functor<R> fn,
                        int idx,
                        BinaryFunctor<?,?,?> bf)
Method Detail

getFunctor

public Functor<R> getFunctor()
Returns the Functor that is invoked


getBinaryFunctor

public BinaryFunctor<?,?,?> getBinaryFunctor()
Returns the generator that produces the indicated argument.


eval

public R eval(java.lang.Object... args)
Returns the results of the functor, using the nested generator to produce the Nth argument. If there are fewer than N+1 arguments, no modification will be attempted.

Specified by:
eval in class Functor<R>
Returns:
fn.eval(args[0], ..., args[N-1], bf(args[N], args[N+1]), args[N+2], ...)

accept

public void accept(Visitor v)
Calls the Visitor's visit(Generate2nd) 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.