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

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


The following commit(s) were added to refs/heads/GROOVY_2_5_X by this push:
     new 0202d55  JDK7 tweaks for NamedParam support
0202d55 is described below

commit 0202d5528dcc11f983d1dc3a44871911a6d4f37b
Author: Paul King <pa...@asert.com.au>
AuthorDate: Mon Mar 4 22:03:38 2019 +1000

    JDK7 tweaks for NamedParam support
---
 .../groovy-sql/src/main/java/groovy/sql/Sql.java   | 65 ++++++++++++----------
 1 file changed, 35 insertions(+), 30 deletions(-)

diff --git a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java 
b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
index 8081138..cc521ef 100644
--- a/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
+++ b/subprojects/groovy-sql/src/main/java/groovy/sql/Sql.java
@@ -23,6 +23,7 @@ import groovy.lang.GString;
 import groovy.lang.MissingPropertyException;
 import groovy.lang.Tuple;
 import groovy.transform.NamedParam;
+import groovy.transform.NamedParams;
 import groovy.transform.stc.ClosureParams;
 import groovy.transform.stc.SimpleType;
 import org.codehaus.groovy.runtime.InvokerHelper;
@@ -530,21 +531,23 @@ public class Sql implements AutoCloseable {
      * @throws ClassNotFoundException if the driver class cannot be found or 
loaded
      */
     public static Sql newInstance(
-            @NamedParam(value = "url", type = String.class, required = true)
-            @NamedParam(value = "properties", type = Properties.class)
-            @NamedParam(value = "driverClassName", type = String.class)
-            @NamedParam(value = "driver", type = String.class)
-            @NamedParam(value = "user", type = String.class)
-            @NamedParam(value = "password", type = String.class)
-            @NamedParam(value = "cacheNamedQueries", type = Boolean.class)
-            @NamedParam(value = "cacheStatements", type = Boolean.class)
-            @NamedParam(value = "enableNamedQueries", type = Boolean.class)
-            @NamedParam(value = "resultSetConcurrency", type = Integer.class)
-            @NamedParam(value = "resultSetHoldability", type = Integer.class)
-            @NamedParam(value = "resultSetType", type = Integer.class)
-            // TODO below will be deleted once we fix type checker to 
understand
-            // readonly Map otherwise seen as Map<String, Serializable>
-            @NamedParam(value = "unused", type = Object.class)
+            @NamedParams({
+                    @NamedParam(value = "url", type = String.class, required = 
true),
+                    @NamedParam(value = "properties", type = Properties.class),
+                    @NamedParam(value = "driverClassName", type = 
String.class),
+                    @NamedParam(value = "driver", type = String.class),
+                    @NamedParam(value = "user", type = String.class),
+                    @NamedParam(value = "password", type = String.class),
+                    @NamedParam(value = "cacheNamedQueries", type = 
Boolean.class),
+                    @NamedParam(value = "cacheStatements", type = 
Boolean.class),
+                    @NamedParam(value = "enableNamedQueries", type = 
Boolean.class),
+                    @NamedParam(value = "resultSetConcurrency", type = 
Integer.class),
+                    @NamedParam(value = "resultSetHoldability", type = 
Integer.class),
+                    @NamedParam(value = "resultSetType", type = Integer.class),
+                    // TODO below will be deleted once we fix type checker to 
understand
+                    // readonly Map otherwise seen as Map<String, Serializable>
+                    @NamedParam(value = "unused", type = Object.class)
+            })
             Map<String, Object> args) throws SQLException, 
ClassNotFoundException {
         if (!args.containsKey("url"))
             throw new IllegalArgumentException("Argument 'url' is required");
@@ -616,21 +619,23 @@ public class Sql implements AutoCloseable {
      * @throws ClassNotFoundException if the driver class cannot be found or 
loaded
      */
     public static void withInstance(
-            @NamedParam(value = "url", type = String.class, required = true)
-            @NamedParam(value = "properties", type = Properties.class)
-            @NamedParam(value = "driverClassName", type = String.class)
-            @NamedParam(value = "driver", type = String.class)
-            @NamedParam(value = "user", type = String.class)
-            @NamedParam(value = "password", type = String.class)
-            @NamedParam(value = "cacheNamedQueries", type = Boolean.class)
-            @NamedParam(value = "cacheStatements", type = Boolean.class)
-            @NamedParam(value = "enableNamedQueries", type = Boolean.class)
-            @NamedParam(value = "resultSetConcurrency", type = Integer.class)
-            @NamedParam(value = "resultSetHoldability", type = Integer.class)
-            @NamedParam(value = "resultSetType", type = Integer.class)
-            // TODO below will be deleted once we fix type checker to 
understand
-            // readonly Map otherwise seen as Map<String, Serializable>
-            @NamedParam(value = "unused", type = Object.class)
+            @NamedParams({
+                    @NamedParam(value = "url", type = String.class, required = 
true),
+                    @NamedParam(value = "properties", type = Properties.class),
+                    @NamedParam(value = "driverClassName", type = 
String.class),
+                    @NamedParam(value = "driver", type = String.class),
+                    @NamedParam(value = "user", type = String.class),
+                    @NamedParam(value = "password", type = String.class),
+                    @NamedParam(value = "cacheNamedQueries", type = 
Boolean.class),
+                    @NamedParam(value = "cacheStatements", type = 
Boolean.class),
+                    @NamedParam(value = "enableNamedQueries", type = 
Boolean.class),
+                    @NamedParam(value = "resultSetConcurrency", type = 
Integer.class),
+                    @NamedParam(value = "resultSetHoldability", type = 
Integer.class),
+                    @NamedParam(value = "resultSetType", type = Integer.class),
+                    // TODO below will be deleted once we fix type checker to 
understand
+                    // readonly Map otherwise seen as Map<String, Serializable>
+                    @NamedParam(value = "unused", type = Object.class)
+            })
             Map<String, Object> args,
             Closure c) throws SQLException, ClassNotFoundException {
         try (Sql sql = newInstance(args)) {

Reply via email to