ResponseHandlerFactory.java 文件源码

java
阅读 26 收藏 0 点赞 0 评论 0

项目:LiquidDonkey 作者:
/**
 * Returns an entity to function result response handler.
 *
 * @param <R> the function return type, not null
 * @param function the function to apply to the response entity, not null
 * @return an entity to function result response handler, not null
 */
public static <R> ResponseHandler<R> of(IOFunction<InputStream, R> function) {
    Objects.requireNonNull(function);

    return new AbstractResponseHandler<R>() {

        @Override
        public R handleEntity(HttpEntity entity) throws IOException {
            try (InputStream inputStream = entity.getContent()) {
                return function.apply(inputStream);
            }
        }
    };
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号