public class ReflectionUtils extends Object
| Constructor and Description |
|---|
ReflectionUtils() |
| Modifier and Type | Method and Description |
|---|---|
static Method |
findMethod(Method methodToFind,
Class<?> cls)
Searches the method methodToFind in given class cls.
|
static <A extends Annotation> |
getAnnotation(Class<?> cls,
Class<A> annotationClass) |
static <A extends Annotation> |
getAnnotation(Method method,
Class<A> annotationClass)
Returns an annotation by type from a method.
|
static List<Field> |
getDeclaredFields(Class<?> cls)
Returns the list of declared fields from the class
cls and its superclasses
excluding Object class. |
static Method |
getOverriddenMethod(Method method)
Returns overridden method from superclass if it exists.
|
static Annotation[][] |
getParameterAnnotations(Method method) |
static <A extends Annotation> |
getRepeatableAnnotations(Class<?> cls,
Class<A> annotationClass) |
static <A extends Annotation> |
getRepeatableAnnotations(Method method,
Class<A> annotationClass)
Returns a List of repeatable annotations by type from a method.
|
static <A extends Annotation> |
getRepeatableAnnotationsArray(Class<?> cls,
Class<A> annotationClass) |
static boolean |
hasOverriddenMethods(Method methodToFind,
Class<?> cls) |
static boolean |
isConstructorCompatible(Constructor<?> constructor) |
static boolean |
isInject(List<Annotation> annotations) |
static boolean |
isOverriddenMethod(Method methodToFind,
Class<?> cls)
Checks if the method methodToFind is the overridden method from the superclass or superinterface.
|
static boolean |
isSystemType(com.fasterxml.jackson.databind.JavaType type) |
static boolean |
isVoid(Type type)
Checks if the type is void.
|
static Class<?> |
loadClassByName(String className)
Load Class by class name.
|
static Optional<Object> |
safeInvoke(Method method,
Object obj,
Object... args) |
static Type |
typeFromString(String type) |
public static Class<?> loadClassByName(String className) throws ClassNotFoundException
className - Canonical class nameClassNotFoundExceptionpublic static boolean isOverriddenMethod(Method methodToFind, Class<?> cls)
methodToFind - is method to checkcls - is method classpublic static Method getOverriddenMethod(Method method)
method - is method to findpublic static Method findMethod(Method methodToFind, Class<?> cls)
methodToFind - is the method to searchcls - is the class or interface where to searchpublic static boolean isInject(List<Annotation> annotations)
public static boolean isConstructorCompatible(Constructor<?> constructor)
public static List<Field> getDeclaredFields(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.
The list is sorted by name to make the output of this method deterministic.
See https://docs.oracle.com/javase/8/docs/api/java/lang/Class.html#getFields--cls - is the processing classpublic static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationClass)
A - is the type of annotationmethod - is the method to findannotationClass - is the type of annotationpublic static <A extends Annotation> A getAnnotation(Class<?> cls, Class<A> annotationClass)
public static <A extends Annotation> List<A> getRepeatableAnnotations(Method method, Class<A> annotationClass)
A - is the type of annotationmethod - is the method to findannotationClass - is the type of annotationpublic static <A extends Annotation> List<A> getRepeatableAnnotations(Class<?> cls, Class<A> annotationClass)
public static <A extends Annotation> A[] getRepeatableAnnotationsArray(Class<?> cls, Class<A> annotationClass)
public static Annotation[][] getParameterAnnotations(Method method)
public static boolean isVoid(Type type)
type - is the type to checkpublic static boolean isSystemType(com.fasterxml.jackson.databind.JavaType type)
Copyright © 2022. All rights reserved.