Here you can find the source of getSuperclasses(Class> clazz)
Gets a List
of superclasses for the given class.
Parameter | Description |
---|---|
clazz | the class to look up, may be <code>null</code> |
List
of superclasses in order going up from this one null
if null input
public static List<Class<?>> getSuperclasses(Class<?> clazz)
//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; } }