Package org.faktorips.runtime.util
Class ReflectionHelper
java.lang.Object
org.faktorips.runtime.util.ReflectionHelper
A helper to make dealing with Java's reflection API a little easier.
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T,R> Optional<R> findFieldValue(Class<T> clazz, String fieldName, T object) Finds a field of the given name in the given class and returns its value from the given object, if such a field is present, otherwise anempty Optional.static <R> Optional<R>findStaticFieldValue(Class<?> clazz, String fieldName) Finds a static field of the given name in the given class and returns its value, if such a field is present, otherwise anempty Optional.
-
Method Details
-
findStaticFieldValue
Finds a static field of the given name in the given class and returns its value, if such a field is present, otherwise anempty Optional.- Type Parameters:
R- the return value's type- Parameters:
clazz- a classfieldName- the name of a field of the class- Returns:
- the field's value if present, otherwise an
empty Optional.
-
findFieldValue
Finds a field of the given name in the given class and returns its value from the given object, if such a field is present, otherwise anempty Optional.- Type Parameters:
T- the type of the class and objectR- the return value's type- Parameters:
clazz- a classfieldName- the name of a field of the classobject- an object of the type of theclazz; may benullfor static fields- Returns:
- the field's value if present, otherwise an
empty Optional.
-