Package org.apache.openjpa.enhance
Class Reflection
java.lang.Object
org.apache.openjpa.enhance.Reflection
Reflection utilities used to support and augment enhancement. Used both
at enhancement time and at runtime.
- Author:
- Abe White
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FieldReturn the field with the given name, optionally throwing an exception if none.static MethodfindGetter(Class cls, String prop, boolean mustExist) Return the getter method matching the given property name, optionally throwing an exception if none.static MethodfindSetter(Class cls, String prop, boolean mustExist) Return the setter method matching the given property name, optionally throwing an exception if none.static MethodfindSetter(Class cls, String prop, Class param, boolean mustExist) Return the setter method matching the given property name, optionally throwing an exception if none.static ObjectReturn the value of the given field in the given object.static ObjectReturn the return value of the given getter in the given object.Gets all bean-style property names of the given Class or its superclass.static booleangetBoolean(Object target, Field field) Return the value of the given field in the given object.static booleangetBoolean(Object target, Method getter) Return the return value of the given getter in the given object.static byteReturn the value of the given field in the given object.static byteReturn the return value of the given getter in the given object.static charReturn the value of the given field in the given object.static charReturn the return value of the given getter in the given object.static ClassGets the declaring class of the given method signature but also checks if the method is declared in an interface.static MethodgetDeclaringMethod(Class c, Method m) Gets the method in the given class that has the same signature of the given method, if exists.static doubleReturn the value of the given field in the given object.static doubleReturn the return value of the given getter in the given object.static <T> Set<T>getFieldValues(Class c, int mods, Class<T> t) Gets values of all field f the given class such that f exactly match the given modifiers and are of given type (Object implies any type) unless f is annotated asReflectable.static floatReturn the value of the given field in the given object.static floatReturn the return value of the given getter in the given object.static intReturn the value of the given field in the given object.static intReturn the return value of the given getter in the given object.static longReturn the value of the given field in the given object.static longReturn the return value of the given getter in the given object.Gets all public field names of the given Class.static shortReturn the value of the given field in the given object.static shortReturn the return value of the given getter in the given object.static ObjectGet the value of the given named field or a corresponding getter method.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidSet the value of the given field in the given object.static voidInvoke the given setter on the given object.static voidInvoke the given setter on the given object.static voidInvoke the given setter on the given object.static voidInvoke the given setter on the given object.static voidInvoke the given setter on the given object.static voidInvoke the given setter on the given object.static voidInvoke the given setter on the given object.static voidInvoke the given setter on the given object.static voidInvoke the given setter on the given object.
-
Constructor Details
-
Reflection
public Reflection()
-
-
Method Details
-
findGetter
Return the getter method matching the given property name, optionally throwing an exception if none. -
findSetter
Return the setter method matching the given property name, optionally throwing an exception if none. The property must also have a getter. -
findSetter
Return the setter method matching the given property name, optionally throwing an exception if none. -
findField
Return the field with the given name, optionally throwing an exception if none. -
get
Return the value of the given field in the given object. -
getValue
Get the value of the given named field or a corresponding getter method.- Returns:
- null if the field does not exist and mustExist is set to false or the given target is null.
- Throws:
UserException- if mustExist is true and the field or getter method is non-existent
-
getBoolean
Return the value of the given field in the given object. -
getByte
Return the value of the given field in the given object. -
getChar
Return the value of the given field in the given object. -
getDouble
Return the value of the given field in the given object. -
getFloat
Return the value of the given field in the given object. -
getInt
Return the value of the given field in the given object. -
getLong
Return the value of the given field in the given object. -
getShort
Return the value of the given field in the given object. -
get
Return the return value of the given getter in the given object. -
getBoolean
Return the return value of the given getter in the given object. -
getByte
Return the return value of the given getter in the given object. -
getChar
Return the return value of the given getter in the given object. -
getDouble
Return the return value of the given getter in the given object. -
getFloat
Return the return value of the given getter in the given object. -
getInt
Return the return value of the given getter in the given object. -
getLong
Return the return value of the given getter in the given object. -
getShort
Return the return value of the given getter in the given object. -
set
Set the value of the given field in the given object. -
set
Set the value of the given field in the given object. -
set
Set the value of the given field in the given object. -
set
Set the value of the given field in the given object. -
set
Set the value of the given field in the given object. -
set
Set the value of the given field in the given object. -
set
Set the value of the given field in the given object. -
set
Set the value of the given field in the given object. -
set
Set the value of the given field in the given object. -
set
Set the value of the given field in the given object. Same behavior as above methods, but parameter ordering is rearranged to simplify usage from generated bytecodes.- Since:
- 1.0.0
-
set
Set the value of the given field in the given object. Same behavior as above methods, but parameter ordering is rearranged to simplify usage from generated bytecodes.- Since:
- 1.0.0
-
set
Set the value of the given field in the given object. Same behavior as above methods, but parameter ordering is rearranged to simplify usage from generated bytecodes.- Since:
- 1.0.0
-
set
Set the value of the given field in the given object. Same behavior as above methods, but parameter ordering is rearranged to simplify usage from generated bytecodes.- Since:
- 1.0.0
-
set
Set the value of the given field in the given object. Same behavior as above methods, but parameter ordering is rearranged to simplify usage from generated bytecodes.- Since:
- 1.0.0
-
set
Set the value of the given field in the given object. Same behavior as above methods, but parameter ordering is rearranged to simplify usage from generated bytecodes.- Since:
- 1.0.0
-
set
Set the value of the given field in the given object. Same behavior as above methods, but parameter ordering is rearranged to simplify usage from generated bytecodes.- Since:
- 1.0.0
-
set
Set the value of the given field in the given object. Same behavior as above methods, but parameter ordering is rearranged to simplify usage from generated bytecodes.- Since:
- 1.0.0
-
set
Set the value of the given field in the given object. Same behavior as above methods, but parameter ordering is rearranged to simplify usage from generated bytecodes.- Since:
- 1.0.0
-
set
Invoke the given setter on the given object. -
set
Invoke the given setter on the given object. -
set
Invoke the given setter on the given object. -
set
Invoke the given setter on the given object. -
set
Invoke the given setter on the given object. -
set
Invoke the given setter on the given object. -
set
Invoke the given setter on the given object. -
set
Invoke the given setter on the given object. -
set
Invoke the given setter on the given object. -
getBeanStylePropertyNames
Gets all bean-style property names of the given Class or its superclass. A bean-style property 'abc' exists in Class C iff C has declared following pair of methods: public void setAbc(Y y) or public C setAbc(Y y) public Y getAbc(); If a getter property is annotated withReflectable, then it is ignored. -
getPublicFieldNames
Gets all public field names of the given Class. -
getFieldValues
Gets values of all field f the given class such that f exactly match the given modifiers and are of given type (Object implies any type) unless f is annotated asReflectable. -
getDeclaringClass
Gets the declaring class of the given method signature but also checks if the method is declared in an interface. If yes, then returns the interface. -
getDeclaringMethod
Gets the method in the given class that has the same signature of the given method, if exists. Otherwise, null.
-