Java Reflection Super Class getSuperClasses(Class clz, boolean reverseOrder)

Here you can find the source of getSuperClasses(Class clz, boolean reverseOrder)

Description

get Super Classes

License

Apache License

Declaration

public static Class[] getSuperClasses(Class clz, boolean reverseOrder) 

Method Source Code

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

import java.util.*;

public class Main {
    public static Class[] getSuperClasses(Class clz, boolean reverseOrder) {
        return getSuperClasses(clz, reverseOrder, false);
    }// ww w.  j ava2s  .com

    public static Class[] getSuperClasses(Class clz, boolean reverseOrder, boolean includeObject) {
        boolean skipObject = !includeObject;
        List<Class> classes = new ArrayList<Class>();
        if (clz != null) {
            do {
                clz = clz.getSuperclass();
                if (Object.class.equals(clz) && skipObject)
                    continue;
                if (clz != null) {
                    if (reverseOrder) {
                        classes.add(0, clz);
                    } else {
                        classes.add(clz);
                    }
                } else {
                    break;
                }
            } while (true);
        }
        return classes.toArray(new Class[classes.size()]);
    }
}

Related

  1. getAllSuperClasses(Class clz)
  2. getAllSuperTypeNames(Class aClass)
  3. getParents(final Class Class)
  4. getSuper(Class clazz, Set result)
  5. getSuperClasses(Class clazz, Set result)
  6. getSuperclasses(Class from)
  7. getSuperClasses(Class c)
  8. getSuperclasses(Class clazz)
  9. getSuperClasses(Class clazz)