public class Reflects extends Object
| 构造器和说明 |
|---|
Reflects() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Collection<Field> |
filterFields(Field[] fields,
int... excludedModifiers) |
static Collection<Field> |
getAllDeclaredFields(Class clazz) |
static Collection<Field> |
getAllDeclaredFields(Class clazz,
boolean containsStatic) |
static Set<Class<?>> |
getAllInterfaces(Class clazz) |
static Collection<Field> |
getAllPublicFields(Class clazz,
boolean containsStatic) |
static Collection<Field> |
getAllPublicInstanceFields(Class clazz) |
static Set<Class<?>> |
getAllSuperClass(Class clazz) |
static <E extends Annotation> |
getAnnotation(AnnotatedElement annotatedElement,
Class<E> annotationClass)
Returns this element's annotation for the specified type if
such an annotation is present, else null.
|
static Annotation[] |
getAnnotations(AnnotatedElement annotatedElement)
Returns all annotations present on this element.
|
static Field |
getAnyField(Class clazz,
String fieldName) |
static <V> V |
getAnyFieldValue(Object object,
String fieldName,
boolean force,
boolean throwException) |
static <V> V |
getAnyFieldValueForcedIfPresent(Object object,
String fieldName) |
static Method |
getAnyMethod(Class clazz,
String methodName,
Class... parameterTypes) |
static URL |
getCodeLocation(Class clazz) |
static Constructor |
getConstructor(Class clazz,
Class... parameterTypes) |
static List<Annotation> |
getDeclaredAnnotations(AnnotatedElement annotatedElement)
Returns all annotations that are directly present on this
element.
|
static Field |
getDeclaredField(Class clazz,
String fieldName) |
static <V> V |
getDeclaredFieldValue(Object object,
String fieldName,
boolean force,
boolean throwException) |
static <V> V |
getDeclaredFieldValueForcedIfPresent(Object object,
String fieldName) |
static Method |
getDeclaredMethod(Class clazz,
String methodName,
Class... parameterTypes) |
static <V> V |
getFieldValue(Field field,
Object object,
boolean force,
boolean throwException) |
static String |
getFQNClassName(Class clazz) |
static String |
getJvmSignature(Class clazz) |
static String |
getMethodString(Class clazz,
String methodName,
Class[] parameterTypes) |
static String |
getMethodString(Method method) |
static String |
getMethodString(String clazzFQN,
String methodName,
Class returnType,
Class[] parameterTypes) |
static String |
getPackageName(Class clazz) |
static Field |
getPublicField(Class clazz,
String fieldName) |
static <V> V |
getPublicFieldValue(Object object,
String fieldName,
boolean throwException) |
static <V> V |
getPublicFieldValueForcedIfPresent(Object object,
String fieldName) |
static Method |
getPublicMethod(Class clazz,
String methodName,
Class... parameterTypes) |
static String |
getSimpleClassName(Class clazz) |
static String |
getSimpleClassName(Object obj) |
static String |
getTypeName(Class type) |
static Iterable<Class<?>> |
hierarchy(Class<?> type)
Get an
Iterable that can iterate over a class hierarchy in ascending (subclass to superclass) order,
excluding interfaces. |
static Iterable<Class<?>> |
hierarchy(Class<?> type,
boolean excludeInterfaces)
Get an
Iterable that can iterate over a class hierarchy in ascending (subclass to superclass) order. |
static <V> V |
invoke(Method method,
Object object,
Object[] parameters,
boolean force,
boolean throwException) |
static <V> V |
invokeAnyMethod(Object object,
String methodName,
Class[] parameterTypes,
Object[] parameters,
boolean force,
boolean throwException) |
static <V> V |
invokeAnyMethodForcedIfPresent(Object object,
String methodName,
Class[] parameterTypes,
Object[] parameters) |
static <V> V |
invokeAnyStaticMethod(Class clazz,
String methodName,
Class[] parameterTypes,
Object[] parameters,
boolean force,
boolean throwException) |
static <V> V |
invokeAnyStaticMethod(String clazz,
String methodName,
Class[] parameterTypes,
Object[] parameters,
boolean force,
boolean throwException) |
static <V> V |
invokeDeclaredMethod(Object object,
String methodName,
Class[] parameterTypes,
Object[] parameters,
boolean force,
boolean throwException) |
static <V> V |
invokeDeclaredMethodForcedIfPresent(Object object,
String methodName,
Class[] parameterTypes,
Object[] parameters) |
static <V> V |
invokePublicMethod(Object object,
String methodName,
Class[] parameterTypes,
Object[] parameters,
boolean force,
boolean throwException) |
static <V> V |
invokePublicMethodForcedIfPresent(Object object,
String methodName,
Class[] parameterTypes,
Object[] parameters) |
static boolean |
isAnnotationPresent(AnnotatedElement annotatedElement,
Class<? extends Annotation> annotationClass)
Returns true if an annotation for the specified type
is present on this element, else false.
|
static boolean |
isAnonymous(Class clazz) |
static boolean |
isAnonymousOrLocal(Class<?> clazz) |
static boolean |
isInnerClass(Class<?> clazz) |
static <T> boolean |
isInstance(T object,
String classFQN) |
static boolean |
isLambda(Class<?> clazz) |
static boolean |
isLocal(Class clazz) |
static boolean |
isStatic(Class<?> clazz) |
static <E> E |
newInstance(Class<E> clazz) |
static <E> E |
newInstance(Class<E> clazz,
Class[] parameterTypes,
Object[] parameters) |
static void |
setAnyFieldValue(Object object,
String fieldName,
Object value,
boolean force,
boolean throwException) |
static void |
setDeclaredFieldValue(Object object,
String fieldName,
Object value,
boolean force,
boolean throwException) |
static void |
setFieldValue(Field field,
Object target,
Object value,
boolean force,
boolean throwException) |
static void |
setPublicFieldValue(Object object,
String fieldName,
Object value,
boolean force,
boolean throwException) |
public static Iterable<Class<?>> hierarchy(@NonNull Class<?> type)
Iterable that can iterate over a class hierarchy in ascending (subclass to superclass) order,
excluding interfaces.type - the type to get the class hierarchy frompublic static Iterable<Class<?>> hierarchy(@NonNull Class<?> type, boolean excludeInterfaces)
Iterable that can iterate over a class hierarchy in ascending (subclass to superclass) order.type - the type to get the class hierarchy fromexcludeInterfaces - switch indicating whether to include or exclude interfacespublic static boolean isAnnotationPresent(@NonNull AnnotatedElement annotatedElement, @NonNull Class<? extends Annotation> annotationClass)
public static <E extends Annotation> E getAnnotation(@NonNull AnnotatedElement annotatedElement, @NonNull Class<E> annotationClass)
public static Annotation[] getAnnotations(@NonNull AnnotatedElement annotatedElement)
public static List<Annotation> getDeclaredAnnotations(@NonNull AnnotatedElement annotatedElement)
public static Field getDeclaredField(@NonNull Class clazz, @NonNull String fieldName)
public static Collection<Field> getAllDeclaredFields(@NonNull Class clazz)
public static Collection<Field> getAllDeclaredFields(@NonNull Class clazz, boolean containsStatic)
public static Collection<Field> getAllPublicInstanceFields(@NonNull Class clazz)
public static Collection<Field> getAllPublicFields(@NonNull Class clazz, boolean containsStatic)
public static Collection<Field> filterFields(@NonNull Field[] fields, int... excludedModifiers)
public static <V> V getPublicFieldValueForcedIfPresent(@NonNull Object object, @NonNull String fieldName)
public static <V> V getPublicFieldValue(@NonNull Object object, @NonNull String fieldName, boolean throwException)
public static <V> V getDeclaredFieldValueForcedIfPresent(@NonNull Object object, @NonNull String fieldName)
public static <V> V getDeclaredFieldValue(@NonNull Object object, String fieldName, boolean force, boolean throwException) throws NoSuchFieldException, IllegalAccessException
public static <V> V getAnyFieldValueForcedIfPresent(@NonNull Object object, @NonNull String fieldName)
public static <V> V getAnyFieldValue(@NonNull Object object, @NonNull String fieldName, boolean force, boolean throwException)
public static <V> V getFieldValue(@NonNull Field field, @NonNull Object object, boolean force, boolean throwException)
public static void setFieldValue(@NonNull Field field, @NonNull Object target, Object value, boolean force, boolean throwException)
public static void setPublicFieldValue(@NonNull Object object, @NonNull String fieldName, Object value, boolean force, boolean throwException)
public static void setDeclaredFieldValue(@NonNull Object object, @NonNull String fieldName, Object value, boolean force, boolean throwException)
public static void setAnyFieldValue(@NonNull Object object, @NonNull String fieldName, Object value, boolean force, boolean throwException)
public static Constructor getConstructor(@NonNull Class clazz, Class... parameterTypes)
public static <E> E newInstance(@NonNull Class<E> clazz, @Nullable Class[] parameterTypes, @NonNull Object[] parameters)
public static Method getPublicMethod(@NonNull Class clazz, @NonNull String methodName, Class... parameterTypes)
public static Method getDeclaredMethod(@NonNull Class clazz, @NonNull String methodName, Class... parameterTypes)
public static Method getAnyMethod(@NonNull Class clazz, @NonNull String methodName, Class... parameterTypes)
public static <V> V invokePublicMethodForcedIfPresent(@NonNull Object object, @NonNull String methodName, @Nullable Class[] parameterTypes, @Nullable Object[] parameters)
public static <V> V invokePublicMethod(@NonNull Object object, @NonNull String methodName, @Nullable Class[] parameterTypes, @Nullable Object[] parameters, boolean force, boolean throwException)
public static <V> V invokeDeclaredMethodForcedIfPresent(@NonNull Object object, @NonNull String methodName, @Nullable Class[] parameterTypes, @Nullable Object[] parameters)
public static <V> V invokeDeclaredMethod(@NonNull Object object, @NonNull String methodName, @Nullable Class[] parameterTypes, @Nullable Object[] parameters, boolean force, boolean throwException)
public static <V> V invokeAnyMethodForcedIfPresent(@NonNull Object object, @NonNull String methodName, @Nullable Class[] parameterTypes, @Nullable Object[] parameters)
public static <V> V invokeAnyMethod(@NonNull Object object, @NonNull String methodName, @Nullable Class[] parameterTypes, @Nullable Object[] parameters, boolean force, boolean throwException)
public static <V> V invoke(@NonNull Method method, @Nullable Object object, @Nullable Object[] parameters, boolean force, boolean throwException)
public static <V> V invokeAnyStaticMethod(String clazz, String methodName, Class[] parameterTypes, Object[] parameters, boolean force, boolean throwException) throws ClassNotFoundException
public static <V> V invokeAnyStaticMethod(Class clazz, String methodName, Class[] parameterTypes, Object[] parameters, boolean force, boolean throwException)
public static String getMethodString(@Nullable String clazzFQN, @NonNull String methodName, @Nullable Class returnType, @Nullable Class[] parameterTypes)
public static String getMethodString(@NonNull Class clazz, @NonNull String methodName, @Nullable Class[] parameterTypes)
public static <T> boolean isInstance(T object,
String classFQN)
Copyright © 2019. All rights reserved.