package org.opendaylight.controller.yang.model.util;\r
\r
import java.net.URI;\r
+import java.util.ArrayList;\r
import java.util.Date;\r
import java.util.HashSet;\r
import java.util.List;\r
import java.util.Set;\r
\r
+import org.opendaylight.controller.yang.common.QName;\r
+import org.opendaylight.controller.yang.model.api.SchemaPath;\r
import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
\r
-public class YangTypesConverter {\r
+public final class YangTypesConverter {\r
private static final Set<String> baseYangTypes = new HashSet<String>();\r
\r
static {\r
String typeName) {\r
TypeDefinition<?> type = null;\r
\r
+ SchemaPath path = createSchemaPath(actualPath, namespace, revision);\r
if (typeName.startsWith("int")) {\r
if (typeName.equals("int8")) {\r
- type = new Int8(actualPath, namespace, revision);\r
+ type = new Int8(path);\r
} else if (typeName.equals("int16")) {\r
- type = new Int16(actualPath, namespace, revision);\r
+ type = new Int16(path);\r
} else if (typeName.equals("int32")) {\r
- type = new Int32(actualPath, namespace, revision);\r
+ type = new Int32(path);\r
} else if (typeName.equals("int64")) {\r
- type = new Int64(actualPath, namespace, revision);\r
+ type = new Int64(path);\r
}\r
} else if (typeName.startsWith("uint")) {\r
if (typeName.equals("uint8")) {\r
- type = new Uint8(actualPath, namespace, revision);\r
+ type = new Uint8(path);\r
} else if (typeName.equals("uint16")) {\r
- type = new Uint16(actualPath, namespace, revision);\r
+ type = new Uint16(path);\r
} else if (typeName.equals("uint32")) {\r
- type = new Uint32(actualPath, namespace, revision);\r
+ type = new Uint32(path);\r
} else if (typeName.equals("uint64")) {\r
- type = new Uint64(actualPath, namespace, revision);\r
+ type = new Uint64(path);\r
}\r
} else if ("string".equals(typeName)) {\r
- type = new StringType(actualPath, namespace, revision);\r
+ type = new StringType(path);\r
} else if("binary".equals(typeName)) {\r
- type = new BinaryType(actualPath, namespace, revision);\r
+ type = new BinaryType(path);\r
} else if("boolean".equals(typeName)) {\r
- type = new BooleanType(actualPath, namespace, revision);\r
+ type = new BooleanType(path);\r
} else if("empty".equals(typeName)) {\r
- type = new EmptyType(actualPath, namespace, revision);\r
+ type = new EmptyType(path);\r
} else if("instance-identifier".equals(typeName)) {\r
- type = new InstanceIdentifier(actualPath, namespace, revision, null, true);\r
+ type = new InstanceIdentifier(path, null, true);\r
}\r
\r
return type;\r
}\r
\r
+ private static SchemaPath createSchemaPath(List<String> actualPath, URI namespace, Date revision) {\r
+ List<QName> path = new ArrayList<QName>();\r
+ for(String element : actualPath) {\r
+ path.add(new QName(namespace, revision, element));\r
+ }\r
+ return new SchemaPath(path, true);\r
+ }\r
+\r
}\r