Deprecate util.Immutables for removal
[yangtools.git] / common / util / src / main / java / org / opendaylight / yangtools / util / Immutables.java
index 4ec7c5f917b46813dea363f314fa6af7078e2ded..ebf4136abe179a23713a4351bc9873985256b73c 100644 (file)
@@ -7,44 +7,38 @@
  */
 package org.opendaylight.yangtools.util;
 
+import static com.google.common.base.Preconditions.checkArgument;
+
 import com.google.common.collect.ImmutableSet;
 import java.math.BigDecimal;
 import java.math.BigInteger;
-import java.util.Set;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.concepts.Mutable;
 
+@Deprecated(since = "7.0.9", forRemoval = true)
 public final class Immutables {
+    private static final ImmutableSet<Class<?>> KNOWN_IMMUTABLES = ImmutableSet.of(
+            Integer.class, Short.class, BigDecimal.class, BigInteger.class, Byte.class, Character.class, Double.class,
+            Float.class, String.class, Boolean.class, Void.class);
 
     private Immutables() {
-        throw new UnsupportedOperationException("Helper class");
+        // Hidden on purpose
     }
 
-    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, Boolean.class, Void.class);
-
     /**
      * Determines if object is known to be immutable
      *
-     * Note: This method may return false to immutable objects which
+     * <p>Note: This method may return false to immutable objects which
      * immutability is not known, was defined not using concepts term.
      *
-     * @param o
-     *            Reference to check
+     * @param obj Reference to check
      * @return true if object is known to be immutable false otherwise.
      */
-    public static boolean isImmutable(final Object o) {
-        if (o == null) {
-            throw new IllegalArgumentException("Object should not be null");
-        }
-        if (o instanceof Mutable) {
+    public static boolean isImmutable(final Object obj) {
+        checkArgument(obj != null,"Object should not be null");
+        if (obj instanceof Mutable) {
             return false;
-        } else if (o instanceof Immutable) {
-            return true;
-        } else if (o instanceof String) {
-            return true;
-        } else if (KNOWN_IMMUTABLES.contains(o.getClass())) {
+        } else if (obj instanceof Immutable || obj instanceof String || KNOWN_IMMUTABLES.contains(obj.getClass())) {
             return true;
         }
         return false;