net.sf.jga.fn.adaptor
Class Constant<T,V>
public
class
Constant<T,V>
extends AbstractBinaryFunctor<T,T,V>
implements UnaryFunctor<T,V>, Serializable
Functor that returns the constant value given at construction. This functor
fulfills both the UnaryFunctor and BinaryFunctor interface.
Copyright © 2003 David A. Hall
Author: David A. Hall
Method Summary |
void | accept(Visitor v)
Calls the Visitor's visit(Constant) method, if it
implements the nested Visitor interface. |
<F> UnaryFunctor<F,V> | compose(UnaryFunctor<F,T> f)
Implements the FactoryMethod in the UnaryFunctor interface. |
<F1,F2> BinaryFunctor<F1,F2,V> | compose(BinaryFunctor<F1,F2,T> f)
Implements the FactoryMethod in the UnaryFunctor interface. |
V | fn(T unused)
Given one argument, summarily ignores it and returns the constant value
given at construction. |
V | fn(T unused, T ignored)
Given two arguments, ignores both and returns the constant value given
at construction. |
String | toString() |
Builds a Constant functor for the given value. The value may be null:
in that case, evaluating the functor will return null.
Calls the Visitor's visit(Constant)
method, if it
implements the nested Visitor interface.
Implements the FactoryMethod in the UnaryFunctor interface. The result
of the newly created functor will still be the same as this, but the
argument is passed to the inner function and evaluated: the result of
the inner function is ignored and the constant value of this functor is
returned to the caller. The contract demands that the inner functor
is actually evaluated (as it might have side effects that are
significant -- that would be the only reason to be composing a functor
whose outer function is a constant)
Implements the FactoryMethod in the UnaryFunctor interface. The result
of the newly created functor will still be the same as this, but the
arguments are passed to the inner function and evaluated: the result of
the inner function is ignored and the constant value of this functor is
returned to the caller. The contract demands that the inner functor
is actually evaluated (as it might have side effects that are
significant -- that would be the only reason to be composing a functor
whose outer function is a constant)
Given one argument, summarily ignores it and returns the constant value
given at construction. The argument will not be evaluated in any way by
this functor.
Returns: the constant value given at construction
public
V fn(
T unused,
T ignored)
Given two arguments, ignores both and returns the constant value given
at construction. Neither argument will be evaluated in any way by this
functor.
Returns: the constant value given at construction
public String toString()