ahc.generic
Interface AttributeGetter


public interface AttributeGetter

This interface serves to retrieve attributes from an object by successively calling get methods. The methods that are to be called are encoded in the "accessPath" parameter.

For example,

 attributeGetter.get (person, "address/city/name")
 
is equivalent to
 person.getAddress().getCity().getName()
 
This sort of programming should be avoided when possible because it prevents compile time checks for consistency and is slower than directly calling the attributes. It is however sometimes helpful when writing generic code that should handle different situations and not know about the details of concrete business classes, e.g. in a framework.

Note that such an approach can only work if all get methods that are called on the way are public, otherwise the generic code doing the lookup will not be able to "see" them and an exception will result.

Several implementations of this interface are available; see AttributeGetterFactory for details.

Author:
Arno Haase

Field Summary
static java.lang.String CHAR_SEPARATOR
           
 
Method Summary
 java.lang.Object get(java.lang.Object obj, java.lang.String accessPath)
           
 

Field Detail

CHAR_SEPARATOR

public static final java.lang.String CHAR_SEPARATOR
See Also:
Constant Field Values
Method Detail

get

public java.lang.Object get(java.lang.Object obj,
                            java.lang.String accessPath)