Modified construction of built-in yang types.
[controller.git] / opendaylight / sal / yang-prototype / yang / yang-model-util / src / main / java / org / opendaylight / controller / yang / model / util / YangTypesConverter.java
index 82849891f9b42b64c9043237598986b007d78403..76d53d5b38b872bd2558be82f340e37b4717ea01 100644 (file)
@@ -52,25 +52,25 @@ public final class YangTypesConverter {
             String typeName) {\r
         TypeDefinition<?> type = null;\r
 \r
-        SchemaPath path = createSchemaPath(actualPath, namespace, revision);\r
+        SchemaPath path = createSchemaPath(actualPath, namespace, revision, typeName);\r
         if (typeName.startsWith("int")) {\r
-            if (typeName.equals("int8")) {\r
+            if ("int8".equals(typeName)) {\r
                 type = new Int8(path);\r
-            } else if (typeName.equals("int16")) {\r
+            } else if ("int16".equals(typeName)) {\r
                 type = new Int16(path);\r
-            } else if (typeName.equals("int32")) {\r
+            } else if ("int32".equals(typeName)) {\r
                 type = new Int32(path);\r
-            } else if (typeName.equals("int64")) {\r
+            } else if ("int64".equals(typeName)) {\r
                 type = new Int64(path);\r
             }\r
         } else if (typeName.startsWith("uint")) {\r
-            if (typeName.equals("uint8")) {\r
+            if ("uint8".equals(typeName)) {\r
                 type = new Uint8(path);\r
-            } else if (typeName.equals("uint16")) {\r
+            } else if ("uint16".equals(typeName)) {\r
                 type = new Uint16(path);\r
-            } else if (typeName.equals("uint32")) {\r
+            } else if ("uint32".equals(typeName)) {\r
                 type = new Uint32(path);\r
-            } else if (typeName.equals("uint64")) {\r
+            } else if ("uint64".equals(typeName)) {\r
                 type = new Uint64(path);\r
             }\r
         } else if ("string".equals(typeName)) {\r
@@ -88,11 +88,18 @@ public final class YangTypesConverter {
         return type;\r
     }\r
 \r
-    private static SchemaPath createSchemaPath(List<String> actualPath, URI namespace, Date revision) {\r
+    private static SchemaPath createSchemaPath(List<String> actualPath, URI namespace, Date revision, String typeName) {\r
+        List<String> correctPath = new ArrayList<String>(actualPath);\r
+        // remove module name\r
+        correctPath.remove(0);\r
+\r
         List<QName> path = new ArrayList<QName>();\r
-        for(String element : actualPath) {\r
+        for(String element : correctPath) {\r
             path.add(new QName(namespace, revision, element));\r
         }\r
+        // add type qname\r
+        QName typeQName = new QName(BaseTypes.BaseTypesNamespace, typeName);\r
+        path.add(typeQName);\r
         return new SchemaPath(path, true);\r
     }\r
 \r