List of utility methods to do Reflection Super Class
List | getSuperClasses(final Class> clazz) get Super Classes final ArrayList<Class<?>> results = new ArrayList<Class<?>>(); Class<?> current = clazz; while (current != null && current != Object.class) { results.add(current); current = current.getSuperclass(); return results; |
List | getSuperclassesForHeight(Collection Returns the list of super-classes of the specified height for the given collection of classes. List<Class<?>> superClasses = new ArrayList<>(); for (Class<?> cls : classes) { Class<?> supCls = getSuperclassForHeight(cls, height); superClasses.add(supCls); return superClasses; |
List | getSuperClasss(Class> sourceClass, boolean isAddCurrentClass) get Super Classs List<Class<?>> classList = new ArrayList<Class<?>>(); Class<?> classs; if (isAddCurrentClass) { classs = sourceClass; } else { classs = sourceClass.getSuperclass(); while (classs != null) { ... |
boolean | hasSuperclass(Class> klass, Class> ancestor) has Superclass return getAncestry(klass).contains(ancestor);
|
Class[] | resolveAllSuperclasses(Class type) Resolves all super classes, from top (direct subclass) to down. List<Class> list = new ArrayList<>(); while (true) { type = type.getSuperclass(); if ((type == null) || (type == Object.class)) { break; list.add(type); return list.toArray(new Class[0]); |