public class ReflectionUtils
extends java.lang.Object
Constructor and Description |
---|
ReflectionUtils() |
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.Method |
findMethod(java.lang.reflect.Method methodToFind,
java.lang.Class<?> cls)
Searches the method methodToFind in given class cls.
|
static <A extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.Class<?> cls,
java.lang.Class<A> annotationClass) |
static <A extends java.lang.annotation.Annotation> |
getAnnotation(java.lang.reflect.Method method,
java.lang.Class<A> annotationClass)
Returns an annotation by type from a method.
|
static java.util.List<java.lang.reflect.Field> |
getDeclaredFields(java.lang.Class<?> cls)
Returns the list of declared fields from the class
cls and its superclasses
excluding Object class. |
static java.lang.reflect.Method |
getOverriddenMethod(java.lang.reflect.Method method)
Returns overridden method from superclass if it exists.
|
static java.lang.annotation.Annotation[][] |
getParameterAnnotations(java.lang.reflect.Method method) |
static boolean |
isConstructorCompatible(java.lang.reflect.Constructor<?> constructor) |
static boolean |
isInject(java.util.List<java.lang.annotation.Annotation> annotations) |
static boolean |
isOverriddenMethod(java.lang.reflect.Method methodToFind,
java.lang.Class<?> cls)
Checks if the method methodToFind is the overridden method from the superclass or superinterface.
|
static boolean |
isVoid(java.lang.reflect.Type type)
Checks if the type is void.
|
static java.lang.Class<?> |
loadClassByName(java.lang.String className)
Load Class by class name.
|
static java.lang.reflect.Type |
typeFromString(java.lang.String type) |
public static java.lang.reflect.Type typeFromString(java.lang.String type)
public static java.lang.Class<?> loadClassByName(java.lang.String className) throws java.lang.ClassNotFoundException
className
- Canonical class namejava.lang.ClassNotFoundException
public static boolean isOverriddenMethod(java.lang.reflect.Method methodToFind, java.lang.Class<?> cls)
methodToFind
- is method to checkcls
- is method classpublic static java.lang.reflect.Method getOverriddenMethod(java.lang.reflect.Method method)
method
- is method to findpublic static java.lang.reflect.Method findMethod(java.lang.reflect.Method methodToFind, java.lang.Class<?> cls)
methodToFind
- is the method to searchcls
- is the class or interface where to searchpublic static boolean isInject(java.util.List<java.lang.annotation.Annotation> annotations)
public static boolean isConstructorCompatible(java.lang.reflect.Constructor<?> constructor)
public static java.util.List<java.lang.reflect.Field> getDeclaredFields(java.lang.Class<?> cls)
cls
and its superclasses
excluding Object
class. If the field from child class hides the field from superclass,
the field from superclass won't be added to the result list.cls
- is the processing classpublic static <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.reflect.Method method, java.lang.Class<A> annotationClass)
A
- is the type of annotationmethod
- is the method to findannotationClass
- is the type of annotationpublic static <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.Class<?> cls, java.lang.Class<A> annotationClass)
public static java.lang.annotation.Annotation[][] getParameterAnnotations(java.lang.reflect.Method method)
public static boolean isVoid(java.lang.reflect.Type type)
type
- is the type to checkCopyright © 2018. All Rights Reserved.