Java Utililty Methods Reflection Interface Get

List of utility methods to do Reflection Interface Get

Description

The list of methods to do Reflection Interface Get are organized into topic(s).

Method

List>getAllInterfaces(Class clazz)
Returns the set of interfaces implemented by the given class and its ancestors or a blank set if none
List<Class<?>> implemented = new ArrayList<Class<?>>();
getAllInterfaces(clazz, implemented);
return implemented;
Class[]getAllInterfaces(Class clazz)
get All Interfaces
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]);
    superClass = superClass.getSuperclass();
return allInterfaces.toArray(new Class<?>[allInterfaces.size()]);
List>getAllInterfaces(Class cls)
get All Interfaces
if (cls == null) {
    return null;
List<Class<?>> list = new ArrayList<Class<?>>();
while (cls != null) {
    Class[] interfaces = cls.getInterfaces();
    for (int i = 0; i < interfaces.length; i++) {
        if (!list.contains(interfaces[i])) {
...
List>getAllInterfaces(Class cls)
Gets a List of all interfaces implemented by the given class and its super-classes.
if (cls == null) {
    return null;
final List<Class<?>> list = new ArrayList<Class<?>>();
while (cls != null) {
    final Class<?>[] interfaces = cls.getInterfaces();
    for (final Class<?> interface1 : interfaces) {
        if (list.contains(interface1) == false) {
...
List>getAllInterfaces(Class type)
get All Interfaces
List<Class<?>> allInterfaces = new ArrayList<Class<?>>();
if (!type.isInterface()) {
    Class<?> superclass = type.getSuperclass();
    if (superclass != null) {
        List<Class<?>> superIfs = getAllInterfaces(superclass);
        for (Class<?> superIf : superIfs) {
            if (!allInterfaces.contains(superIf)) {
                allInterfaces.add(superIf);
...
Class[]getAllInterfaces(Object object)
Return all interfaces that the given object implements as array, including ones implemented by superclasses.
List interfaces = getAllInterfacesAsList(object);
return (Class[]) interfaces.toArray(new Class[interfaces.size()]);
voidgetAllInterfaces(Set> searchInterfaces, Class clazz)
Recursively finds all the interfaces.
while (clazz != null) {
    searchInterfaces.addAll(Arrays.asList(clazz.getInterfaces()));
    for (Class<?> intf : clazz.getInterfaces()) {
        getAllInterfaces(searchInterfaces, intf);
    clazz = clazz.getSuperclass();
Class[]getAllInterfacesForClass(Class clazz)
Return all interfaces that the given class implements as array, including ones implemented by superclasses.
return getAllInterfacesForClass(clazz, null);
ListgetAllInterfacesNames(Class aClass)
get All Interfaces Names
return toString(getAllInterfaces(aClass));
List>getClassHierarchy(Class c, boolean includeInterfaces)
get Class Hierarchy
List<Class<?>> classes = new ArrayList<Class<?>>();
while (c != Object.class) {
    classes.add(c);
    if (includeInterfaces) {
        Class<?>[] interfaces = c.getInterfaces();
        for (Class<?> i : interfaces) {
            classes.add(i);
    c = c.getSuperclass();
    if (c == null) {
        break;
return classes;