Package org.hibernate.testing.util
Class ReflectionUtil
java.lang.Object
org.hibernate.testing.util.ReflectionUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Field
Get a field from a given classstatic <T> T
getFieldValue
(Object target, String name) Get a field value from a given objectstatic Method
Get target methodstatic Method
Get setter methodstatic <T> T
newInstance
(String className) New target Object instance using the given Class namestatic <T> T
newInstance
(Supplier<Constructor<T>> constructorSupplier, Object... args) New target Object instance using the given argumentsstatic void
Set target Object field to a certain valuestatic void
Set target Object field to a certain valuestatic void
setProperty
(Object target, String property, Object parameter) Invoke setter method with the given parameterstatic void
setStaticField
(Class<?> target, String fieldName, Object value) Set target Class field to a certain value
-
Constructor Details
-
ReflectionUtil
public ReflectionUtil()
-
-
Method Details
-
getField
Get a field from a given class- Parameters:
clazz
- clazzname
- field name- Returns:
- field object
-
getFieldValue
Get a field value from a given object- Parameters:
target
- Object whose field is being readname
- field name- Returns:
- field object
-
setField
Set target Object field to a certain value- Parameters:
target
- Object whose field is being setfield
- Object field to setvalue
- the new value for the given field
-
setField
Set target Object field to a certain value- Parameters:
target
- Object whose field is being setfieldName
- Object field naem to setvalue
- the new value for the given field
-
setStaticField
Set target Class field to a certain value- Parameters:
target
- Class whose field is being setfieldName
- Class field name to setvalue
- the new value for the given field
-
newInstance
New target Object instance using the given arguments- Parameters:
constructorSupplier
- constructor supplierargs
- Constructor arguments- Returns:
- new Object instance
-
newInstance
New target Object instance using the given Class name- Parameters:
className
- class name- Returns:
- new Object instance
-
getSetter
Get setter method- Parameters:
target
- target objectproperty
- propertyparameterType
- setter parameter type- Returns:
- setter method
-
getMethod
Get target method- Parameters:
target
- target objectmethodName
- method nameparameterTypes
- method parameter types- Returns:
- return value
-
setProperty
Invoke setter method with the given parameter- Parameters:
target
- target objectproperty
- propertyparameter
- setter parameter
-