Java Reflection Super Class getSuperclasses(Class clazz)

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

Description

Gets a List of superclasses for the given class.

License

Open Source License

Parameter

Parameter Description
clazz the class to look up, may be <code>null</code>

Return

the List of superclasses in order going up from this one null if null input

Declaration

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

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**/* w  ww.  j  a v  a  2s.c o  m*/
     * <p>
     * Gets a <code>List</code> of superclasses for the given class.
     * </p>
     *
     * @param clazz the class to look up, may be <code>null</code>
     * @return the <code>List</code> of superclasses in order going up from this
     *         one <code>null</code> if null input
     */
    public static List<Class<?>> getSuperclasses(Class<?> clazz) {
        if (clazz == null)
            return null;
        List<Class<?>> classes = new ArrayList<Class<?>>();
        Class<?> superclass = clazz.getSuperclass();
        while (superclass != null) {
            classes.add(superclass);
            superclass = superclass.getSuperclass();
        }
        return classes;
    }
}

Related

  1. getSuperClasses(Class clz, boolean reverseOrder)
  2. getSuperclasses(Class from)
  3. getSuperClasses(Class c)
  4. getSuperclasses(Class clazz)
  5. getSuperClasses(Class clazz)
  6. getSuperClasses(Class cls)
  7. getSuperClasses(Class entryClass)
  8. getSuperclasses(Class the_class)
  9. getSuperClasses(final Class clazz)