You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2021/04/23 08:20:49 UTC

[groovy] 03/03: GROOVY-10050: Add additional NamedParam annotations in JsonSlurper

This is an automated email from the ASF dual-hosted git repository.

paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 80320e5e164943860f7edfbce6933646ed74b4af
Author: Paul King <pa...@asert.com.au>
AuthorDate: Thu Apr 22 14:10:26 2021 +1000

    GROOVY-10050: Add additional NamedParam annotations in JsonSlurper
---
 .../src/main/java/groovy/json/JsonSlurper.java      | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurper.java b/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurper.java
index b635f47..c325c8e 100644
--- a/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurper.java
+++ b/subprojects/groovy-json/src/main/java/groovy/json/JsonSlurper.java
@@ -18,6 +18,7 @@
  */
 package groovy.json;
 
+import groovy.transform.NamedParam;
 import org.apache.groovy.json.internal.JsonFastParser;
 import org.apache.groovy.json.internal.JsonParserCharArray;
 import org.apache.groovy.json.internal.JsonParserLax;
@@ -419,11 +420,27 @@ public class JsonSlurper {
      * @return a data structure of lists and maps
      * @since 2.2.0
      */
-    public Object parse(Map params, URL url) {
+    public Object parse(
+            @NamedParam(value = "connectTimeout", type = Integer.class)
+            @NamedParam(value = "readTimeout", type = Integer.class)
+            @NamedParam(value = "useCaches", type = Boolean.class)
+            @NamedParam(value = "allowUserInteraction", type = Boolean.class)
+            @NamedParam(value = "requestProperties", type = Map.class)
+            Map<String, ?> params,
+            URL url
+    ) {
         return parseURL(url, params);
     }
 
-    private Object parseURL(URL url, Map params) {
+    private Object parseURL(
+            URL url,
+            @NamedParam(value = "connectTimeout", type = Integer.class)
+            @NamedParam(value = "readTimeout", type = Integer.class)
+            @NamedParam(value = "useCaches", type = Boolean.class)
+            @NamedParam(value = "allowUserInteraction", type = Boolean.class)
+            @NamedParam(value = "requestProperties", type = Map.class)
+            Map<String, ?> params
+    ) {
         Reader reader = null;
         try {
             if (params == null || params.isEmpty()) {