static List<Class<?>> getExtendedAndImplementedTypes(Class<?> clazz, List<Class<?>> hierarchy) {
        hierarchy.add(clazz);
        Class<?> superClass = clazz.getSuperclass();
        if (superClass != null) {
            hierarchy = getExtendedAndImplementedTypes(superClass, hierarchy);
        }
        for (Class<?> implementedInterface : clazz.getInterfaces()) {
            hierarchy = getExtendedAndImplementedTypes(implementedInterface, hierarchy);
        }
        return hierarchy;
    }
static List < Class < ? > > getExtendedAndImplementedTypes ( Class < ? > clazz , List < Class < ? > > hierarchy ) { hierarchy . add ( clazz ) ; Class < ? > superClass = clazz . getSuperclass ( ) ; if ( superClass != null ) { hierarchy = getExtendedAndImplementedTypes ( superClass , hierarchy ) ; } for ( Class < ? > implementedInterface : clazz . getInterfaces ( ) ) { hierarchy = getExtendedAndImplementedTypes ( implementedInterface , hierarchy ) ; } return hierarchy ; }
Gets all classes and interfaces in the class hierarchy of the given class including
the class itself.

@param clazz The class
@param hierarchy The current list of all classes and interfaces found so far
@return All classes and interfaces in the class's hierarchy