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
-
Method Summary
Modifier and TypeMethodDescriptionstatic Field
Return the field with the given name, optionally throwing an exception if none.static Method
findGetter
(Class cls, String prop, boolean mustExist) Return the getter method matching the given property name, optionally throwing an exception if none.static Method
findSetter
(Class cls, String prop, boolean mustExist) Return the setter method matching the given property name, optionally throwing an exception if none.static Method
findSetter
(Class cls, String prop, Class param, boolean mustExist) Return the setter method matching the given property name, optionally throwing an exception if none.static Object
Return the value of the given field in the given object.static Object
Return 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 boolean
getBoolean
(Object target, Field field) Return the value of the given field in the given object.static boolean
getBoolean
(Object target, Method getter) Return the return value of the given getter in the given object.static byte
Return the value of the given field in the given object.static byte
Return the return value of the given getter in the given object.static char
Return the value of the given field in the given object.static char
Return the return value of the given getter in the given object.static Class
Gets the declaring class of the given method signature but also checks if the method is declared in an interface.static Method
getDeclaringMethod
(Class c, Method m) Gets the method in the given class that has the same signature of the given method, if exists.static double
Return the value of the given field in the given object.static double
Return 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 float
Return the value of the given field in the given object.static float
Return the return value of the given getter in the given object.static int
Return the value of the given field in the given object.static int
Return the return value of the given getter in the given object.static long
Return the value of the given field in the given object.static long
Return the return value of the given getter in the given object.Gets all public field names of the given Class.static short
Return the value of the given field in the given object.static short
Return the return value of the given getter in the given object.static Object
Get the value of the given named field or a corresponding getter method.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Set the value of the given field in the given object.static void
Invoke the given setter on the given object.static void
Invoke the given setter on the given object.static void
Invoke the given setter on the given object.static void
Invoke the given setter on the given object.static void
Invoke the given setter on the given object.static void
Invoke the given setter on the given object.static void
Invoke the given setter on the given object.static void
Invoke the given setter on the given object.static void
Invoke 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.
-