接口定义

public interface RequestEntityResolverAdvice {

    /**
     * This method will be called around
     * {@link RequestEntityResolver#readFrom(RequestEntity, RequestContext)}.
     *
     * @param context context
     * @return object   resolved value
     * @throws Exception exception
     */
    Object aroundRead(RequestEntityResolverContext context) throws Exception;

}

自定义RequestEntityResolverAdvice

RequestEntityResolver相同,RequestEntityResolverAdvice自定应时同样需要实现RequestEntityResolverAdviceAdapterRequestEntityResolverAdviceFactory接口

方式1 实现RequestEntityResolverAdviceAdapter

接口定义

public interface RequestEntityResolverAdviceAdapter extends RequestEntityResolverAdvice,
        ParamPredicate, Ordered {

    @Override
    default boolean supports(Param param) {
        return true;
    }

    @Override
    default int getOrder() {
        return Ordered.HIGHEST_PRECEDENCE;
    }
}


方式2:实现RequestEntityResolverAdviceFactory

接口定义

public interface RequestEntityResolverAdviceFactory extends ParamPredicate, Ordered {
    /**
     * 生成RequestEntityResolverAdvice
     */
    RequestEntityResolverAdvice createResolverAdvice(Param param);

    @Override
    default int getOrder() {
        return HIGHEST_PRECEDENCE;
    }
}

RequestEntityResolverAdviceAdapter接口以及RequestEntityResolverAdviceFactory接口与RequestEntityResolver中的RequestEntityResolverAdapter接口以及RequestEntityResolverFactory接口的使用方式相同,这里不过多赘述。