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 2020/12/18 02:04:28 UTC

[groovy] branch master updated: remove deprecated methods and tidy up

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


The following commit(s) were added to refs/heads/master by this push:
     new 3eb59a2  remove deprecated methods and tidy up
3eb59a2 is described below

commit 3eb59a2064a91af6e23f296c7766034ae2d18192
Author: Paul King <pa...@asert.com.au>
AuthorDate: Fri Dec 18 12:04:17 2020 +1000

    remove deprecated methods and tidy up
---
 src/main/java/groovy/util/GroovyCollections.java | 56 +++++-------------------
 1 file changed, 11 insertions(+), 45 deletions(-)

diff --git a/src/main/java/groovy/util/GroovyCollections.java b/src/main/java/groovy/util/GroovyCollections.java
index e70230c..05e2f67 100644
--- a/src/main/java/groovy/util/GroovyCollections.java
+++ b/src/main/java/groovy/util/GroovyCollections.java
@@ -24,7 +24,6 @@ import org.codehaus.groovy.runtime.typehandling.DefaultTypeTransformation;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
@@ -38,10 +37,10 @@ public class GroovyCollections {
      *
      * @param collections the given collections
      * @return a List of the combinations found
-     * @see #combinations(Collection)
+     * @see #combinations(Iterable)
      */
     public static List combinations(Object[] collections) {
-        return combinations((Iterable)Arrays.asList(collections));
+        return combinations(Arrays.asList(collections));
     }
 
     /**
@@ -54,16 +53,16 @@ public class GroovyCollections {
      */
     public static <T> Set<List<T>> subsequences(List<T> items) {
         // items.inject([]){ ss, h -> ss.collect { it + [h] }  + ss + [[h]] }
-        Set<List<T>> ans = new HashSet<List<T>>();
+        Set<List<T>> ans = new HashSet<>();
         for (T h : items) {
-            Set<List<T>> next = new HashSet<List<T>>();
+            Set<List<T>> next = new HashSet<>();
             for (List<T> it : ans) {
-                List<T> sublist = new ArrayList<T>(it);
+                List<T> sublist = new ArrayList<>(it);
                 sublist.add(h);
                 next.add(sublist);
             }
             next.addAll(ans);
-            List<T> hlist = new ArrayList<T>();
+            List<T> hlist = new ArrayList<>();
             hlist.add(h);
             next.add(hlist);
             ans = next;
@@ -72,15 +71,6 @@ public class GroovyCollections {
     }
 
     /**
-     * @param collections the given collections
-     * @deprecated use combinations(Iterable)
-     */
-    @Deprecated
-    public static List combinations(Collection collections) {
-        return combinations((Iterable)collections);
-    }
-
-    /**
      * Finds all combinations of items from the given Iterable aggregate of collections.
      * So, <code>combinations([[true, false], [true, false]])</code>
      * is <code>[[true, true], [false, true], [true, false], [false, false]]</code>
@@ -125,7 +115,7 @@ public class GroovyCollections {
 
     public static <T> List<List<T>> inits(Iterable<T> collections) {
         List<T> copy = DefaultGroovyMethods.toList(collections);
-        List<List<T>> result = new ArrayList<List<T>>();
+        List<List<T>> result = new ArrayList<>();
         for (int i = copy.size(); i >= 0; i--) {
             List<T> next = copy.subList(0, i);
             result.add(next);
@@ -135,7 +125,7 @@ public class GroovyCollections {
 
     public static <T> List<List<T>> tails(Iterable<T> collections) {
         List<T> copy = DefaultGroovyMethods.toList(collections);
-        List<List<T>> result = new ArrayList<List<T>>();
+        List<List<T>> result = new ArrayList<>();
         for (int i = 0; i <= copy.size(); i++) {
             List<T> next = copy.subList(i, copy.size());
             result.add(next);
@@ -194,15 +184,7 @@ public class GroovyCollections {
      * @return the minimum value
      */
     public static <T> T min(T[] items) {
-        return min((Iterable<T>)Arrays.asList(items));
-    }
-
-    /**
-     * @deprecated use min(Iterable)
-     */
-    @Deprecated
-    public static <T> T min(Collection<T> items) {
-        return min((Iterable<T>)items);
+        return min(Arrays.asList(items));
     }
 
     /**
@@ -232,15 +214,7 @@ public class GroovyCollections {
      * @return the maximum value
      */
     public static <T> T max(T[] items) {
-        return max((Iterable<T>)Arrays.asList(items));
-    }
-
-    /**
-     * @deprecated use max(Iterable)
-     */
-    @Deprecated
-    public static <T> T max(Collection<T> items) {
-        return max((Iterable<T>)items);
+        return max(Arrays.asList(items));
     }
 
     /**
@@ -269,15 +243,7 @@ public class GroovyCollections {
      * @return the sum of the items
      */
     public static Object sum(Object[] items) {
-        return sum((Iterable)Arrays.asList(items));
-    }
-
-    /**
-     * @deprecated use sum(Iterable)
-     */
-    @Deprecated
-    public static Object sum(Collection items) {
-        return sum((Iterable)items);
+        return sum(Arrays.asList(items));
     }
 
     /**