Java Reflection Super Class resolveAllSuperclasses(Class type)

Here you can find the source of resolveAllSuperclasses(Class type)

Description

Resolves all super classes, from top (direct subclass) to down.

License

Open Source License

Declaration

public static Class[] resolveAllSuperclasses(Class type) 

Method Source Code

//package com.java2s;

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/* w w  w . ja  v  a 2 s  .co m*/
     * Resolves all super classes, from top (direct subclass) to down. <code>Object</code>
     * class is not included in the list.
     */
    public static Class[] resolveAllSuperclasses(Class type) {
        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]);
    }
}

Related

  1. getSuperclasses(Class the_class)
  2. getSuperClasses(final Class clazz)
  3. getSuperclassesForHeight(Collection> classes, int height)
  4. getSuperClasss(Class sourceClass, boolean isAddCurrentClass)
  5. hasSuperclass(Class klass, Class ancestor)