Cleanup PathArgumentTypes
[controller.git] / opendaylight / md-sal / sal-clustering-commons / src / main / java / org / opendaylight / controller / cluster / datastore / node / utils / stream / PathArgumentTypes.java
index b01beb8c779b5b80907a0afcf51cc04f58c54d60..dd140ca410156d028175243dbd66fba67e339794 100644 (file)
@@ -8,31 +8,31 @@
 
 package org.opendaylight.controller.cluster.datastore.node.utils.stream;
 
+import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableMap;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-
 import java.util.Map;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
-public class PathArgumentTypes {
+final class PathArgumentTypes {
     public static final byte AUGMENTATION_IDENTIFIER = 1;
     public static final byte NODE_IDENTIFIER = 2;
     public static final byte NODE_IDENTIFIER_WITH_VALUE = 3;
     public static final byte NODE_IDENTIFIER_WITH_PREDICATES = 4;
 
-    private static Map<Class<?>, Byte> CLASS_TO_ENUM_MAP =
+    private PathArgumentTypes() {
+        throw new UnsupportedOperationException("Utility class");
+    }
+
+    private static final Map<Class<?>, Byte> CLASS_TO_ENUM_MAP =
             ImmutableMap.<Class<?>, Byte>builder().
                 put(YangInstanceIdentifier.AugmentationIdentifier.class, AUGMENTATION_IDENTIFIER).
                 put(YangInstanceIdentifier.NodeIdentifier.class, NODE_IDENTIFIER).
                 put(YangInstanceIdentifier.NodeIdentifierWithPredicates.class, NODE_IDENTIFIER_WITH_PREDICATES).
                 put(YangInstanceIdentifier.NodeWithValue.class, NODE_IDENTIFIER_WITH_VALUE).build();
 
-    public static byte getSerializablePathArgumentType(YangInstanceIdentifier.PathArgument pathArgument){
-
-        Byte type = CLASS_TO_ENUM_MAP.get(pathArgument.getClass());
-        if(type == null) {
-            throw new IllegalArgumentException("Unknown type of PathArgument = " + pathArgument);
-        }
-
+    public static byte getSerializablePathArgumentType(YangInstanceIdentifier.PathArgument pathArgument) {
+        final Byte type = CLASS_TO_ENUM_MAP.get(pathArgument.getClass());
+        Preconditions.checkArgument(type != null, "Unknown type of PathArgument = %s", pathArgument);
         return type;
     }