Class ReflectionUtils

    • Constructor Detail

      • ReflectionUtils

        public ReflectionUtils()
    • Method Detail

      • get

        public static <C,​T> Set<T> get​(QueryFunction<C,​T> function)
        get type elements <T> by applying QueryFunction
        get(SuperTypes.of(type))
      • getAllAnnotations

        public static <T extends AnnotatedElementSet<Annotation> getAllAnnotations​(T type,
                                                                                     Predicate<Annotation>... predicates)
        get all annotations of given type, up the super class hierarchy, optionally filtered by predicates

        marked for removal, use instead get(Annotations.of())

      • getAllSuperTypes

        public static Set<Class<?>> getAllSuperTypes​(Class<?> type,
                                                     Predicate<? super Class<?>>... predicates)
        get all super types of given type, including, optionally filtered by predicates
      • getSuperTypes

        public static Set<Class<?>> getSuperTypes​(Class<?> type)
        get the immediate supertype and interfaces of the given type

        marked for removal, use instead get(SuperTypes.get())

      • getAllMethods

        public static Set<Method> getAllMethods​(Class<?> type,
                                                Predicate<? super Method>... predicates)
        get all methods of given type, up the super class hierarchy, optionally filtered by predicates

        marked for removal, use instead get(Methods.of())

      • getMethods

        public static Set<Method> getMethods​(Class<?> t,
                                             Predicate<? super Method>... predicates)
        get methods of given type, optionally filtered by predicates

        marked for removal, use instead get(Methods.get())

      • getAllConstructors

        public static Set<Constructor> getAllConstructors​(Class<?> type,
                                                          Predicate<? super Constructor>... predicates)
        get all constructors of given type, up the super class hierarchy, optionally filtered by predicates

        marked for removal, use instead get(Constructors.of())

      • getConstructors

        public static Set<Constructor> getConstructors​(Class<?> t,
                                                       Predicate<? super Constructor>... predicates)
        get constructors of given type, optionally filtered by predicates

        marked for removal, use instead get(Constructors.get())

      • getAllFields

        public static Set<Field> getAllFields​(Class<?> type,
                                              Predicate<? super Field>... predicates)
        get all fields of given type, up the super class hierarchy, optionally filtered by predicates

        marked for removal, use instead get(Fields.of())

      • getFields

        public static Set<Field> getFields​(Class<?> type,
                                           Predicate<? super Field>... predicates)
        get fields of given type, optionally filtered by predicates

        marked for removal, use instead get(Fields.get())

      • getAnnotations

        public static <T extends AnnotatedElementSet<Annotation> getAnnotations​(T type,
                                                                                  Predicate<Annotation>... predicates)
        get annotations of given type, optionally honorInherited, optionally filtered by predicates

        marked for removal, use instead get(Annotations.get())

      • toMap

        public static Map<String,​Object> toMap​(Annotation annotation)
        map annotation to hash map of member values recursively
        Annotations.of(type).map(ReflectionUtils::toMap) 
      • toMap

        public static Map<String,​Object> toMap​(Annotation annotation,
                                                     AnnotatedElement element)
        map annotation and annotatedElement to hash map of member values
        Annotations.of(type).map(a -> toMap(type, a)) 
      • toAnnotation

        public static Annotation toAnnotation​(Map<String,​Object> map)
        create new annotation proxy with member values from the given map
        toAnnotation(Map.of("annotationType", annotationType, "value", ""))
      • toAnnotation

        public static <T extends Annotation> T toAnnotation​(Map<String,​Object> map,
                                                            Class<T> annotationType)
        create new annotation proxy with member values from the given map and member values from the given map
        toAnnotation(Map.of("value", ""), annotationType)
      • invoke

        public static Object invoke​(Method method,
                                    Object obj,
                                    Object... args)
        invoke the given method with args, return either the result or an exception if occurred