public final class ReflectionUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static <E extends Executable> |
getByModifier(E[] executables,
int modifier)
Get executables with the specified modifier
|
static <R,T> Collection<R> |
getFieldValues(Class<T> clazz,
Class<R> type,
T instance)
Collect values of static fields with the specified type
|
static Optional<Method> |
getMethod(Class<?> clazz,
String methodName,
Class<?>... parameterTypes)
Get method wrapped into optional instead of exception if method does not exist.
|
static List<Method> |
getMethods(Class<?> clazz,
String methodName)
Collect all methods with the same name
|
static Set<Method> |
getMethodsAnnotatedWith(Class<?> clazz,
Class<? extends Annotation> annotation)
Collect methods annotated with the specified annotation
|
static <T> Collection<T> |
getStaticFieldValues(Class<?> clazz,
Class<T> type)
Collect values of static fields with the specified type
|
public static <E extends Executable> Collection<E> getByModifier(E[] executables, int modifier)
E - type of executableexecutables - array of executables to search inmodifier - the modifier to search forpublic static Optional<Method> getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes)
Class.getMethod(String, Class[]) it also checks non-public methods.clazz - the class to search inmethodName - name of methodparameterTypes - parameter types of methodpublic static List<Method> getMethods(Class<?> clazz, String methodName)
clazz - class to searchmethodName - name to search forpublic static Set<Method> getMethodsAnnotatedWith(Class<?> clazz, Class<? extends Annotation> annotation)
clazz - class to searchannotation - annotation to search forpublic static <T> Collection<T> getStaticFieldValues(Class<?> clazz, Class<T> type)
T - value typeclazz - class to search intype - type of fieldpublic static <R,T> Collection<R> getFieldValues(Class<T> clazz, Class<R> type, @Nullable T instance)
R - type of valuesT - type of instanceclazz - class to search intype - type of fieldsinstance - instanceCopyright © 2020. All rights reserved.