public class Reflections
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static interface |
Reflections.FieldRunner<A extends java.lang.annotation.Annotation> |
static interface |
Reflections.MethodRunner<A extends java.lang.annotation.Annotation> |
Constructor and Description |
---|
Reflections() |
Modifier and Type | Method and Description |
---|---|
static void |
addToCollectionField(java.lang.Object owner,
java.lang.reflect.Field field,
java.lang.Object item)
Add the item to a collection field of an object.
|
static <A extends java.lang.annotation.Annotation> |
forFields(java.lang.Class<?> clazz,
java.lang.Class<A> annotationClass,
Reflections.FieldRunner<A> runner)
Traverse through all fields with a certain annotation in a class and
it super classes.
|
static <A extends java.lang.annotation.Annotation> |
forMethods(java.lang.Class<?> clazz,
java.lang.Class<A> annotationClass,
Reflections.MethodRunner<A> runner)
Traverse through all methods with a certain annotation in a class,
including ones inherited from its super class.
|
static java.lang.Class<?> |
getClass(java.lang.reflect.Type type)
Return the Class representing the given Type.
|
static java.lang.Object |
getFieldValue(java.lang.Object bean,
java.lang.reflect.Field field)
Get field value.
|
static void |
invokeMethod(java.lang.reflect.Method method,
java.lang.Object bean,
java.lang.Object... arguments)
Invoke a method reflexively.
|
static boolean |
isAppendableToCollection(java.lang.reflect.Type type,
java.lang.Object object)
Return true if field is of Collection type, and an object of type clazz
can be added into the Collection.
|
static boolean |
isPassableToMethod(java.lang.reflect.Method method,
java.lang.Object... arguments)
Return true if the given arguments can be passed as the arguments of
the method.
|
static void |
setFieldValue(java.lang.Object bean,
java.lang.reflect.Field field,
java.lang.Object value)
Set a value to a field of the object.
|
public static <A extends java.lang.annotation.Annotation> void forFields(java.lang.Class<?> clazz, java.lang.Class<A> annotationClass, Reflections.FieldRunner<A> runner)
All the fields with the same name will be scanned too. (since 6.5.1), before 6.5.1 release, only the subclass will be scanned.
public static <A extends java.lang.annotation.Annotation> void forMethods(java.lang.Class<?> clazz, java.lang.Class<A> annotationClass, Reflections.MethodRunner<A> runner)
public static boolean isAppendableToCollection(java.lang.reflect.Type type, java.lang.Object object)
public static boolean isPassableToMethod(java.lang.reflect.Method method, java.lang.Object... arguments)
public static void setFieldValue(java.lang.Object bean, java.lang.reflect.Field field, java.lang.Object value)
public static java.lang.Object getFieldValue(java.lang.Object bean, java.lang.reflect.Field field)
public static void addToCollectionField(java.lang.Object owner, java.lang.reflect.Field field, java.lang.Object item)
public static void invokeMethod(java.lang.reflect.Method method, java.lang.Object bean, java.lang.Object... arguments)
public static java.lang.Class<?> getClass(java.lang.reflect.Type type)
Copyright © 2005-2021 Potix Corporation. All Rights Reserved.