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

StringaddInterfaceName(String name)
add Interface Name
interfaceNames.add(name);
return null;
booleanequalInterfaces(Object obj1, Object obj2)
Returns true if the interfaces implemented by obj1's class are the same (and in the same order) as obj2's class.
if (obj1 == obj2) {
    return true;
if ((obj1 == null || obj2 == null) && obj1 != obj2) {
    return false;
Class[] intf1 = getAllInterfaces(obj1);
Class[] intf2 = getAllInterfaces(obj2);
...
ListgetAllClassesAndInterfaces(Class startClass)
Find all super classes and implemented interfaces for the given class.
ArrayList classes = new ArrayList();
addClassesAndInterfaces(startClass, classes);
return classes;
Class[]getAllInterfaces(Class clazz)
get All Interfaces
if (clazz == null) {
    return new Class[0];
List<Class> classList = new ArrayList<Class>();
while (clazz != null) {
    Class[] interfaces = clazz.getInterfaces();
    for (Class interf : interfaces) {
        if (!classList.contains(interf)) {
...
Class[]getAllInterfaces(Class clazz)
Returns all of the interfaces implemented by a class.
ArrayList result = new ArrayList();
getAllInterfaces(clazz, result);
return (Class[]) result.toArray(new Class[0]);
ListgetAllInterfaces(Class clazz)
get All Interfaces
return getAllInterfaces(clazz, new ArrayList<Class>());
ListgetAllInterfaces(Class cls)

Gets a List of all interfaces implemented by the given class and its superclasses.

The order is determined by looking through each interface in turn as declared in the source file and following its hierarchy up.

if (cls == null) {
    return null;
List interfacesFound = new ArrayList();
getAllInterfaces(cls, interfacesFound);
return interfacesFound;
ListgetAllInterfaces(Class cls)

Gets a List of all interfaces implemented by the given class and its superclasses.

The order is determined by looking through each interface in turn as declared in the source file and following its hierarchy up.

if (cls == null)
    return null;
List list = new ArrayList();
while (cls != null) {
    Class[] interfaces = cls.getInterfaces();
    for (int i = 0; i < interfaces.length; i++) {
        if (list.contains(interfaces[i]) == false) {
            list.add(interfaces[i]);
...
List>getAllInterfaces(Class base)
get All Interfaces
List<Class<?>> classes = new ArrayList<>();
Class<?>[] interfaces = base.getInterfaces();
for (Class<?> anInterface : interfaces) {
    classes.add(anInterface);
    classes.addAll(getAllInterfaces(anInterface));
return classes;
Class[]getAllInterfaces(Class clazz)
get All Interfaces
HashSet<Class<?>> interfaces = new HashSet<>();
getAllInterfaces(clazz, interfaces);
return interfaces.toArray(new Class<?>[interfaces.size()]);