groovy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject [2/2] groovy git commit: GROOVY-8376: Add @DelegatesTo/@ClosureParams for DGM#identity (closes #632)
Date Mon, 13 Nov 2017 02:41:03 GMT
GROOVY-8376: Add @DelegatesTo/@ClosureParams for DGM#identity (closes #632)


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/eedc6bfc
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/eedc6bfc
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/eedc6bfc

Branch: refs/heads/master
Commit: eedc6bfcd134749e7d76b05031dfbd914cec2d6e
Parents: d6f3c93
Author: paulk <paulk@asert.com.au>
Authored: Mon Nov 13 10:57:11 2017 +1000
Committer: paulk <paulk@asert.com.au>
Committed: Mon Nov 13 10:58:13 2017 +1000

----------------------------------------------------------------------
 .../codehaus/groovy/runtime/DefaultGroovyMethods.java    | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/eedc6bfc/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
----------------------------------------------------------------------
diff --git a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index 1df7be1..eec02af 100644
--- a/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -256,9 +256,16 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport
{
      * @param self    the object to have a closure act upon
      * @param closure the closure to call on the object
      * @return result of calling the closure
+     * @see #with(Object, Closure)
      * @since 1.0
      */
-    public static <T> T identity(Object self, Closure<T> closure) {
+    public static <T,U> T identity(
+            @DelegatesTo.Target("self") U self,
+            @DelegatesTo(value=DelegatesTo.Target.class,
+                    target="self",
+                    strategy=Closure.DELEGATE_FIRST)
+            @ClosureParams(FirstParam.class)
+                    Closure<T> closure) {
         return DefaultGroovyMethods.with(self, closure);
     }
 
@@ -311,7 +318,7 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport
{
      * Allows the closure to be called for the object reference self.
      * <p/>
      * Any method invoked inside the closure will first be invoked on the
-     * self reference. For exampe, the following method calls to the append()
+     * self reference. For example, the following method calls to the append()
      * method are invoked on the StringBuilder instance and then, because
      * 'returning' is true, the self instance is returned:
      * <pre class="groovyTestCase">


Mime
View raw message