Java Reflection Interface Get getAllInterfaces(Class clazz)

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

Description

get All Interfaces

License

Mozilla Public License

Declaration

public static List<Class> getAllInterfaces(Class clazz) 

Method Source Code

//package com.java2s;
/******************************************************************************
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0.  If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/.
 * //from  w  ww  . j a va 2 s  . co m
 * Software distributed under the License is distributed on an "AS IS" basis, 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for 
 * the specific language governing rights and limitations under the License.
 *
 * The Original Code is: Jsoda
 * The Initial Developer of the Original Code is: William Wong (williamw520@gmail.com)
 * Portions created by William Wong are Copyright (C) 2012 William Wong, All Rights Reserved.
 *
 ******************************************************************************/

import java.util.*;

public class Main {
    public static List<Class> getAllInterfaces(Class clazz) {
        return getAllInterfaces(clazz, new ArrayList<Class>());
    }

    private static List<Class> getAllInterfaces(Class clazz, List<Class> list) {
        for (Class intf : clazz.getInterfaces()) {
            list.add(intf);
        }
        Class superClazz = clazz.getSuperclass();
        if (superClazz != null)
            getAllInterfaces(superClazz, list);
        return list;
    }
}

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)
  8. getAllInterfaces(Class base)
  9. getAllInterfaces(Class clazz)