Class 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>
      T
      getAnnotationInHierarchy​(java.lang.Class<?> clazz, java.lang.Class<T> annotation)  
      static java.lang.Class<?> getClassFromType​(java.lang.reflect.Type type)
      Returns the Class from a Type, 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 the Class from a Type, 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 check
        enumClass - Enum class to check the given value against
        Returns:
        True if given value is valid, false otherwise