Here you can find the source of getAllClassesAndInterfaces(Class startClass)
Parameter | Description |
---|---|
startClass | The class |
public static List getAllClassesAndInterfaces(Class startClass)
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { /**// ww w. j a va 2 s . com * Find all super classes and implemented interfaces for the given * class. * * @param startClass The class * @return A List of Class objects */ public static List getAllClassesAndInterfaces(Class startClass) { ArrayList classes = new ArrayList(); addClassesAndInterfaces(startClass, classes); return classes; } /** * Add all super classes and interfaces of the given class to the given * List. * * @param c The Class * @param classes An List of Classes */ protected static void addClassesAndInterfaces(Class c, List classes) { if (c != null) { Class superClass = c.getSuperclass(); Class[] interfaces = c.getInterfaces(); if (superClass != null && !classes.contains(superClass)) { classes.add(superClass); } for (Class anInterface : interfaces) { if (anInterface != null && !classes.contains(anInterface)) { classes.add(anInterface); } } addClassesAndInterfaces(superClass, classes); for (Class anInterface : interfaces) { addClassesAndInterfaces(anInterface, classes); } } } }