|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnet.sf.sasl.common.helper.ReflectionHelper
public class ReflectionHelper
The class defines some helper methods for reflection operations.
Actually all of them could have been defined in a static way. Because of the
impossibility to mock static method calls without changing the byte code or
do some jar-hell tricks, non of them is defined static.
| Constructor Summary | |
|---|---|
ReflectionHelper()
|
|
| Method Summary | ||
|---|---|---|
List<Class<?>> |
getAllSuperClasses(Class<?> clazz)
Returns a list of all super classes of the over given class. |
|
Class<?> |
getClassByName(String className)
Tries to find the class object to the corresponding class name. |
|
List<Field> |
getCompletePropertyList(Class<?> clazz)
Returns a list of all declared properties of the class and its super classes (not including Object). |
|
Method |
getPropertyGetterMethod(Class<?> clazz,
String propertyName)
Returns the bean getter method for the property or null, if there exists no such. |
|
Object |
getPropertyOverMethodOrField(Object targetObject,
String propertyName)
Tries to fetch the value of the property. |
|
Object |
getPropertyViaPath(Object targetObject,
String path)
Resolves the value of a property by a property path and returns the resolved value. |
|
boolean |
hasProperty(Class<?> clazz,
String propertyName)
Checks if there is a field or setter for the given propertyName defined in the class. |
|
|
instantiateObject(Class<T> clazz)
Tries to instantiate a new object of the given class via the no argument constructor. |
|
boolean |
setPropertyOverMethodOrField(Object targetObject,
String propertyName,
Object value)
Tries to set the given property with the given value on the given targetObject. |
|
String |
toBeanSetterMethodName(String propertyName)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ReflectionHelper()
| Method Detail |
|---|
public Class<?> getClassByName(String className)
className - null or non null
public List<Class<?>> getAllSuperClasses(Class<?> clazz)
clazz - null or non null
public boolean setPropertyOverMethodOrField(Object targetObject,
String propertyName,
Object value)
targetObject - non nullpropertyName - non null, non emptyvalue - null or non null
public boolean hasProperty(Class<?> clazz,
String propertyName)
clazz - null or non nullpropertyName - null or non null
public <T> T instantiateObject(Class<T> clazz)
clazz - null or non null
public String toBeanSetterMethodName(String propertyName)
throws IllegalArgumentException
propertyName -
IllegalArgumentException
public List<Field> getCompletePropertyList(Class<?> clazz)
throws IllegalArgumentException
clazz - non null.
IllegalArgumentException - if parameter clazz is null.
public Method getPropertyGetterMethod(Class<?> clazz,
String propertyName)
throws IllegalArgumentException
clazz - non null.propertyName - non null
IllegalArgumentException - if clazz is null or propertyName does not have text.
public Object getPropertyOverMethodOrField(Object targetObject,
String propertyName)
throws IntrospectionException,
IllegalArgumentException
targetObject - non null.propertyName - non null.
IntrospectionException - if the value of the property could not be fetched, because
there exists no bean getter method for the property or the
property does not exists.
IllegalArgumentException - if targetObject is null or propertyName does not have text.
public Object getPropertyViaPath(Object targetObject,
String path)
throws ReflectionException,
NotResolveableException
targetObject - null or non null.path - non null.
ReflectionException - if any reflection operation exception occurs,
for example a property is not declared at a class.
NotResolveableException - if at some point of the path resolution a null value for a property occurs and
the path could not get resolved anymore as of missing meta informations.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||