net.sf.jga.fn.adaptor

Class Bind1st<T1,T2,R>

public class Bind1st<T1,T2,R> extends AbstractUnaryFunctor<T2,R> implements Serializable

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 David A. Hall

Author: David A. Hall

Nested Class Summary
interfaceBind1st.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
voidaccept(Visitor v)
Calls the Visitor's visit(Bind1st) method, if it implements the nested Visitor interface.
Rfn(T2 x)
Given one argument, passes the constant value and the argument to the child functor and returns the result.
T1getConstant()
Returns the constant value
BinaryFunctor<T1,T2,R>getFunction()
Returns the child functor for this functor
StringtoString()

Constructor Detail

Bind1st

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

Throws: IllegalArgumentException if the functor is null.

Method Detail

accept

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

fn

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

Returns: f(c,x)

getConstant

public T1 getConstant()
Returns the constant value

Returns: the constant value

getFunction

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

Returns: the child functor for this functor

toString

public String toString()