public class ReflectionUtil
extends java.lang.Object
| Modifier and Type | Class and Description |
|---|---|
static class |
ReflectionUtil.ReflectionException |
| Modifier and Type | Method and Description |
|---|---|
static <T> java.util.Optional<java.lang.reflect.Constructor<T>> |
findMatchingConstructor(java.lang.Class<T> clazz,
java.lang.Class<?>... parameterTypes) |
static <T extends java.lang.annotation.Annotation> |
forEachAnnotatedField(java.lang.Class<? extends T> annotation,
java.lang.Class<?> clazz,
java.util.function.BiConsumer<java.lang.reflect.Field,T> action)
Invokes an action on each field annotated with specified annotation of
given object
|
static <T extends java.lang.annotation.Annotation> |
forEachRecursiveAnnotatedField(java.lang.Class<T> annotation,
java.lang.Class<?> clazz,
java.util.function.BiConsumer<java.lang.reflect.Field,T> action) |
static <T extends java.lang.annotation.Annotation> |
getAnnotatedFields(java.lang.Class<T> annotation,
java.lang.Class<?> clazz)
Gets all the annotated fields of this class, including all the parents
classes in the order of hierarchy.
|
static <T> T |
newInstance(java.lang.Class<T> clazz,
java.lang.Object... args) |
static <T> T |
newInstanceMatching(java.lang.Class<T> clazz,
java.lang.Object... args) |
public static <T> java.util.Optional<java.lang.reflect.Constructor<T>> findMatchingConstructor(java.lang.Class<T> clazz,
java.lang.Class<?>... parameterTypes)
public static <T> T newInstanceMatching(java.lang.Class<T> clazz,
java.lang.Object... args)
public static <T> T newInstance(java.lang.Class<T> clazz,
java.lang.Object... args)
public static <T extends java.lang.annotation.Annotation> void forEachAnnotatedField(java.lang.Class<? extends T> annotation,
java.lang.Class<?> clazz,
java.util.function.BiConsumer<java.lang.reflect.Field,T> action)
T - Annotation typeannotation - Annotation typeclazz - Class to scanaction - Action to invokepublic static <T extends java.lang.annotation.Annotation> java.util.Map<java.lang.reflect.Field,T> getAnnotatedFields(java.lang.Class<T> annotation,
java.lang.Class<?> clazz)
T - The annotation typeannotation - Your annotation class.clazz - Class to search through.public static <T extends java.lang.annotation.Annotation> void forEachRecursiveAnnotatedField(java.lang.Class<T> annotation,
java.lang.Class<?> clazz,
java.util.function.BiConsumer<java.lang.reflect.Field,T> action)