Here you can find the source of getAllInterfaces(Class clazz)
Parameter | Description |
---|---|
clazz | the class |
public static Class[] getAllInterfaces(Class clazz)
//package com.java2s; import java.util.ArrayList; public class Main { /**/*www . j a v a 2s. c o m*/ * Returns all of the interfaces implemented by a class. * * @param clazz the class * @return a list of the interfaces implemented by the class. */ public static Class[] getAllInterfaces(Class clazz) { ArrayList result = new ArrayList(); getAllInterfaces(clazz, result); return (Class[]) result.toArray(new Class[0]); } /** * Returns all of the interfaces inplemented by a class. * @param clazz the class * @param result the array to contain the result */ private static void getAllInterfaces(Class clazz, ArrayList result) { Class[] interfaces = clazz.getInterfaces(); for (int i = 0; i < interfaces.length; ++i) { if (!result.contains(interfaces[i])) { result.add(interfaces[i]); } } Class superClass = clazz.getSuperclass(); if (superClass != null) { getAllInterfaces(superClass, result); } } }