Class Reflections
java.lang.Object
io.github.cjstehno.testthings.util.Reflections
Some utility methods for working with reflection. These are mostly meant for internal use.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <R> R
extractValue
(Object classOrInstance, Field field, Class<? extends R> valueType) Extracts the value from the field of the specified instance or class with the given type.static void
invokeMethod
(Object classOrInstance, Method method) Invokes a non-returning method on the specified class or instance.
-
Constructor Details
-
Reflections
public Reflections()
-
-
Method Details
-
extractValue
Extracts the value from the field of the specified instance or class with the given type. Any exception is wrapped in aRuntimeException
.- Type Parameters:
R
- the value type of the field- Parameters:
classOrInstance
- the class or instance where the field is definedfield
- the fieldvalueType
- the value type of the field- Returns:
- the extracted field value
-
invokeMethod
Invokes a non-returning method on the specified class or instance. Any exception is wrapped in aRuntimeException
.- Parameters:
classOrInstance
- the class or instance where the method is definedmethod
- the method
-