net.sf.jga.fn.property

Class GetProperty<T,R>

public class GetProperty<T,R> extends AbstractUnaryFunctor<T,R> implements Serializable

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

Note that declaring the return type incorrectly can result in ClassCastExceptions being thrown when the functor is invoked: the compiler cannot check the return type of a reflectively loaded method.

Copyright © 2002 David A. Hall

Author: David A. Hall

Nested Class Summary
interfaceGetProperty.Visitor
Interface for classes that may interpret a GetProperty function.
Constructor Summary
GetProperty(String propName)
Builds a GetProperty for the given property.
Method Summary
voidaccept(Visitor v)
Calls the Visitor's visit(GetProperty) method, if it implements the nested Visitor interface.
Rfn(T arg)
Returns the value of the designated property of the argument
StringtoString()

Constructor Detail

GetProperty

public GetProperty(String propName)
Builds a GetProperty for the given property.

Throws: IllegalArgumentException if the property name is null or empty

Method Detail

accept

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

fn

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

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.

toString

public String toString()