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 final Class<?>[] getAllInterfaces(Class<?> clazz) 

Method Source Code


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

import java.util.ArrayList;
import java.util.List;

public class Main {
    public static final Class<?>[] getAllInterfaces(Class<?> clazz) {
        List<Class<?>> allInterfaces = new ArrayList<>();
        Class<?> superClass = clazz;

        while (superClass != null) {
            Class<?>[] interfaces = superClass.getInterfaces();

            if (interfaces != null && interfaces.length > 0) {
                for (int index = 0; index < interfaces.length; index++) {
                    allInterfaces.add(interfaces[index]);
                }/*  www.java  2 s  .  c o m*/
            }

            superClass = superClass.getSuperclass();
        }

        return allInterfaces.toArray(new Class<?>[allInterfaces.size()]);
    }
}

Related

  1. getAllInterfaces(Class cls)
  2. getAllInterfaces(Class cls)
  3. getAllInterfaces(Class base)
  4. getAllInterfaces(Class clazz)
  5. getAllInterfaces(Class clazz)
  6. getAllInterfaces(Class cls)
  7. getAllInterfaces(Class cls)
  8. getAllInterfaces(Class type)
  9. getAllInterfaces(Object object)