You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2017/12/14 20:25:06 UTC

svn commit: r1818208 - /pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java

Author: rwhitcomb
Date: Thu Dec 14 20:25:06 2017
New Revision: 1818208

URL: http://svn.apache.org/viewvc?rev=1818208&view=rev
Log:
Add a static "allOf" method to EnumSet that constructs a fully-populated
set containing all the values of the backing enum.

Modified:
    pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java

Modified: pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java?rev=1818208&r1=1818207&r2=1818208&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/collections/EnumSet.java Thu Dec 14 20:25:06 2017
@@ -177,6 +177,22 @@ public class EnumSet<E extends Enum<E>>
     }
 
     /**
+     * Creates an enum set initially containing all the elements of the backing enum.
+     *
+     * @param <E> The enum type of the set.
+     * @param elementClass The class of the individual elements to be used
+     * in this set.
+     * @return The new complete set.
+     */
+    public static <E extends Enum<E>> EnumSet<E> allOf(Class<E> elementClass) {
+        EnumSet<E> set = new EnumSet<E>(elementClass);
+        for (E e : elementClass.getEnumConstants()) {
+            set.add(e);
+        }
+        return set;
+    }
+
+    /**
      * Creates an enum set containing the given element.
      *
      * @param <E> The enum type of the set.