net.sf.jga.fn.adaptor
Class Bind1st<T1,T2,R>

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

public class Bind1st<T1,T2,R>
extends UnaryFunctor<T2,R>

UnaryFunctor that wraps a given BinaryFunctor, passing a constant value as the first argument of the child functor. The runtime argument is passed as the second argument of the child functor.

Copyright © 2003-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface Bind1st.Visitor
          Interface for classes that may interpret an Bind1st functor.
 
Constructor Summary
Bind1st(T1 constant, BinaryFunctor<T1,T2,R> fn)
          Builds a Bind1st Functor with the given contant and child functor.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(Bind1st) method, if it implements the nested Visitor interface.
 R fn(T2 x)
          Given one argument, passes the constant value and the argument to the child functor and returns the result.
 T1 getConstant()
          Returns the constant value
 BinaryFunctor<T1,T2,R> getFunctor()
          Returns the child functor for this functor
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.UnaryFunctor
bind, bind0th, bindNth, compose, compose, compose, composeNth, composeNth, eval, generate, generateNth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Bind1st

public Bind1st(T1 constant,
               BinaryFunctor<T1,T2,R> fn)
Builds a Bind1st Functor with the given contant and child functor.

Throws:
java.lang.IllegalArgumentException - if the functor is null.
Method Detail

getFunctor

public BinaryFunctor<T1,T2,R> getFunctor()
Returns the child functor for this functor

Returns:
the child functor for this functor

getConstant

public T1 getConstant()
Returns the constant value

Returns:
the constant value

fn

public R fn(T2 x)
Given one argument, passes the constant value and the argument to the child functor and returns the result.

Specified by:
fn in class UnaryFunctor<T2,R>
Returns:
f(c,x)

accept

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