Package net.engio.mbassy.common
Class ReflectionUtils
- java.lang.Object
-
- net.engio.mbassy.common.ReflectionUtils
-
public class ReflectionUtils extends java.lang.Object
-
-
Constructor Summary
Constructors Constructor Description ReflectionUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidcollectInterfaces(java.lang.Class from, java.util.Collection<java.lang.Class> accumulator)static booleancontainsOverridingMethod(java.lang.reflect.Method[] allMethods, java.lang.reflect.Method methodToCheck)static <A extends java.lang.annotation.Annotation>
AgetAnnotation(java.lang.reflect.AnnotatedElement from, java.lang.Class<A> annotationType)private static <A extends java.lang.annotation.Annotation>
AgetAnnotation(java.lang.reflect.AnnotatedElement from, java.lang.Class<A> annotationType, java.util.Set<java.lang.reflect.AnnotatedElement> visited)Searches for an Annotation of the given type on the class.static java.lang.reflect.Method[]getMethods(IPredicate<java.lang.reflect.Method> condition, java.lang.Class<?> target)static voidgetMethods(IPredicate<java.lang.reflect.Method> condition, java.lang.Class<?> target, java.util.ArrayList<java.lang.reflect.Method> methods)static java.lang.reflect.MethodgetOverridingMethod(java.lang.reflect.Method overridingMethod, java.lang.Class subclass)Traverses the class hierarchy upwards, starting at the given subclass, looking for an override of the given methods -> finds the bottom most override of the given method if any existsstatic java.lang.Class[]getSuperTypes(java.lang.Class from)Collect all directly and indirectly related super types (classes and interfaces) of a given class.private static booleanisOverriddenBy(java.lang.reflect.Method superclassMethod, java.lang.reflect.Method subclassMethod)
-
-
-
Method Detail
-
getMethods
public static java.lang.reflect.Method[] getMethods(IPredicate<java.lang.reflect.Method> condition, java.lang.Class<?> target)
-
getMethods
public static void getMethods(IPredicate<java.lang.reflect.Method> condition, java.lang.Class<?> target, java.util.ArrayList<java.lang.reflect.Method> methods)
-
getOverridingMethod
public static java.lang.reflect.Method getOverridingMethod(java.lang.reflect.Method overridingMethod, java.lang.Class subclass)Traverses the class hierarchy upwards, starting at the given subclass, looking for an override of the given methods -> finds the bottom most override of the given method if any exists- Parameters:
overridingMethod-subclass-
-
getSuperTypes
public static java.lang.Class[] getSuperTypes(java.lang.Class from)
Collect all directly and indirectly related super types (classes and interfaces) of a given class.- Parameters:
from- The root class to start with- Returns:
- A set of classes, each representing a super type of the root class
-
collectInterfaces
public static void collectInterfaces(java.lang.Class from, java.util.Collection<java.lang.Class> accumulator)
-
containsOverridingMethod
public static boolean containsOverridingMethod(java.lang.reflect.Method[] allMethods, java.lang.reflect.Method methodToCheck)
-
getAnnotation
private static <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.reflect.AnnotatedElement from, java.lang.Class<A> annotationType, java.util.Set<java.lang.reflect.AnnotatedElement> visited)Searches for an Annotation of the given type on the class. Supports meta annotations.- Type Parameters:
A- Class of annotation type- Parameters:
from- AnnotatedElement (class, method...)annotationType- Annotation class to look for.- Returns:
- Annotation instance or null
-
getAnnotation
public static <A extends java.lang.annotation.Annotation> A getAnnotation(java.lang.reflect.AnnotatedElement from, java.lang.Class<A> annotationType)
-
isOverriddenBy
private static boolean isOverriddenBy(java.lang.reflect.Method superclassMethod, java.lang.reflect.Method subclassMethod)
-
-