Java Reflection Interface Get getParentAllInterfaces(Class pojoClass)

Here you can find the source of getParentAllInterfaces(Class pojoClass)

Description

get Parent All Interfaces

License

Apache License

Declaration

public static Class[] getParentAllInterfaces(Class pojoClass) 

Method Source Code

//package com.java2s;
/*/*ww  w.j a v a  2s .c  o m*/
 * Copyright 2003-2009 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 * 
 */

import java.util.ArrayList;

import java.util.List;

public class Main {
    public static Class[] getParentAllInterfaces(Class pojoClass) {
        Class[] interfaces = null;
        try {
            List interfacesL = new ArrayList();
            while (pojoClass != null) {
                for (int i = 0; i < pojoClass.getInterfaces().length; i++) {
                    Class ifc = pojoClass.getInterfaces()[i];
                    // not add jdk interface
                    if (!ifc.getName().startsWith("java."))
                        interfacesL.add(ifc);
                }
                pojoClass = pojoClass.getSuperclass();
            }
            if (interfacesL.size() == 0) {
                throw new Exception();
            }
            interfaces = (Class[]) interfacesL.toArray(new Class[interfacesL.size()]);
        } catch (Exception e) {
        }
        return interfaces;
    }
}

Related

  1. getInterfaces(Class clazz)
  2. getInterfaces(final Class type)
  3. getInterfaces(Object owner, String[] interfaceStrings)
  4. getInterfacesForClass(Class type)
  5. getInterfacesList(Class clazz)
  6. getPortNameAndSuffixFromInterfaceName( String intfName)