You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by em...@apache.org on 2020/07/20 14:38:18 UTC

[groovy] branch GROOVY-9420 updated (5b46327 -> 53cc36a)

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

emilles pushed a change to branch GROOVY-9420
in repository https://gitbox.apache.org/repos/asf/groovy.git.


 discard 5b46327  GROOVY-9420: trump getAt(Object,String) with getAt(Map<String,?>,String)
     new 53cc36a  GROOVY-9420: trump getAt(Object,String) with getAt(Map<String,?>,String)

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (5b46327)
            \
             N -- N -- N   refs/heads/GROOVY-9420 (53cc36a)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)


[groovy] 01/01: GROOVY-9420: trump getAt(Object, String) with getAt(Map, String)

Posted by em...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

emilles pushed a commit to branch GROOVY-9420
in repository https://gitbox.apache.org/repos/asf/groovy.git

commit 53cc36a8c27f4d7047df62305eb92c37094b5945
Author: Eric Milles <er...@thomsonreuters.com>
AuthorDate: Sun Jul 19 22:33:59 2020 -0500

    GROOVY-9420: trump getAt(Object,String) with getAt(Map<String,?>,String)
---
 .../groovy/runtime/DefaultGroovyMethods.java       | 37 ++++++++++++++++++++--
 1 file changed, 34 insertions(+), 3 deletions(-)

diff --git a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
index ff84038..5fd95e8 100644
--- a/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
+++ b/src/main/java/org/codehaus/groovy/runtime/DefaultGroovyMethods.java
@@ -7966,12 +7966,17 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
 
     /**
      * Support the subscript operator for a Map.
-     * <pre class="groovyTestCase">def map = [a:10]
-     * assert map["a"] == 10</pre>
+     *
+     * <pre class="groovyTestCase">
+     * def map = [1:10]
+     * assert map[1] == 10
+     * assert map.getAt(1) == 10
+     * </pre>
      *
      * @param self a Map
      * @param key  an Object as a key for the map
      * @return the value corresponding to the given key
+     *
      * @since 1.0
      */
     public static <K,V> V getAt(Map<K,V> self, Object key) {
@@ -7979,6 +7984,25 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
     }
 
     /**
+     * Support the subscript operator for a Map.
+     *
+     * <pre class="groovyTestCase">
+     * def map = [a:10]
+     * assert map['a'] == 10
+     * assert map.getAt('a') == 10
+     * </pre>
+     *
+     * @param self a Map
+     * @param key  a String as a key for the map
+     * @return the value corresponding to the given key
+     *
+     * @since 3.0.6
+     */
+    public static <V> V getAt(Map<String, V> self, String key) {
+        return self.get(key);
+    }
+
+    /**
      * Returns a new <code>Map</code> containing all entries from <code>left</code> and <code>right</code>,
      * giving precedence to <code>right</code>.  Any keys appearing in both Maps
      * will appear in the resultant map with values from the <code>right</code>
@@ -8005,12 +8029,19 @@ public class DefaultGroovyMethods extends DefaultGroovyMethodsSupport {
     }
 
     /**
-     * A helper method to allow maps to work with subscript operators
+     * Support the subscript operator for Map.
+     *
+     * <pre class="groovyTestCase">
+     * def map = [:]
+     * map[1] = 'a'
+     * assert map.get(1) == 'a'
+     * </pre>
      *
      * @param self  a Map
      * @param key   an Object as a key for the map
      * @param value the value to put into the map
      * @return the value corresponding to the given key
+     *
      * @since 1.0
      */
     public static <K,V> V putAt(Map<K,V> self, K key, V value) {