X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blobdiff_plain;f=opendaylight%2Fsal%2Fyang-prototype%2Fyang%2Fyang-model-util%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fyang%2Fmodel%2Futil%2FYangTypesConverter.java;h=76d53d5b38b872bd2558be82f340e37b4717ea01;hp=6d41321bfd0cb5042c150f3f77779e9f68cc344a;hb=970fb91c60c15a9b57e078f81aab7dde903addb9;hpb=9fab620d933bab1ddf7eef39087fa515e6d0c988 diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/YangTypesConverter.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/YangTypesConverter.java index 6d41321bfd..76d53d5b38 100644 --- a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/YangTypesConverter.java +++ b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/YangTypesConverter.java @@ -8,14 +8,17 @@ package org.opendaylight.controller.yang.model.util; import java.net.URI; +import java.util.ArrayList; import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; +import org.opendaylight.controller.yang.common.QName; +import org.opendaylight.controller.yang.model.api.SchemaPath; import org.opendaylight.controller.yang.model.api.TypeDefinition; -public class YangTypesConverter { +public final class YangTypesConverter { private static final Set baseYangTypes = new HashSet(); static { @@ -49,41 +52,55 @@ public class YangTypesConverter { String typeName) { TypeDefinition type = null; + SchemaPath path = createSchemaPath(actualPath, namespace, revision, typeName); if (typeName.startsWith("int")) { - if (typeName.equals("int8")) { - type = new Int8(actualPath, namespace, revision); - } else if (typeName.equals("int16")) { - type = new Int16(actualPath, namespace, revision); - } else if (typeName.equals("int32")) { - type = new Int32(actualPath, namespace, revision); - } else if (typeName.equals("int64")) { - type = new Int64(actualPath, namespace, revision); + if ("int8".equals(typeName)) { + type = new Int8(path); + } else if ("int16".equals(typeName)) { + type = new Int16(path); + } else if ("int32".equals(typeName)) { + type = new Int32(path); + } else if ("int64".equals(typeName)) { + type = new Int64(path); } } else if (typeName.startsWith("uint")) { - if (typeName.equals("uint8")) { - type = new Uint8(actualPath, namespace, revision); - } else if (typeName.equals("uint16")) { - type = new Uint16(actualPath, namespace, revision); - } else if (typeName.equals("uint32")) { - type = new Uint32(actualPath, namespace, revision); - } else if (typeName.equals("uint64")) { - type = new Uint64(actualPath, namespace, revision); + if ("uint8".equals(typeName)) { + type = new Uint8(path); + } else if ("uint16".equals(typeName)) { + type = new Uint16(path); + } else if ("uint32".equals(typeName)) { + type = new Uint32(path); + } else if ("uint64".equals(typeName)) { + type = new Uint64(path); } } else if ("string".equals(typeName)) { - type = new StringType(actualPath, namespace, revision); + type = new StringType(path); } else if("binary".equals(typeName)) { - type = new BinaryType(actualPath, namespace, revision); - } else if("bits".equals(typeName)) { - type = new BitsType(actualPath, namespace, revision); + type = new BinaryType(path); } else if("boolean".equals(typeName)) { - type = new BooleanType(actualPath, namespace, revision); + type = new BooleanType(path); } else if("empty".equals(typeName)) { - type = new EmptyType(actualPath, namespace, revision); + type = new EmptyType(path); } else if("instance-identifier".equals(typeName)) { - type = new InstanceIdentifier(actualPath, namespace, revision, null, true); + type = new InstanceIdentifier(path, null, true); } return type; } + private static SchemaPath createSchemaPath(List actualPath, URI namespace, Date revision, String typeName) { + List correctPath = new ArrayList(actualPath); + // remove module name + correctPath.remove(0); + + List path = new ArrayList(); + for(String element : correctPath) { + path.add(new QName(namespace, revision, element)); + } + // add type qname + QName typeQName = new QName(BaseTypes.BaseTypesNamespace, typeName); + path.add(typeQName); + return new SchemaPath(path, true); + } + }