net.sf.jga.fn.adaptor
Class Bind<T,R>

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

public class Bind<T,R>
extends Generator<R>

Generator that wraps a given UnaryFunctor, passing a constant value as the argument of the child functor.

Copyright © 2004-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface Bind.Visitor
          Interface for classes that may interpret an Bind functor.
 
Constructor Summary
Bind(T constant, UnaryFunctor<T,R> fn)
          Builds a Bind Functor with the given constant and child functor.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(Bind) method, if it implements the nested Visitor interface.
 R fn()
          Given one argument, passes the constant value and the argument to the child functor and returns the result.
 T getConstant()
          Returns the constant value
 UnaryFunctor<T,R> getFunctor()
          Returns the child functor for this functor
 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

Bind

public Bind(T constant,
            UnaryFunctor<T,R> fn)
Builds a Bind Functor with the given constant and child functor.

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

getFunctor

public UnaryFunctor<T,R> getFunctor()
Returns the child functor for this functor

Returns:
the child functor for this functor

getConstant

public T getConstant()
Returns the constant value

Returns:
the constant value

fn

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

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

accept

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