Package org.syncany.util
Class ReflectionUtil
- java.lang.Object
-
- org.syncany.util.ReflectionUtil
-
public abstract class ReflectionUtil extends java.lang.Object
Utility class to find classes, methods and fields with certain properties - typically having an annotation or a certain erasure.
-
-
Constructor Summary
Constructors Constructor Description ReflectionUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.reflect.Field[]
getAllFieldsWithAnnotation(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
static java.lang.reflect.Method[]
getAllMethodsWithAnnotation(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
static <T extends java.lang.annotation.Annotation>
TgetAnnotationInHierarchy(java.lang.Class<?> clazz, java.lang.Class<T> annotation)
static java.lang.Class<?>
getClassFromType(java.lang.reflect.Type type)
Returns theClass
from aType
, or returns null if the class is not found, or the type is not a class.static java.lang.reflect.Constructor<?>
getMatchingConstructorForClass(java.lang.Class<?> clazz, java.lang.Class<?>... parameterTypes)
static boolean
isAnnotationPresentInHierarchy(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
static boolean
isValidEnum(java.lang.String checkEnumValue, java.lang.Class<?> enumClass)
Returns whether or not the value is a valid value for the enum given.
-
-
-
Constructor Detail
-
ReflectionUtil
public ReflectionUtil()
-
-
Method Detail
-
getAllFieldsWithAnnotation
public static java.lang.reflect.Field[] getAllFieldsWithAnnotation(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
-
getAllMethodsWithAnnotation
public static java.lang.reflect.Method[] getAllMethodsWithAnnotation(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
-
getMatchingConstructorForClass
public static java.lang.reflect.Constructor<?> getMatchingConstructorForClass(java.lang.Class<?> clazz, java.lang.Class<?>... parameterTypes)
-
getClassFromType
public static java.lang.Class<?> getClassFromType(java.lang.reflect.Type type)
Returns theClass
from aType
, or returns null if the class is not found, or the type is not a class.
-
isAnnotationPresentInHierarchy
public static boolean isAnnotationPresentInHierarchy(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
-
getAnnotationInHierarchy
public static <T extends java.lang.annotation.Annotation> T getAnnotationInHierarchy(java.lang.Class<?> clazz, java.lang.Class<T> annotation)
-
isValidEnum
public static boolean isValidEnum(java.lang.String checkEnumValue, java.lang.Class<?> enumClass)
Returns whether or not the value is a valid value for the enum given.- Parameters:
checkEnumValue
- Value to checkenumClass
- Enum class to check the given value against- Returns:
- True if given value is valid, false otherwise
-
-