Class ClassMisc
- java.lang.Object
-
- org.apache.commons.jexl3.internal.introspection.ClassMisc
-
public class ClassMisc extends java.lang.Object
Miscellaneous introspection methods.The main algorithm is computing the actual ordered complete set of classes and interfaces that a given class extends or implements. This set order is based on the super-class then (recursive interface) declaration order, attempting to reflect the (hopefully intended) abstraction order (from strong to weak).
-
-
Constructor Summary
Constructors Modifier Constructor Description private
ClassMisc()
Lets not instantiate it.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static void
addSuperClasses(java.util.Set<java.lang.Class<?>> superSet, java.lang.Class<?> baseClass)
Collect super classes and interfaces in super-order.private static void
addSuperInterfaces(java.util.Set<java.lang.Class<?>> superSet, java.lang.Class<?> clazz)
Recursively add super-interfaces in super-order.static java.lang.Class<?>
getCommonSuperClass(java.lang.Class<?> baseClass, java.lang.Class<?> other)
Gets the closest common super-class of two classes.static java.util.Set<java.lang.Class<?>>
getSuperClasses(java.lang.Class<?> baseClass, java.lang.Class<?>... otherClasses)
Build the set of super classes and interfaces common to a collection of classes.
-
-
-
Method Detail
-
addSuperClasses
private static void addSuperClasses(java.util.Set<java.lang.Class<?>> superSet, java.lang.Class<?> baseClass)
Collect super classes and interfaces in super-order.This orders from stronger to weaker abstraction in the sense that Integer is a stronger abstraction than Number.
- Parameters:
superSet
- the set of super classes to collect intobaseClass
- the root class.
-
addSuperInterfaces
private static void addSuperInterfaces(java.util.Set<java.lang.Class<?>> superSet, java.lang.Class<?> clazz)
Recursively add super-interfaces in super-order.On the premise that a class also tends to enumerate interface in the order of weaker abstraction and that interfaces follow the same convention (strong implements weak).
- Parameters:
superSet
- the set of super classes to fillclazz
- the root class.
-
getCommonSuperClass
public static java.lang.Class<?> getCommonSuperClass(java.lang.Class<?> baseClass, java.lang.Class<?> other)
Gets the closest common super-class of two classes.When building an array, this helps strong-typing the result.
- Parameters:
baseClass
- the class to serve as baseother
- the other class- Returns:
- Object.class if nothing in common, the closest common class or interface otherwise
-
getSuperClasses
public static java.util.Set<java.lang.Class<?>> getSuperClasses(java.lang.Class<?> baseClass, java.lang.Class<?>... otherClasses)
Build the set of super classes and interfaces common to a collection of classes.The returned set is ordered and puts classes in order of super-class appearance then interfaces of each super-class.
- Parameters:
baseClass
- the class to serve as baseotherClasses
- the (optional) other classes- Returns:
- an empty set if nothing in common, the set of common classes and interfaces that does not contain the baseClass nor Object class
-
-