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 2017/11/13 02:44:40 UTC

[5/5] groovy git commit: GROOVY-8376: Add @DelegatesTo/@ClosureParams for DGM#identity (closes #632)

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/412c6441
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/412c6441
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/412c6441

Branch: refs/heads/GROOVY_2_6_X
Commit: 412c6441cdfadb39847e36cbb369d900f950a9dd
Parents: 699d75c
Author: paulk <pa...@asert.com.au>
Authored: Mon Nov 13 10:57:11 2017 +1000
Committer: paulk <pa...@asert.com.au>
Committed: Mon Nov 13 12:44:08 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/412c6441/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">