Java Reflection Super Class getAllSuperclasses(Class clazz)

Here you can find the source of getAllSuperclasses(Class clazz)

Description

Returns a List of superclasses for the given class.

License

Apache License

Parameter

Parameter Description
clazz - the class to look up

Return

the List of super-classes in order going up from this one

Declaration

public static List<Class<?>> getAllSuperclasses(Class<?> clazz) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**//from ww w . j  ava 2s. com
     * Returns a List of superclasses for the given class.
     * 
     * @param clazz - the class to look up
     * @return the List of super-classes in order going up from this one
     */
    public static List<Class<?>> getAllSuperclasses(Class<?> clazz) {
        List<Class<?>> classes = new ArrayList<Class<?>>();

        Class<?> superclass = clazz.getSuperclass();
        while (superclass != null) {
            classes.add(superclass);
            superclass = superclass.getSuperclass();
        }

        return classes;
    }
}

Related

  1. findSuperTypes(Class cls, Class endBefore)
  2. getAllSuperClass(Class clazz, boolean includesObjectClass)
  3. getAllSuperclasses(Class cls)
  4. getAllSuperclasses(Class cls)
  5. getAllSuperClasses(Class clazz)
  6. getAllSuperClasses(Class clz)
  7. getAllSuperTypeNames(Class aClass)
  8. getParents(final Class Class)
  9. getSuper(Class clazz, Set result)