net.sf.jga.fn.property
Class Cast<T,R>

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

public class Cast<T,R>
extends UnaryFunctor<T,R>

UnaryFunctor that returns its argument, cast to the given type. Executing the functor will throw ClassCastExceptions if the argument cannot be cast to the given type.

Copyright © 2004-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface Cast.Visitor
          Interface for classes that may interpret a Cast function.
 
Constructor Summary
Cast(java.lang.Class<R> cl)
          Builds a Cast fuctor that returns values cast to the given type.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(InstanceOf) method, if it implements the nested Visitor interface.
 R fn(T arg)
          Executes the function and returns the result.
 java.lang.Class<R> getCastClass()
           
 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

Cast

public Cast(java.lang.Class<R> cl)
Builds a Cast fuctor that returns values cast to the given type.

Throws:
java.lang.IllegalArgumentException - if the method name is null or empty, or if the argument type array is null.
Method Detail

getCastClass

public java.lang.Class<R> getCastClass()

fn

public R fn(T arg)
Description copied from class: UnaryFunctor
Executes the function and returns the result.

Specified by:
fn in class UnaryFunctor<T,R>

accept

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

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

toString

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


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