Add String to known-immutable classes 44/9344/1
authorRobert Varga <rovarga@cisco.com>
Sat, 26 Jul 2014 00:04:44 +0000 (02:04 +0200)
committerRobert Varga <rovarga@cisco.com>
Sat, 26 Jul 2014 00:35:49 +0000 (02:35 +0200)
All instances of String are guaranteed to be immutable, not sure why
that was not captured anywhere.

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

index d659123f9710e81a6fbc4c6df8ef3978e283c786..cc2d0186d4a03c5e7af8eaca829c3d278dc6a2cd 100644 (file)
@@ -16,7 +16,7 @@ import java.util.Set;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.concepts.Mutable;
 
-public class Immutables {
+public final class Immutables {
 
     private Immutables() {
         throw new UnsupportedOperationException("Helper class");
@@ -25,7 +25,7 @@ public class Immutables {
     public static final Set<Class<?>> KNOWN_IMMUTABLES = Immutables.<Class<?>> asHashSet(
             //
             Integer.class, Short.class, BigDecimal.class, BigInteger.class, Byte.class, Character.class, Double.class,
-            Float.class);
+            Float.class, String.class);
 
     /**
      * Determines if object is known to be immutable
@@ -37,7 +37,7 @@ public class Immutables {
      *            Reference to check
      * @return true if object is known to be immutable false otherwise.
      */
-    public static boolean isImmutable(Object o) {
+    public static boolean isImmutable(final Object o) {
         if (o == null) {
             throw new IllegalArgumentException("Object should not be null");
         }
@@ -54,7 +54,7 @@ public class Immutables {
     }
 
     @SafeVarargs
-    private static <E> Set<E> asHashSet(E... list) {
+    private static <E> Set<E> asHashSet(final E... list) {
         HashSet<E> ret = new HashSet<>();
         for (E e : list) {
             ret.add(e);