public boolean validate(Class<?> resultClass) {
        // 查找：已经注册的类
        if (mapping.containsKey(resultClass)) {
            return true;
        }
        // 查找：用 annotation 标注，但是没有注册的 ResultHandler
        ManagedWith with = resultClass.getAnnotation(ManagedWith.class);
        if (with != null && ResultHandler.class.isAssignableFrom(with.value())) {
            register(resultClass, with.value()); // 发现后注册
            return true;
        }
        // 查找：使用了已经注册的类的子类
        for (Map.Entry<Class<?>, ResultHandler<?>> entry : mapping.entrySet()) {
            Class<?> targetClass = entry.getKey();
            if (targetClass != Object.class && targetClass.isAssignableFrom(resultClass)) {
                mapping.put(resultClass, entry.getValue()); // 发现后关联
                return true;
            }
        }
        return false;
    }
public boolean validate ( Class < ? > resultClass ) { if ( mapping . containsKey ( resultClass ) ) { return true ; } ManagedWith with = resultClass . getAnnotation ( ManagedWith . class ) ; if ( with != null && ResultHandler . class . isAssignableFrom ( with . value ( ) ) ) { register ( resultClass , with . value ( ) ) ; return true ; } for ( Map . Entry < Class < ? > , ResultHandler < ? > > entry : mapping . entrySet ( ) ) { Class < ? > targetClass = entry . getKey ( ) ; if ( targetClass != Object . class && targetClass . isAssignableFrom ( resultClass ) ) { mapping . put ( resultClass , entry . getValue ( ) ) ; return true ; } } return false ; }
是否支持该 resultClass