From 08da23b3d4de0e79f85c4e876aa900e96c6d51b2 Mon Sep 17 00:00:00 2001 From: Looly Date: Sat, 16 Apr 2022 12:05:50 +0800 Subject: [PATCH] fix doc --- .../java/cn/hutool/http/GlobalInterceptor.java | 2 ++ .../main/java/cn/hutool/http/HttpConfig.java | 3 +++ .../main/java/cn/hutool/json/JSONObject.java | 18 ++++++++++-------- .../main/java/cn/hutool/json/JSONParser.java | 6 ++++-- 4 files changed, 19 insertions(+), 10 deletions(-) diff --git a/hutool-http/src/main/java/cn/hutool/http/GlobalInterceptor.java b/hutool-http/src/main/java/cn/hutool/http/GlobalInterceptor.java index 98def3fc2..52ccc3ba4 100644 --- a/hutool-http/src/main/java/cn/hutool/http/GlobalInterceptor.java +++ b/hutool-http/src/main/java/cn/hutool/http/GlobalInterceptor.java @@ -17,6 +17,7 @@ public enum GlobalInterceptor { * 设置拦截器,用于在请求前重新编辑请求 * * @param interceptor 拦截器实现 + * @return this */ synchronized public GlobalInterceptor addRequestInterceptor(HttpInterceptor interceptor) { this.requestInterceptors.addChain(interceptor); @@ -27,6 +28,7 @@ public enum GlobalInterceptor { * 设置拦截器,用于在响应读取后完成编辑或读取 * * @param interceptor 拦截器实现 + * @return this */ synchronized public GlobalInterceptor addResponseInterceptor(HttpInterceptor interceptor) { this.responseInterceptors.addChain(interceptor); diff --git a/hutool-http/src/main/java/cn/hutool/http/HttpConfig.java b/hutool-http/src/main/java/cn/hutool/http/HttpConfig.java index 9b289f7ed..8ca0d643b 100755 --- a/hutool-http/src/main/java/cn/hutool/http/HttpConfig.java +++ b/hutool-http/src/main/java/cn/hutool/http/HttpConfig.java @@ -244,6 +244,7 @@ public class HttpConfig { * 如果服务端未遵循这个规范或响应没有正常结束,会报EOF异常,此选项用于是否忽略这个异常。 * * @param ignoreEOFError 是否忽略响应读取时可能的EOF异常。 + * @return this * @since 5.7.20 */ public HttpConfig setIgnoreEOFError(boolean ignoreEOFError) { @@ -257,6 +258,7 @@ public class HttpConfig { * 按照RFC3986规范,在发送请求时,全部编码之。如果为{@code false},则不会解码已经编码的内容,在请求时只编码需要编码的部分。 * * @param decodeUrl 是否忽略解码URL + * @return this */ public HttpConfig setDecodeUrl(boolean decodeUrl) { this.decodeUrl = decodeUrl; @@ -267,6 +269,7 @@ public class HttpConfig { * 设置拦截器,用于在请求前重新编辑请求 * * @param interceptor 拦截器实现 + * @return this */ public HttpConfig addRequestInterceptor(HttpInterceptor interceptor) { this.requestInterceptors.addChain(interceptor); diff --git a/hutool-json/src/main/java/cn/hutool/json/JSONObject.java b/hutool-json/src/main/java/cn/hutool/json/JSONObject.java index 55d0e4693..53b7deb26 100644 --- a/hutool-json/src/main/java/cn/hutool/json/JSONObject.java +++ b/hutool-json/src/main/java/cn/hutool/json/JSONObject.java @@ -369,9 +369,10 @@ public class JSONObject extends MapWrapper implements JSON, JSON /** * 设置键值对到JSONObject中,在忽略null模式下,如果值为{@code null},将此键移除 * - * @param key 键 - * @param value 值对象. 可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL. - * @param filter 键值对过滤编辑器,可以通过实现此接口,完成解析前对键值对的过滤和修改操作,{@code null}表示不过滤 + * @param key 键 + * @param value 值对象. 可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL. + * @param filter 键值对过滤编辑器,可以通过实现此接口,完成解析前对键值对的过滤和修改操作,{@code null}表示不过滤 + * @param checkDuplicate 是否检查重复键,如果为{@code true},则出现重复键时抛出{@link JSONException}异常 * @return this. * @throws JSONException 值是无穷数字抛出此异常 * @since 5.8.0 @@ -388,7 +389,7 @@ public class JSONObject extends MapWrapper implements JSON, JSON // 使用修改后的键值对 key = pair.getKey(); value = pair.getValue(); - }else{ + } else { // 键值对被过滤 return this; } @@ -399,7 +400,7 @@ public class JSONObject extends MapWrapper implements JSON, JSON // 忽略值模式下如果值为空清除key this.remove(key); } else { - if(checkDuplicate && containsKey(key)){ + if (checkDuplicate && containsKey(key)) { throw new JSONException("Duplicate key \"{}\"", key); } @@ -423,9 +424,10 @@ public class JSONObject extends MapWrapper implements JSON, JSON /** * 一次性Put 键值对,如果key已经存在抛出异常,如果键值中有null值,忽略 * - * @param key 键 - * @param value 值对象,可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL. - * @return this. + * @param key 键 + * @param value 值对象,可以是以下类型: Boolean, Double, Integer, JSONArray, JSONObject, Long, String, or the JSONNull.NULL. + * @param filter 键值对过滤编辑器,可以通过实现此接口,完成解析前对键值对的过滤和修改操作,{@code null}表示不过滤 + * @return this * @throws JSONException 值是无穷数字、键重复抛出异常 * @since 5.8.0 */ diff --git a/hutool-json/src/main/java/cn/hutool/json/JSONParser.java b/hutool-json/src/main/java/cn/hutool/json/JSONParser.java index 8fd6b8388..584de206d 100755 --- a/hutool-json/src/main/java/cn/hutool/json/JSONParser.java +++ b/hutool-json/src/main/java/cn/hutool/json/JSONParser.java @@ -34,11 +34,12 @@ public class JSONParser { } // region parseTo + /** * 解析{@link JSONTokener}中的字符到目标的{@link JSONObject}中 * * @param jsonObject {@link JSONObject} - * @param filter 键值对过滤编辑器,可以通过实现此接口,完成解析前对键值对的过滤和修改操作,{@code null}表示不过滤 + * @param filter 键值对过滤编辑器,可以通过实现此接口,完成解析前对键值对的过滤和修改操作,{@code null}表示不过滤 */ public void parseTo(JSONObject jsonObject, Filter> filter) { final JSONTokener tokener = this.tokener; @@ -91,7 +92,8 @@ public class JSONParser { /** * 解析JSON字符串到{@link JSONArray}中 * - * @param jsonArray {@link JSONArray} + * @param jsonArray {@link JSONArray + * @param filter 键值对过滤编辑器,可以通过实现此接口,完成解析前对值的过滤和修改操作,{@code null}表示不过滤 */ public void parseTo(JSONArray jsonArray, Filter> filter) { final JSONTokener x = this.tokener;