public final class Reflections extends Object
Internal API: these methods are part of the internal API and may be removed, have their signature change, or have their access level decreased from public to protected, package, or private in future versions without notice.
| Modifier and Type | Method and Description |
|---|---|
static List<Field> |
findAllFields(Class<?> type)
Get all fields on given object and look for fields of
super classes.
|
static List<Field> |
findStaticFieldsAnnotatedWith(Class<?> type,
Class<? extends Annotation> annotationClass)
Get all static fields on given class object
annotated with given annotation.
|
static List<Method> |
findStaticMethodsAnnotatedWith(Class<?> type,
Class<? extends Annotation> annotationClass)
Get all static methods on given class object
annotated with given annotation.
|
static <T> T |
getter(Field field)
Get value of static field.
|
static <T> T |
getter(Object target,
Field field)
Get value of field on target object.
|
static <T> T |
invoke(Method method)
Invoke the static method without any arguments.
|
static void |
setter(Object instance,
Field field,
Object value)
Set value of given field on given instance.
|
public static List<Field> findAllFields(Class<?> type)
type - Class to inspect.public static List<Field> findStaticFieldsAnnotatedWith(Class<?> type, Class<? extends Annotation> annotationClass)
type - Class to inspect.annotationClass - Annotation class.public static List<Method> findStaticMethodsAnnotatedWith(Class<?> type, Class<? extends Annotation> annotationClass)
type - Class to inspect.annotationClass - Annotation class.public static void setter(Object instance, Field field, Object value)
instance - Instance.field - Field.value - Field value.ReflectionException - if set operation is not permitted.public static <T> T getter(Field field)
T - Type of expected value.field - Field.public static <T> T getter(Object target, Field field)
T - Type of expected value.target - Target object.field - Field.public static <T> T invoke(Method method)
T - Return type.method - The method to invoke.Copyright © 2019. All rights reserved.