com.scooterframework.common.util
Class BeanUtil

java.lang.Object
  extended by com.scooterframework.common.util.BeanUtil

public class BeanUtil
extends java.lang.Object

BeanUtil class has helper methods on beans.


Constructor Summary
BeanUtil()
           
 
Method Summary
static java.lang.Object execute(java.lang.Object instance, java.lang.String methodName, java.lang.Object[] args)
          Executes a method of a bean instance.
static java.lang.Object getBeanProperty(java.lang.Object bean, java.lang.String property)
          Gets property of a bean for a property.
static java.lang.reflect.Method getMethod(java.lang.Class<?> clz, java.lang.String methodName)
          Returns method of an object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BeanUtil

public BeanUtil()
Method Detail

getMethod

public static java.lang.reflect.Method getMethod(java.lang.Class<?> clz,
                                                 java.lang.String methodName)
Returns method of an object.

Parameters:
clz - the class type
methodName - the method name of the object
Returns:
the method object
Throws:
MethodCreationException - if bean or method is null

execute

public static java.lang.Object execute(java.lang.Object instance,
                                       java.lang.String methodName,
                                       java.lang.Object[] args)
Executes a method of a bean instance.

Parameters:
instance - the bean instance
methodName - the method to be executed
args - input parameters for the method
Returns:
return value of the method

getBeanProperty

public static java.lang.Object getBeanProperty(java.lang.Object bean,
                                               java.lang.String property)

Gets property of a bean for a property.

 Examples:
     getBeanProperty(pet, "name") -> pet.getName()
     getBeanProperty(pet, "owner.first_name") -> pet.getOwner().getFirstName()
 

Parameters:
bean - the bean instance
property - the property name
Returns:
value of the property