Fixing sonar issues 4
[yangtools.git] / yang / yang-model-util / src / main / java / org / opendaylight / yangtools / yang / model / util / YangTypesConverter.java
index 7b75a30247bd72af8773b71bfe7018cd74d11dc1..0cf3b859bc3943e01ddc09ae4d07efc91379d279 100644 (file)
@@ -1,83 +1,89 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.yangtools.yang.model.util;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;\r
-\r
-public final class YangTypesConverter {\r
-    private static final Set<String> baseYangTypes = new HashSet<String>();\r
-\r
-    static {\r
-        baseYangTypes.add("binary");\r
-        baseYangTypes.add("bits");\r
-        baseYangTypes.add("boolean");\r
-        baseYangTypes.add("decimal64");\r
-        baseYangTypes.add("empty");\r
-        baseYangTypes.add("enumeration");\r
-        baseYangTypes.add("identityref");\r
-        baseYangTypes.add("instance-identifier");\r
-        baseYangTypes.add("int8");\r
-        baseYangTypes.add("int16");\r
-        baseYangTypes.add("int32");\r
-        baseYangTypes.add("int64");\r
-        baseYangTypes.add("leafref");\r
-        baseYangTypes.add("string");\r
-        baseYangTypes.add("uint8");\r
-        baseYangTypes.add("uint16");\r
-        baseYangTypes.add("uint32");\r
-        baseYangTypes.add("uint64");\r
-        baseYangTypes.add("union");\r
-    }\r
-\r
-    public static boolean isBaseYangType(String type) {\r
-        return baseYangTypes.contains(type);\r
-    }\r
-\r
-    public static TypeDefinition<?> javaTypeForBaseYangType(String typeName) {\r
-        TypeDefinition<?> type = null;\r
-\r
-        if (typeName.startsWith("int")) {\r
-            if ("int8".equals(typeName)) {\r
-                type = Int8.getInstance();\r
-            } else if ("int16".equals(typeName)) {\r
-                type = Int16.getInstance();\r
-            } else if ("int32".equals(typeName)) {\r
-                type = Int32.getInstance();\r
-            } else if ("int64".equals(typeName)) {\r
-                type = Int64.getInstance();\r
-            }\r
-        } else if (typeName.startsWith("uint")) {\r
-            if ("uint8".equals(typeName)) {\r
-                type = Uint8.getInstance();\r
-            } else if ("uint16".equals(typeName)) {\r
-                type = Uint16.getInstance();\r
-            } else if ("uint32".equals(typeName)) {\r
-                type = Uint32.getInstance();\r
-            } else if ("uint64".equals(typeName)) {\r
-                type = Uint64.getInstance();\r
-            }\r
-        } else if ("string".equals(typeName)) {\r
-            type = StringType.getIntance();\r
-        } else if("binary".equals(typeName)) {\r
-            type = BinaryType.getInstance();\r
-        } else if("boolean".equals(typeName)) {\r
-            type = BooleanType.getInstance();\r
-        } else if("empty".equals(typeName)) {\r
-            type = EmptyType.getInstance();\r
-        } else if("instance-identifier".equals(typeName)) {\r
-            // FIXME\r
-            type = new InstanceIdentifier(null, true);\r
-        }\r
-\r
-        return type;\r
-    }\r
-\r
-}\r
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.model.util;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+
+public final class YangTypesConverter {
+    private static final Set<String> BASE_YANG_TYPES = new HashSet<String>();
+
+    /**
+     * It isn't desirable to create the instances of this class
+     */
+    private YangTypesConverter() {
+    }
+
+    static {
+        BASE_YANG_TYPES.add("binary");
+        BASE_YANG_TYPES.add("bits");
+        BASE_YANG_TYPES.add("boolean");
+        BASE_YANG_TYPES.add("decimal64");
+        BASE_YANG_TYPES.add("empty");
+        BASE_YANG_TYPES.add("enumeration");
+        BASE_YANG_TYPES.add("identityref");
+        BASE_YANG_TYPES.add("instance-identifier");
+        BASE_YANG_TYPES.add("int8");
+        BASE_YANG_TYPES.add("int16");
+        BASE_YANG_TYPES.add("int32");
+        BASE_YANG_TYPES.add("int64");
+        BASE_YANG_TYPES.add("leafref");
+        BASE_YANG_TYPES.add("string");
+        BASE_YANG_TYPES.add("uint8");
+        BASE_YANG_TYPES.add("uint16");
+        BASE_YANG_TYPES.add("uint32");
+        BASE_YANG_TYPES.add("uint64");
+        BASE_YANG_TYPES.add("union");
+    }
+
+    public static boolean isBaseYangType(String type) {
+        return BASE_YANG_TYPES.contains(type);
+    }
+
+    public static TypeDefinition<?> javaTypeForBaseYangType(String typeName) {
+        TypeDefinition<?> type = null;
+
+        if (typeName.startsWith("int")) {
+            if ("int8".equals(typeName)) {
+                type = Int8.getInstance();
+            } else if ("int16".equals(typeName)) {
+                type = Int16.getInstance();
+            } else if ("int32".equals(typeName)) {
+                type = Int32.getInstance();
+            } else if ("int64".equals(typeName)) {
+                type = Int64.getInstance();
+            }
+        } else if (typeName.startsWith("uint")) {
+            if ("uint8".equals(typeName)) {
+                type = Uint8.getInstance();
+            } else if ("uint16".equals(typeName)) {
+                type = Uint16.getInstance();
+            } else if ("uint32".equals(typeName)) {
+                type = Uint32.getInstance();
+            } else if ("uint64".equals(typeName)) {
+                type = Uint64.getInstance();
+            }
+        } else if ("string".equals(typeName)) {
+            type = StringType.getIntance();
+        } else if ("binary".equals(typeName)) {
+            type = BinaryType.getInstance();
+        } else if ("boolean".equals(typeName)) {
+            type = BooleanType.getInstance();
+        } else if ("empty".equals(typeName)) {
+            type = EmptyType.getInstance();
+        } else if ("instance-identifier".equals(typeName)) {
+            // FIXME
+            type = new InstanceIdentifier(null, true);
+        }
+
+        return type;
+    }
+
+}