net.sf.jga.fn.adaptor

Class ComposeBinary<T1,T2,F1,F2,R>

public class ComposeBinary<T1,T2,F1,F2,R> extends AbstractBinaryFunctor<T1,T2,R> implements Serializable

Binary Functor that passes the results of two inner Binary Functors as the arguments to an outer Binary 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
interfaceComposeBinary.Visitor
Interface for classes that may interpret a ComposeBinary functor.
Constructor Summary
ComposeBinary(BinaryFunctor<T1,T2,F1> f, BinaryFunctor<T1,T2,F2> g, BinaryFunctor<F1,F2,R> h)
Builds a ComposeBinary functor, given two inner functors f and g, and outer functor h.
Method Summary
voidaccept(Visitor v)
Calls the Visitor's visit(ComposeBinary) method, if it implements the nested Visitor interface.
Rfn(T1 x, T2 y)
Given argument x, passes x to both inner functors, and passes the results of those functors to the outer functor.
BinaryFunctor<T1,T2,F1>getFirstInner()
Returns the first of two inner functors
BinaryFunctor<F1,F2,R>getOuter()
Returns the outer functor
BinaryFunctor<T1,T2,F2>getSecondInner()
Returns the second of two inner functors
StringtoString()

Constructor Detail

ComposeBinary

public ComposeBinary(BinaryFunctor<T1,T2,F1> f, BinaryFunctor<T1,T2,F2> g, BinaryFunctor<F1,F2,R> h)
Builds a ComposeBinary functor, given two inner functors f and g, and outer functor h.

Throws: IllegalArgumentException if any of the functors is missing

Method Detail

accept

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

fn

public R fn(T1 x, T2 y)
Given argument x, passes x to both inner functors, and passes the results of those functors to the outer functor.

Returns: h(f(x,y), g(x,y))

getFirstInner

public BinaryFunctor<T1,T2,F1> getFirstInner()
Returns the first of two inner functors

Returns: the first of two inner functors

getOuter

public BinaryFunctor<F1,F2,R> getOuter()
Returns the outer functor

Returns: the outer functor

getSecondInner

public BinaryFunctor<T1,T2,F2> getSecondInner()
Returns the second of two inner functors

Returns: the second of two inner functors

toString

public String toString()