Class ReflectionUtils


  • public class ReflectionUtils
    extends Object
    Various utility methods that simplify JAVA reflection actions.
    Author:
    jbegic
    • Method Detail

      • getAnnotatedFields

        public static List<Field> getAnnotatedFields​(Class<?> clazz,
                                                     Class<? extends Annotation> annotation,
                                                     boolean checkSuperclass)
        Returns all field from a given class that are annotated with provided annotation type.
        Parameters:
        clazz - source class
        annotation - target annotation
        checkSuperclass - if true, method will follow class hierarchy to look for fields with target annotation
        Returns:
        list of fields or empty collection in case no fields were found
      • getTypeName

        public static String getTypeName​(Class<?> clazz)
        Returns the type name defined using Type annotation on provided class.
        Parameters:
        clazz - type class
        Returns:
        name of the type or null in case Type annotation is not present
      • getFieldType

        public static Class<?> getFieldType​(Field field)