com.anasoft.os.daofusion.util
Class ReflectionHelper

java.lang.Object
  extended by com.anasoft.os.daofusion.util.ReflectionHelper

public final class ReflectionHelper
extends java.lang.Object

Helper class for common reflection operations.

Author:
vojtech.szocs

Method Summary
static java.lang.Object invokeGetterMethod(java.lang.Object object, java.lang.String propertyName)
          Tries to invoke a getter method for the given propertyName on the provided object.
static java.lang.Object resolvePropertyPath(java.lang.Object object, java.lang.String propertyPath)
          Tries to resolve the given dot-separated propertyPath on the provided object by traversing its properties.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

invokeGetterMethod

public static java.lang.Object invokeGetterMethod(java.lang.Object object,
                                                  java.lang.String propertyName)
Tries to invoke a getter method for the given propertyName on the provided object.

Note that the getter method should meet the following requirements:

Parameters:
object - Object on which to invoke the getter method.
propertyName - Name of the property containing the requested value.
Returns:
Getter method invocation result.

resolvePropertyPath

public static java.lang.Object resolvePropertyPath(java.lang.Object object,
                                                   java.lang.String propertyPath)
Tries to resolve the given dot-separated propertyPath on the provided object by traversing its properties.

This is a convenient way of accessing nested properties of a root object programatically.

Note that the method is null-friendly - it won't throw a NullPointerException during the object traversal (a null value is returned instead).

Parameters:
object - Object on which to resolve the property path.
propertyPath - Dot-separated logical path to the target property.
Returns:
Property resolution result.


Copyright © 2008-2009 ANASOFT and contributors. All Rights Reserved.