net.sf.jga.fn.adaptor
Class Identity<T>

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

public class Identity<T>
extends UnaryFunctor<T,T>

Unary Functor that returns the runtime argument.

Copyright © 2002-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static class Identity.Accessor<T>
          A Generator that returns the last value passed to an associated Identity.
static interface Identity.AccessorVisitor
          Interface for classes that may interpret an Identity.Accessor.
static interface Identity.Visitor
          Interface for classes that may interpret an Identity functor.
 
Constructor Summary
Identity()
           
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(Identity) method, if it implements the nested Visitor interface.
 Generator<T> accessor()
          Returns a Generator that will always return the last value passed to this functor.
 T arg()
          Returns the last argument that was given, or null if called prior to the first call to fn().
 T fn(T x)
          Given one argument, returns it.
 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

Identity

public Identity()
Method Detail

arg

public T arg()
Returns the last argument that was given, or null if called prior to the first call to fn(). This value does not persist when the functor is serialized.

Returns:
the last argument that was given or null.

accessor

public Generator<T> accessor()
Returns a Generator that will always return the last value passed to this functor.


fn

public T fn(T x)
Given one argument, returns it.

Specified by:
fn in class UnaryFunctor<T,T>
Returns:
x

accept

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

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

toString

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


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