private static Object delegateChains(final Class<?> type) {
        final ReturnsEmptyValues returnsEmptyValues = new ReturnsEmptyValues();
        Object result = returnsEmptyValues.returnValueFor(type);

        if (result == null) {
            Class<?> emptyValueForClass = type;
            while (emptyValueForClass != null && result == null) {
                final Class<?>[] classes = emptyValueForClass.getInterfaces();
                for (Class<?> clazz : classes) {
                    result = returnsEmptyValues.returnValueFor(clazz);
                    if (result != null) {
                        break;
                    }
                }
                emptyValueForClass = emptyValueForClass.getSuperclass();
            }
        }

        if (result == null) {
            result = new ReturnsMoreEmptyValues().returnValueFor(type);
        }

        return result;
    }
private static Object delegateChains ( final Class < ? > type ) { final ReturnsEmptyValues returnsEmptyValues = new ReturnsEmptyValues ( ) ; Object result = returnsEmptyValues . returnValueFor ( type ) ; if ( result == null ) { Class < ? > emptyValueForClass = type ; while ( emptyValueForClass != null && result == null ) { final Class < ? > [ ] classes = emptyValueForClass . getInterfaces ( ) ; for ( Class < ? > clazz : classes ) { result = returnsEmptyValues . returnValueFor ( clazz ) ; if ( result != null ) { break ; } } emptyValueForClass = emptyValueForClass . getSuperclass ( ) ; } } if ( result == null ) { result = new ReturnsMoreEmptyValues ( ) . returnValueFor ( type ) ; } return result ; }
Try to resolve the result value using {@link ReturnsEmptyValues} and {@link ReturnsMoreEmptyValues}.

This will try to use all parent class (superclass & interfaces) to retrieve the value..

@param type the return type of the method
@return a non-null instance if the type has been resolve. Null otherwise.