net.sf.jga.fn.adaptor

Class ChainUnary<T,F,R>

public class ChainUnary<T,F,R> extends AbstractUnaryFunctor<T,R> implements Serializable

Unary Functor that passes the results of one Unary Functor as the argument to another Unary Functor. This allows for the construction of compound functors from the primitives found in the arithmetic, logical, property, and comparison packages.

Copyright © 2002 David A. Hall

Author: David A. Hall

Nested Class Summary
interfaceChainUnary.Visitor
Interface for classes that may interpret a ChainUnary functor.
Constructor Summary
ChainUnary(UnaryFunctor<F,R> f, UnaryFunctor<T,F> g)
Builds a BinaryCompose functor, given the outer functor f the inner functor g.
Method Summary
voidaccept(Visitor v)
Calls the Visitor's visit(BinaryCompose) method, if it implements the nested Visitor interface.
Rfn(T x)
Given argument x, passes x to the inner functor, and passes the result to the outer functor.
UnaryFunctor<T,F>getInnerFn()
Returns the inner functor
UnaryFunctor<F,R>getOuterFn()
Returns the outer functor
StringtoString()

Constructor Detail

ChainUnary

public ChainUnary(UnaryFunctor<F,R> f, UnaryFunctor<T,F> g)
Builds a BinaryCompose functor, given the outer functor f the inner functor g.

Throws: IllegalArgumentException if any of the functors is missing

Method Detail

accept

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

fn

public R fn(T x)
Given argument x, passes x to the inner functor, and passes the result to the outer functor.

Returns: f(g(x))

getInnerFn

public UnaryFunctor<T,F> getInnerFn()
Returns the inner functor

Returns: the inner functor

getOuterFn

public UnaryFunctor<F,R> getOuterFn()
Returns the outer functor

Returns: the outer functor

toString

public String toString()