Java Reflection Interface Get getAllInterfaces(Class clazz)

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

Description

get All Interfaces

License

LGPL

Declaration

public static Class[] getAllInterfaces(Class clazz) 

Method Source Code

//package com.java2s;
/*//  ww  w . j  a  va  2 s.com
 * JFox - The most lightweight Java EE Application Server!
 * more details please visit http://www.huihoo.org/jfox or http://www.jfox.org.cn.
 *
 * JFox is licenced and re-distributable under GNU LGPL.
 */

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static Class[] getAllInterfaces(Class clazz) {
        if (clazz == null) {
            return new Class[0];
        }
        List<Class> classList = new ArrayList<Class>();
        while (clazz != null) {
            Class[] interfaces = clazz.getInterfaces();
            for (Class interf : interfaces) {
                if (!classList.contains(interf)) {
                    classList.add(interf);
                }
                Class[] superInterfaces = getAllInterfaces(interf);
                for (Class superIntf : superInterfaces) {
                    if (!classList.contains(superIntf)) {
                        classList.add(superIntf);
                    }
                }
            }
            clazz = clazz.getSuperclass();
        }
        return classList.toArray(new Class[classList.size()]);
    }
}

Related

  1. addInterfaceName(String name)
  2. equalInterfaces(Object obj1, Object obj2)
  3. getAllClassesAndInterfaces(Class startClass)
  4. getAllInterfaces(Class clazz)
  5. getAllInterfaces(Class clazz)
  6. getAllInterfaces(Class cls)
  7. getAllInterfaces(Class cls)