Expand known immutables 49/15849/1
authorRobert Varga <rovarga@cisco.com>
Sat, 28 Feb 2015 09:00:23 +0000 (10:00 +0100)
committerRobert Varga <rovarga@cisco.com>
Sat, 28 Feb 2015 20:48:57 +0000 (21:48 +0100)
Void and Boolean are immutable types, too. Also use ImmutableSet instead
of a hown-grown utility.

Change-Id: I63bddcfe5a8538065378a2259bf8bdc58f76d620
Signed-off-by: Robert Varga <rovarga@cisco.com>
common/util/src/main/java/org/opendaylight/yangtools/util/Immutables.java

index e10977b6de01ecd0c2254a0fd1c263f4088e8aac..4ec7c5f917b46813dea363f314fa6af7078e2ded 100644 (file)
@@ -7,12 +7,10 @@
  */
 package org.opendaylight.yangtools.util;
 
+import com.google.common.collect.ImmutableSet;
 import java.math.BigDecimal;
 import java.math.BigInteger;
-import java.util.Collections;
-import java.util.HashSet;
 import java.util.Set;
-
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.concepts.Mutable;
 
@@ -22,10 +20,9 @@ public final class Immutables {
         throw new UnsupportedOperationException("Helper class");
     }
 
-    public static final Set<Class<?>> KNOWN_IMMUTABLES = Immutables.<Class<?>> asHashSet(
-            //
+    public static final Set<Class<?>> KNOWN_IMMUTABLES = ImmutableSet.<Class<?>>of(
             Integer.class, Short.class, BigDecimal.class, BigInteger.class, Byte.class, Character.class, Double.class,
-            Float.class, String.class);
+            Float.class, String.class, Boolean.class, Void.class);
 
     /**
      * Determines if object is known to be immutable
@@ -52,13 +49,4 @@ public final class Immutables {
         }
         return false;
     }
-
-    @SafeVarargs
-    private static <E> Set<E> asHashSet(final E... list) {
-        HashSet<E> ret = new HashSet<>();
-        for (E e : list) {
-            ret.add(e);
-        }
-        return Collections.unmodifiableSet(ret);
-    }
 }