net.sf.jga.fn.adaptor

Class Bind2nd<T1,T2,R>

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

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

Copyright © 2003 David A. Hall

Author: David A. Hall

Nested Class Summary
interfaceBind2nd.Visitor
Interface for classes that may interpret an Bind2nd functor.
Constructor Summary
Bind2nd(T2 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(Bind2nd) method, if it implements the nested Visitor interface.
Rfn(T1 x)
Given one argument, passes the argument and the constant value to the child functor and returns the result.
T2getConstant()
Returns the constant value
BinaryFunctor<T1,T2,R>getFunction()
Returns the child functor for this functor
StringtoString()

Constructor Detail

Bind2nd

public Bind2nd(T2 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(Bind2nd) method, if it implements the nested Visitor interface.

fn

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

Returns: f(x,c)

getConstant

public T2 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()