public static ClassNode getNextSuperClass(ClassNode clazz, ClassNode goalClazz) {
        if (clazz.isArray()) {
            if (!goalClazz.isArray()) return null;
            ClassNode cn = getNextSuperClass(clazz.getComponentType(), goalClazz.getComponentType());
            if (cn != null) cn = cn.makeArray();
            return cn;
        }

        if (!goalClazz.isInterface()) {
            if (clazz.isInterface()) {
                if (OBJECT_TYPE.equals(clazz)) return null;
                return OBJECT_TYPE;
            } else {
                return clazz.getUnresolvedSuperClass();
            }
        }

        ClassNode[] interfaces = clazz.getUnresolvedInterfaces();
        for (ClassNode anInterface : interfaces) {
            if (StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(anInterface, goalClazz)) {
                return anInterface;
            }
        }
        //none of the interfaces here match, so continue with super class
        return clazz.getUnresolvedSuperClass();
    }
public static ClassNode getNextSuperClass ( ClassNode clazz , ClassNode goalClazz ) { if ( clazz . isArray ( ) ) { if ( ! goalClazz . isArray ( ) ) return null ; ClassNode cn = getNextSuperClass ( clazz . getComponentType ( ) , goalClazz . getComponentType ( ) ) ; if ( cn != null ) cn = cn . makeArray ( ) ; return cn ; } if ( ! goalClazz . isInterface ( ) ) { if ( clazz . isInterface ( ) ) { if ( OBJECT_TYPE . equals ( clazz ) ) return null ; return OBJECT_TYPE ; } else { return clazz . getUnresolvedSuperClass ( ) ; } } ClassNode [ ] interfaces = clazz . getUnresolvedInterfaces ( ) ; for ( ClassNode anInterface : interfaces ) { if ( StaticTypeCheckingSupport . implementsInterfaceOrIsSubclassOf ( anInterface , goalClazz ) ) { return anInterface ; } } return clazz . getUnresolvedSuperClass ( ) ; }
Returns a super class or interface for a given class depending on a given target.
If the target is no super class or interface, then null will be returned.
For a non-primitive array type, returns an array of the componentType's super class
or interface if the target is also an array.

@param clazz     the start class
@param goalClazz the goal class
@return the next super class or interface