net.sf.jga.fn.adaptor
Class ConstantUnary<T,V>

java.lang.Object
  extended by net.sf.jga.fn.Functor<R>
      extended by net.sf.jga.fn.UnaryFunctor<T,V>
          extended by net.sf.jga.fn.adaptor.ConstantUnary<T,V>
All Implemented Interfaces:
java.io.Serializable, Visitable

public class ConstantUnary<T,V>
extends UnaryFunctor<T,V>

Functor that returns the constant value given at construction.

To Serialize a ConstantUnary, the generic parameter V must be serializable.

Copyright © 2003-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface ConstantUnary.Visitor
          Interface for classes that may interpret a ConstantUnary functor.
 
Constructor Summary
ConstantUnary(V val)
          Builds a Constant functor for the given value.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(ConstantUnary) method, if it implements the nested Visitor interface.
 V fn(T unused)
          Given one argument, summarily ignores it and returns the constant value given at construction.
 java.lang.String toString()
           
 
Methods inherited from class net.sf.jga.fn.UnaryFunctor
bind, bind0th, bindNth, compose, compose, compose, composeNth, composeNth, eval, generate, generateNth
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstantUnary

public ConstantUnary(V val)
Builds a Constant functor for the given value. The value may be null: in that case, evaluating the functor will return null.

Method Detail

fn

public V fn(T unused)
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.

Specified by:
fn in class UnaryFunctor<T,V>
Returns:
the constant value given at construction

accept

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

Specified by:
accept in interface Visitable
Overrides:
accept in class Functor<V>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object


Copyright © 2002-2006 David A. Hall. All Rights Reserved.