集册 Java实例教程 获取所有接口

获取所有接口

欢马劈雪     最近更新时间:2020-01-02 10:19:05

521
获取所有接口


import java.lang.reflect.Array;

import java.lang.reflect.Constructor;

import java.lang.reflect.Method;//来 自 时代Java

import java.lang.reflect.Modifier;

import java.net.URL;

import java.util.Collections;

import java.util.Iterator;

import java.util.List;

import java.util.Map;

import java.util.Set;

import java.util.WeakHashMap;


public class Main{

    public static void main(String[] argv) throws Exception{

        Class clazz = String.class;
        /* from 
        N o w J a v a . c o m - 时代Java*/

        System.out.println(getAllInterfaces(clazz));

    }

    public static List<Class<?>> getAllInterfaces(Class<?> clazz) {

        if (clazz == null) {

            return null;

        }


        List<Class<?>> interfacesFound = CollectionUtil.createArrayList();

        getAllInterfaces(clazz, interfacesFound);


        return interfacesFound;

    }

    private static void getAllInterfaces(Class<?> clazz,

            List<Class<?>> interfacesFound) {

        while (clazz != null) {

            Class<?>[] interfaces = clazz.getInterfaces();


            for (
展开阅读全文