net.sf.jga.fn.property
Class GetProperty<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.GetProperty<T,R>
All Implemented Interfaces:
java.io.Serializable, Visitable

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

Unary Functor that returns the value of the named property for the argument. The property name and type are set at construction.

Copyright © 2002-2005 David A. Hall

Author:
David A. Hall
See Also:
Serialized Form

Nested Class Summary
static interface GetProperty.Visitor
          Interface for classes that may interpret a GetProperty function.
 
Constructor Summary
GetProperty(java.lang.Class<T> argclass, java.lang.String propName)
          Builds a GetProperty for the given property, using the given class to find the desired method.
 
Method Summary
 void accept(Visitor v)
          Calls the Visitor's visit(GetProperty) method, if it implements the nested Visitor interface.
 R fn(T arg)
          Returns the value of the designated property of the argument
 java.lang.String getPropertyName()
          Returns the name of the property that this functor retrieves.
 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

GetProperty

public GetProperty(java.lang.Class<T> argclass,
                   java.lang.String propName)
Builds a GetProperty for the given property, using the given class to find the desired method.

Throws:
java.lang.IllegalArgumentException - if the property name is null or empty, or if there is no getter method for the given property name.
Method Detail

getPropertyName

public java.lang.String getPropertyName()
Returns the name of the property that this functor retrieves.


fn

public R fn(T arg)
Returns the value of the designated property of the argument

Specified by:
fn in class UnaryFunctor<T,R>
Returns:
the value of the designated property of the argument
Throws:
EvaluationException - if the argument does not have the designated public property, or if it is not of the correct type.

accept

public void accept(Visitor v)
Calls the Visitor's visit(GetProperty) 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.