Merge "Modified construction of built-in yang types."
authorGiovanni Meo <gmeo@cisco.com>
Mon, 10 Jun 2013 15:19:00 +0000 (15:19 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Mon, 10 Jun 2013 15:19:00 +0000 (15:19 +0000)
28 files changed:
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangParserImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangParserListenerImpl.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/util/ParserUtils.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/util/YangModelBuilderUtil.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/TypesResolutionTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/parser/impl/YangParserTest.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile2.yang
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/AbstractSignedInteger.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/AbstractUnsignedInteger.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BinaryType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BitsType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/BooleanType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Decimal64.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/EmptyType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/EnumerationType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/IdentityrefType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/InstanceIdentifier.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int16.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int32.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int64.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Int8.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Leafref.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/StringType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint16.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint32.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint64.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/Uint8.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/YangTypesConverter.java

index 25af3ebae5f47f9cb875b7a91af8de512c217bf3..401189b1d1efbb11a79801c9837fb1053f1f226d 100644 (file)
@@ -49,6 +49,7 @@ import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
 import org.opendaylight.controller.yang.model.util.ExtendedType;
 import org.opendaylight.controller.yang.model.util.IdentityrefType;
 import org.opendaylight.controller.yang.model.util.UnknownType;
+import org.opendaylight.controller.yang.model.util.YangTypesConverter;
 import org.opendaylight.controller.yang.parser.builder.api.AugmentationSchemaBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.AugmentationTargetBuilder;
 import org.opendaylight.controller.yang.parser.builder.api.Builder;
@@ -552,11 +553,16 @@ public final class YangParserImpl implements YangModelParser {
             constraints.addPatterns(patterns);
             fractionDigits = ext.getFractionDigits();
             constraints.setFractionDigits(fractionDigits);
-            return findConstraints(
-                    findTypeDefinitionBuilder(nodeToResolve.getPath(), builder,
-                            ext.getQName().getLocalName(), builder.getName(),
-                            nodeToResolve.getLine()), constraints, modules,
-                    builder);
+            if(YangTypesConverter.isBaseYangType(ext.getBaseType().getQName().getLocalName())) {
+                mergeConstraints(ext.getBaseType(), constraints);
+                return constraints;
+            } else {
+                return findConstraints(
+                        findTypeDefinitionBuilder(nodeToResolve.getPath(), builder,
+                                ext.getQName().getLocalName(), builder.getName(),
+                                nodeToResolve.getLine()), constraints, modules,
+                        builder);
+            }
         } else if (referencedType instanceof UnknownType) {
             final UnknownType unknown = (UnknownType) referencedType;
             ranges = unknown.getRangeStatements();
index 8b739098a067f3fbd0144963b0cce0600e091045..d7394e62291db2ca98e6be896cc551a4b800e08e 100644 (file)
@@ -356,10 +356,7 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                             getIdentityrefBase(typeBody), actualPath, path,
                             line);
                 } else {
-                    List<String> typePath = new ArrayList<String>(actualPath);
-                    typePath.add(typeName);
-
-                    type = parseTypeBody(typeName, typeBody, typePath,
+                    type = parseTypeBody(typeName, typeBody, actualPath,
                             namespace, revision, yangModelPrefix);
                     moduleBuilder.setType(type, actualPath);
                 }
index 2e3f0cc860ba80d22cef4d01b33b47d531626e10..e95a162de763811d1d9ead81d32df43aeb599827 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.controller.yang.parser.util;
 
 import java.lang.reflect.Method;
-import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -28,9 +27,6 @@ import org.opendaylight.controller.yang.model.api.type.IdentityrefTypeDefinition
 import org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.LengthConstraint;
-import org.opendaylight.controller.yang.model.api.type.PatternConstraint;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
@@ -198,30 +194,22 @@ public final class ParserUtils {
                 newSchemaPath = createNewSchemaPath(parentSchemaPath,
                         nodeQName, binType.getQName());
                 List<Byte> bytes = (List<Byte>) binType.getDefaultValue();
-                result = new BinaryType(newSchemaPath, bytes,
-                        binType.getLengthConstraints(), binType.getUnits());
+                result = new BinaryType(newSchemaPath, bytes);
             } else if (nodeType instanceof BitsTypeDefinition) {
                 BitsTypeDefinition bitsType = (BitsTypeDefinition) nodeType;
                 newSchemaPath = createNewSchemaPath(parentSchemaPath,
                         nodeQName, nodeType.getQName());
-                result = new BitsType(newSchemaPath, bitsType.getBits(),
-                        bitsType.getUnits());
+                result = new BitsType(newSchemaPath, bitsType.getBits());
             } else if (nodeType instanceof BooleanTypeDefinition) {
                 BooleanTypeDefinition booleanType = (BooleanTypeDefinition) nodeType;
                 newSchemaPath = createNewSchemaPath(parentSchemaPath,
                         nodeQName, booleanType.getQName());
-                result = new BooleanType(newSchemaPath,
-                        (Boolean) booleanType.getDefaultValue(),
-                        booleanType.getUnits());
+                result = new BooleanType(newSchemaPath);
             } else if (nodeType instanceof DecimalTypeDefinition) {
                 DecimalTypeDefinition decimalType = (DecimalTypeDefinition) nodeType;
                 newSchemaPath = createNewSchemaPath(parentSchemaPath,
                         nodeQName, decimalType.getQName());
-                BigDecimal defaultValue = (BigDecimal) decimalType
-                        .getDefaultValue();
-                result = new Decimal64(newSchemaPath, decimalType.getUnits(),
-                        defaultValue, decimalType.getRangeStatements(),
-                        decimalType.getFractionDigits());
+                result = new Decimal64(newSchemaPath, decimalType.getFractionDigits());
             } else if (nodeType instanceof EmptyTypeDefinition) {
                 newSchemaPath = createNewSchemaPath(parentSchemaPath,
                         nodeQName, nodeType.getQName());
@@ -232,7 +220,7 @@ public final class ParserUtils {
                         nodeQName, enumType.getQName());
                 result = new EnumerationType(newSchemaPath,
                         (EnumPair) enumType.getDefaultValue(),
-                        enumType.getValues(), enumType.getUnits());
+                        enumType.getValues());
             } else if (nodeType instanceof IdentityrefTypeDefinition) {
                 IdentityrefTypeDefinition idrefType = (IdentityrefTypeDefinition) nodeType;
                 newSchemaPath = createNewSchemaPath(parentSchemaPath,
@@ -247,13 +235,13 @@ public final class ParserUtils {
                         instIdType.getPathStatement(),
                         instIdType.requireInstance());
             } else if (nodeType instanceof StringTypeDefinition) {
-                result = copyStringType(parentSchemaPath, nodeQName,
+                result = createNewStringType(parentSchemaPath, nodeQName,
                         (StringTypeDefinition) nodeType);
             } else if (nodeType instanceof IntegerTypeDefinition) {
-                result = copyIntType(parentSchemaPath, nodeQName,
+                result = createNewIntType(parentSchemaPath, nodeQName,
                         (IntegerTypeDefinition) nodeType);
             } else if (nodeType instanceof UnsignedIntegerTypeDefinition) {
-                result = copyUIntType(parentSchemaPath, nodeQName,
+                result = createNewUintType(parentSchemaPath, nodeQName,
                         (UnsignedIntegerTypeDefinition) nodeType);
             } else if (nodeType instanceof LeafrefTypeDefinition) {
                 newSchemaPath = createNewSchemaPath(parentSchemaPath,
@@ -270,7 +258,7 @@ public final class ParserUtils {
         return result;
     }
 
-    private static TypeDefinition<?> copyStringType(SchemaPath schemaPath,
+    private static TypeDefinition<?> createNewStringType(SchemaPath schemaPath,
             QName nodeQName, StringTypeDefinition nodeType) {
         List<QName> path = schemaPath.getPath();
         List<QName> newPath = new ArrayList<QName>(path);
@@ -279,64 +267,44 @@ public final class ParserUtils {
         SchemaPath newSchemaPath = new SchemaPath(newPath,
                 schemaPath.isAbsolute());
 
-        String newDefault = nodeType.getDefaultValue().toString();
-        String newUnits = nodeType.getUnits();
-        List<LengthConstraint> lengths = nodeType.getLengthStatements();
-        List<PatternConstraint> patterns = nodeType.getPatterns();
-
-        return new StringType(newSchemaPath, newDefault, lengths, patterns,
-                newUnits);
+        return new StringType(newSchemaPath);
     }
 
-    private static TypeDefinition<?> copyIntType(SchemaPath schemaPath,
+    private static TypeDefinition<?> createNewIntType(SchemaPath schemaPath,
             QName nodeQName, IntegerTypeDefinition type) {
         QName typeQName = type.getQName();
         SchemaPath newSchemaPath = createNewSchemaPath(schemaPath, nodeQName,
                 typeQName);
-
         String localName = typeQName.getLocalName();
-        List<RangeConstraint> ranges = type.getRangeStatements();
-        String units = type.getUnits();
 
         if ("int8".equals(localName)) {
-            Byte defaultValue = (Byte) type.getDefaultValue();
-            return new Int8(newSchemaPath, ranges, units, defaultValue);
+            return new Int8(newSchemaPath);
         } else if ("int16".equals(localName)) {
-            Short defaultValue = (Short) type.getDefaultValue();
-            return new Int16(newSchemaPath, ranges, units, defaultValue);
+            return new Int16(newSchemaPath);
         } else if ("int32".equals(localName)) {
-            Integer defaultValue = (Integer) type.getDefaultValue();
-            return new Int32(newSchemaPath, ranges, units, defaultValue);
+            return new Int32(newSchemaPath);
         } else if ("int64".equals(localName)) {
-            Long defaultValue = (Long) type.getDefaultValue();
-            return new Int64(newSchemaPath, ranges, units, defaultValue);
+            return new Int64(newSchemaPath);
         } else {
             return null;
         }
     }
 
-    private static TypeDefinition<?> copyUIntType(SchemaPath schemaPath,
+    private static TypeDefinition<?> createNewUintType(SchemaPath schemaPath,
             QName nodeQName, UnsignedIntegerTypeDefinition type) {
         QName typeQName = type.getQName();
         SchemaPath newSchemaPath = createNewSchemaPath(schemaPath, nodeQName,
                 typeQName);
-
         String localName = typeQName.getLocalName();
-        List<RangeConstraint> ranges = type.getRangeStatements();
-        String units = type.getUnits();
 
         if ("uint8".equals(localName)) {
-            Byte defaultValue = (Byte) type.getDefaultValue();
-            return new Int8(newSchemaPath, ranges, units, defaultValue);
+            return new Int8(newSchemaPath);
         } else if ("uint16".equals(localName)) {
-            Short defaultValue = (Short) type.getDefaultValue();
-            return new Int16(newSchemaPath, ranges, units, defaultValue);
+            return new Int16(newSchemaPath);
         } else if ("uint32".equals(localName)) {
-            Integer defaultValue = (Integer) type.getDefaultValue();
-            return new Int32(newSchemaPath, ranges, units, defaultValue);
+            return new Int32(newSchemaPath);
         } else if ("uint64".equals(localName)) {
-            Long defaultValue = (Long) type.getDefaultValue();
-            return new Int64(newSchemaPath, ranges, units, defaultValue);
+            return new Int64(newSchemaPath);
         } else {
             return null;
         }
index e63f12839dfa8d4d883806bccf6f5e226d45a5bc..f58ee740cfe4a274840098716be91a430265e70d 100644 (file)
@@ -84,10 +84,12 @@ import org.opendaylight.controller.yang.model.api.type.LengthConstraint;
 import org.opendaylight.controller.yang.model.api.type.PatternConstraint;
 import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.util.BaseConstraints;
+import org.opendaylight.controller.yang.model.util.BaseTypes;
 import org.opendaylight.controller.yang.model.util.BinaryType;
 import org.opendaylight.controller.yang.model.util.BitsType;
 import org.opendaylight.controller.yang.model.util.Decimal64;
 import org.opendaylight.controller.yang.model.util.EnumerationType;
+import org.opendaylight.controller.yang.model.util.ExtendedType;
 import org.opendaylight.controller.yang.model.util.InstanceIdentifier;
 import org.opendaylight.controller.yang.model.util.Int16;
 import org.opendaylight.controller.yang.model.util.Int32;
@@ -999,7 +1001,7 @@ public final class YangModelBuilderUtil {
             final Type_body_stmtsContext typeBody,
             final List<String> actualPath, final URI namespace,
             final Date revision, final String prefix) {
-        TypeDefinition<?> type = null;
+        TypeDefinition<?> baseType = null;
 
         List<RangeConstraint> rangeStatements = getRangeConstraints(typeBody);
         Integer fractionDigits = getFractionDigits(typeBody);
@@ -1008,53 +1010,115 @@ public final class YangModelBuilderUtil {
         List<EnumTypeDefinition.EnumPair> enumConstants = getEnumConstants(
                 typeBody, actualPath, namespace, revision, prefix);
 
-        SchemaPath schemaPath = createActualSchemaPath(actualPath, namespace,
-                revision, prefix);
+        SchemaPath baseTypePathFinal = createTypeSchemaPath(actualPath,
+                namespace, revision, prefix, typeName, true, true);
+        SchemaPath baseTypePath = createTypeSchemaPath(actualPath,
+                namespace, revision, prefix, typeName, true, false);
 
         if ("decimal64".equals(typeName)) {
-            type = new Decimal64(schemaPath, fractionDigits);
+            if (rangeStatements.isEmpty()) {
+                return new Decimal64(baseTypePathFinal, fractionDigits);
+            }
+            baseType = new Decimal64(baseTypePath, fractionDigits);
         } else if (typeName.startsWith("int")) {
             if ("int8".equals(typeName)) {
-                type = new Int8(schemaPath, rangeStatements, null, null);
+                baseType = new Int8(baseTypePath);
             } else if ("int16".equals(typeName)) {
-                type = new Int16(schemaPath, rangeStatements, null, null);
+                baseType = new Int16(baseTypePath);
             } else if ("int32".equals(typeName)) {
-                type = new Int32(schemaPath, rangeStatements, null, null);
+                baseType = new Int32(baseTypePath);
             } else if ("int64".equals(typeName)) {
-                type = new Int64(schemaPath, rangeStatements, null, null);
+                baseType = new Int64(baseTypePath);
             }
         } else if (typeName.startsWith("uint")) {
             if ("uint8".equals(typeName)) {
-                type = new Uint8(schemaPath, rangeStatements, null, null);
+                baseType = new Uint8(baseTypePath);
             } else if ("uint16".equals(typeName)) {
-                type = new Uint16(schemaPath, rangeStatements, null, null);
+                baseType = new Uint16(baseTypePath);
             } else if ("uint32".equals(typeName)) {
-                type = new Uint32(schemaPath, rangeStatements, null, null);
+                baseType = new Uint32(baseTypePath);
             } else if ("uint64".equals(typeName)) {
-                type = new Uint64(schemaPath, rangeStatements, null, null);
+                baseType = new Uint64(baseTypePath);
             }
         } else if ("enumeration".equals(typeName)) {
-            type = new EnumerationType(schemaPath, enumConstants);
+            return new EnumerationType(baseTypePathFinal, enumConstants);
         } else if ("string".equals(typeName)) {
-            type = new StringType(schemaPath, lengthStatements,
-                    patternStatements);
+            baseType = new StringType(baseTypePath);
         } else if ("bits".equals(typeName)) {
-            type = new BitsType(schemaPath, getBits(typeBody, actualPath,
-                    namespace, revision, prefix));
+            return new BitsType(baseTypePathFinal, getBits(typeBody,
+                    actualPath, namespace, revision, prefix));
         } else if ("leafref".equals(typeName)) {
             final String path = parseLeafrefPath(typeBody);
             final boolean absolute = path.startsWith("/");
             RevisionAwareXPath xpath = new RevisionAwareXPathImpl(path,
                     absolute);
-            type = new Leafref(schemaPath, xpath);
+            return new Leafref(baseTypePathFinal, xpath);
         } else if ("binary".equals(typeName)) {
-            List<Byte> bytes = Collections.emptyList();
-            type = new BinaryType(schemaPath, bytes, lengthStatements, null);
+            baseType = new BinaryType(baseTypePath);
         } else if ("instance-identifier".equals(typeName)) {
             boolean requireInstance = isRequireInstance(typeBody);
-            type = new InstanceIdentifier(schemaPath, null, requireInstance);
+            baseType = new InstanceIdentifier(baseTypePath, null,
+                    requireInstance);
         }
-        return type;
+
+        TypeDefinition<?> result = null;
+        QName qname = new QName(namespace, revision, prefix, typeName);
+        ExtendedType.Builder typeBuilder = null;
+
+        SchemaPath schemaPath = createTypeSchemaPath(actualPath, namespace,
+                revision, prefix, typeName, false, false);
+        typeBuilder = new ExtendedType.Builder(qname, baseType, "", "",
+                schemaPath);
+
+        typeBuilder.ranges(rangeStatements);
+        typeBuilder.lengths(lengthStatements);
+        typeBuilder.patterns(patternStatements);
+        typeBuilder.fractionDigits(fractionDigits);
+
+        result = typeBuilder.build();
+        return result;
+    }
+
+    /**
+     * Create SchemaPath object from given path list with namespace, revision
+     * and prefix based on given values.
+     *
+     * @param actualPath
+     *            current position in model
+     * @param namespace
+     * @param revision
+     * @param prefix
+     * @param typeName
+     * @param isBaseYangType
+     *            if this is base yang type
+     * @param isBaseYangTypeFinal
+     *            if this is base yang type without restrictions
+     * @return SchemaPath object.
+     */
+    private static SchemaPath createTypeSchemaPath(
+            final List<String> actualPath, final URI namespace,
+            final Date revision, final String prefix, final String typeName,
+            final boolean isBaseYangType, final boolean isBaseYangTypeFinal) {
+        List<String> typePath = new ArrayList<String>(actualPath);
+        if (isBaseYangType && !isBaseYangTypeFinal) {
+            typePath.add(typeName);
+        }
+
+        final List<QName> path = new ArrayList<QName>();
+        QName qname;
+        // start from index 1 -> module name omited
+        for (int i = 1; i < typePath.size(); i++) {
+            qname = new QName(namespace, revision, prefix, typePath.get(i));
+            path.add(qname);
+        }
+        QName typeQName;
+        if (isBaseYangType) {
+            typeQName = new QName(BaseTypes.BaseTypesNamespace, typeName);
+        } else {
+            typeQName = new QName(namespace, revision, prefix, typeName);
+        }
+        path.add(typeQName);
+        return new SchemaPath(path, true);
     }
 
     /**
index 36c98c36e2a3928cded65ecdbad0ec11b850f2a4..461cc4b5c28522d675851bb417563f2baaa91830 100644 (file)
@@ -31,7 +31,6 @@ import org.opendaylight.controller.yang.model.util.EnumerationType;
 import org.opendaylight.controller.yang.model.util.ExtendedType;
 import org.opendaylight.controller.yang.model.util.IdentityrefType;
 import org.opendaylight.controller.yang.model.util.InstanceIdentifier;
-import org.opendaylight.controller.yang.model.util.StringType;
 import org.opendaylight.controller.yang.model.util.UnionType;
 
 public class TypesResolutionTest {
@@ -123,7 +122,7 @@ public class TypesResolutionTest {
         List<TypeDefinition<?>> unionTypes = baseType.getTypes();
 
         ExtendedType ipv4 = (ExtendedType) unionTypes.get(0);
-        StringType ipv4Base = (StringType) ipv4.getBaseType();
+        ExtendedType ipv4Base = (ExtendedType) ipv4.getBaseType();
         String expectedPattern = "(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\\.){3}"
                 + "([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])"
                 + "(%[\\p{N}\\p{L}]+)?";
@@ -131,7 +130,7 @@ public class TypesResolutionTest {
                 .getRegularExpression());
 
         ExtendedType ipv6 = (ExtendedType) unionTypes.get(1);
-        StringType ipv6Base = (StringType) ipv6.getBaseType();
+        ExtendedType ipv6Base = (ExtendedType) ipv6.getBaseType();
         List<PatternConstraint> ipv6Patterns = ipv6Base.getPatterns();
         expectedPattern = "((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}"
                 + "((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|"
@@ -152,7 +151,7 @@ public class TypesResolutionTest {
         Module tested = TestUtils.findModule(testedModules, "ietf-inet-types");
         Set<TypeDefinition<?>> typedefs = tested.getTypeDefinitions();
         TypeDefinition<?> type = TestUtils.findTypedef(typedefs, "domain-name");
-        StringType baseType = (StringType) type.getBaseType();
+        ExtendedType baseType = (ExtendedType) type.getBaseType();
         List<PatternConstraint> patterns = baseType.getPatterns();
         assertEquals(1, patterns.size());
         String expectedPattern = "((([a-zA-Z0-9_]([a-zA-Z0-9\\-_]){0,61})?[a-zA-Z0-9]\\.)*"
@@ -160,9 +159,9 @@ public class TypesResolutionTest {
                 + "|\\.";
         assertEquals(expectedPattern, patterns.get(0).getRegularExpression());
 
-        List<LengthConstraint> lengths = baseType.getLengthStatements();
+        List<LengthConstraint> lengths = baseType.getLengths();
         assertEquals(1, lengths.size());
-        LengthConstraint length = baseType.getLengthStatements().get(0);
+        LengthConstraint length = baseType.getLengths().get(0);
         assertEquals(1L, length.getMin());
         assertEquals(253L, length.getMax());
     }
@@ -173,8 +172,9 @@ public class TypesResolutionTest {
                 .findModule(testedModules, "custom-types-test");
         LeafSchemaNode leaf = (LeafSchemaNode) tested
                 .getDataChildByName("inst-id-leaf1");
-        InstanceIdentifier leafType = (InstanceIdentifier) leaf.getType();
-        assertFalse(leafType.requireInstance());
+        ExtendedType leafType = (ExtendedType) leaf.getType();
+        InstanceIdentifier leafTypeBase = (InstanceIdentifier)leafType.getBaseType();
+        assertFalse(leafTypeBase.requireInstance());
     }
 
     @Test
index fd2593ba4805fade12bb2193e7a3d4cf94a5b097..23bb4a41d2f25fc16c501f06ed9d65b316206d53 100644 (file)
@@ -12,6 +12,7 @@ import static org.junit.Assert.*;
 import java.io.FileNotFoundException;
 import java.net.URI;
 import java.text.DateFormat;
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Date;
@@ -56,12 +57,15 @@ import org.opendaylight.controller.yang.model.util.Decimal64;
 import org.opendaylight.controller.yang.model.util.ExtendedType;
 import org.opendaylight.controller.yang.model.util.Int16;
 import org.opendaylight.controller.yang.model.util.Int32;
+import org.opendaylight.controller.yang.model.util.Int8;
 import org.opendaylight.controller.yang.model.util.Leafref;
 import org.opendaylight.controller.yang.model.util.StringType;
 import org.opendaylight.controller.yang.model.util.Uint32;
 import org.opendaylight.controller.yang.model.util.UnionType;
 
 public class YangParserTest {
+    private final DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
+
     private Set<Module> modules;
 
     @Before
@@ -198,6 +202,55 @@ public class YangParserTest {
         assertTrue(ifMtu.getType() instanceof Int32);
     }
 
+    @Test
+    public void testParseLeaf() throws ParseException {
+        Module test = TestUtils.findModule(modules, "types2");
+
+        // leaf if-name
+        LeafSchemaNode ifName = (LeafSchemaNode) test
+                .getDataChildByName("if-name");
+        Leafref ifNameType = (Leafref)ifName.getType();
+        QName qname = ifNameType.getQName();
+
+        URI baseYangTypeNS = URI.create("urn:ietf:params:xml:ns:yang:1");
+        assertEquals(baseYangTypeNS, qname.getNamespace());
+        assertNull(qname.getRevision());
+        assertEquals("", qname.getPrefix());
+        assertEquals("leafref", qname.getLocalName());
+
+        // leaf name
+        LeafSchemaNode name = (LeafSchemaNode) test
+                .getDataChildByName("name");
+        StringType nameType = (StringType)name.getType();
+        QName nameQName = nameType.getQName();
+
+        assertEquals(baseYangTypeNS, nameQName.getNamespace());
+        assertNull(nameQName.getRevision());
+        assertEquals("", nameQName.getPrefix());
+        assertEquals("string", nameQName.getLocalName());
+
+        // leaf count
+        LeafSchemaNode count = (LeafSchemaNode) test
+                .getDataChildByName("count");
+        ExtendedType countType = (ExtendedType)count.getType();
+        QName countTypeQName = countType.getQName();
+
+        URI expectedNS = URI.create("urn:simple.types.data.demo");
+        Date expectedDate = simpleDateFormat.parse("2013-02-27");
+        assertEquals(expectedNS, countTypeQName.getNamespace());
+        assertEquals(expectedDate, countTypeQName.getRevision());
+        assertEquals("t2", countTypeQName.getPrefix());
+        assertEquals("int8", countTypeQName.getLocalName());
+
+        Int8 countTypeBase = (Int8)countType.getBaseType();
+        QName countTypeBaseQName = countTypeBase.getQName();
+
+        assertEquals(baseYangTypeNS, countTypeBaseQName.getNamespace());
+        assertNull(countTypeBaseQName.getRevision());
+        assertEquals("", countTypeBaseQName.getPrefix());
+        assertEquals("int8", countTypeBaseQName.getLocalName());
+    }
+
     @Test
     public void testAugmentResolving() {
         // testfile1
@@ -371,8 +424,14 @@ public class YangParserTest {
         ExtendedType baseType = (ExtendedType) testleafType.getBaseType();
         assertEquals("my-base-int32-type", baseType.getQName().getLocalName());
 
-        Int32 int32base = (Int32) baseType.getBaseType();
-        List<RangeConstraint> ranges = int32base.getRangeStatements();
+        ExtendedType int32Type = (ExtendedType) baseType.getBaseType();
+        Int32 int32TypeBase = (Int32)int32Type.getBaseType();
+        QName qname = int32TypeBase.getQName();
+        assertEquals(URI.create("urn:ietf:params:xml:ns:yang:1"), qname.getNamespace());
+        assertNull(qname.getRevision());
+        assertEquals("", qname.getPrefix());
+        assertEquals("int32", qname.getLocalName());
+        List<RangeConstraint> ranges = int32Type.getRanges();
         assertEquals(1, ranges.size());
         RangeConstraint range = ranges.get(0);
         assertEquals(2L, range.getMin());
@@ -419,14 +478,14 @@ public class YangParserTest {
         UnionType unionBase = (UnionType) baseType.getBaseType();
 
         List<TypeDefinition<?>> unionTypes = unionBase.getTypes();
-        Int16 unionType1 = (Int16) unionTypes.get(0);
-        List<RangeConstraint> ranges = unionType1.getRangeStatements();
+        ExtendedType unionType1 = (ExtendedType) unionTypes.get(0);
+        List<RangeConstraint> ranges = unionType1.getRanges();
         assertEquals(1, ranges.size());
         RangeConstraint range = ranges.get(0);
         assertEquals(1L, range.getMin());
         assertEquals(100L, range.getMax());
 
-        assertTrue(unionTypes.get(0) instanceof Int16);
+        assertTrue(unionType1.getBaseType() instanceof Int16);
         assertTrue(unionTypes.get(1) instanceof Int32);
     }
 
@@ -458,11 +517,12 @@ public class YangParserTest {
                 .getBaseType();
         List<TypeDefinition<?>> extendedTargetTypes = extendedTargetUnion
                 .getTypes();
-        assertTrue(extendedTargetTypes.get(0) instanceof Int16);
+        assertTrue(extendedTargetTypes.get(0).getBaseType() instanceof Int16);
         assertTrue(extendedTargetTypes.get(1) instanceof Int32);
 
-        Int16 int16 = (Int16) extendedTargetTypes.get(0);
-        List<RangeConstraint> ranges = int16.getRangeStatements();
+        ExtendedType int16 = (ExtendedType) extendedTargetTypes.get(0);
+        assertTrue(int16.getBaseType() instanceof Int16);
+        List<RangeConstraint> ranges = int16.getRanges();
         assertEquals(1, ranges.size());
         RangeConstraint range = ranges.get(0);
         assertEquals(1L, range.getMin());
@@ -536,10 +596,10 @@ public class YangParserTest {
         UnionType myUnionBase = (UnionType) myUnion.getBaseType();
         List<TypeDefinition<?>> myUnionBaseTypes = myUnionBase.getTypes();
         assertEquals(2, myUnionBaseTypes.size());
-        assertTrue(myUnionBaseTypes.get(0) instanceof Int16);
+        assertTrue(myUnionBaseTypes.get(0).getBaseType() instanceof Int16);
         assertTrue(myUnionBaseTypes.get(1) instanceof Int32);
-        Int16 int16 = (Int16) myUnionBaseTypes.get(0);
-        List<RangeConstraint> ranges = int16.getRangeStatements();
+        ExtendedType int16 = (ExtendedType) myUnionBaseTypes.get(0);
+        List<RangeConstraint> ranges = int16.getRanges();
         assertEquals(1, ranges.size());
         RangeConstraint range = ranges.get(0);
         assertEquals(1L, range.getMin());
@@ -770,7 +830,6 @@ public class YangParserTest {
 
     @Test
     public void testAugmentNodesTypesSchemaPath() throws Exception {
-        final DateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
         Module testModule = TestUtils.findModule(modules, "types1");
         Set<AugmentationSchema> augments = testModule.getAugmentations();
         assertEquals(1, augments.size());
@@ -807,4 +866,93 @@ public class YangParserTest {
         assertEquals(q3, higherLayerTypePath.get(3));
     }
 
+    @Test
+    public void testTypePath() throws ParseException {
+        Module test = TestUtils.findModule(modules, "types2");
+        Set<TypeDefinition<?>> types = test.getTypeDefinitions();
+
+        // my-base-int32-type
+        ExtendedType int32Typedef = (ExtendedType)TestUtils.findTypedef(types, "my-base-int32-type");
+        QName int32TypedefQName = int32Typedef.getQName();
+
+        URI expectedNS = URI.create("urn:simple.types.data.demo");
+        Date expectedDate = simpleDateFormat.parse("2013-02-27");
+        assertEquals(expectedNS, int32TypedefQName.getNamespace());
+        assertEquals(expectedDate, int32TypedefQName.getRevision());
+        assertEquals("t2", int32TypedefQName.getPrefix());
+        assertEquals("my-base-int32-type", int32TypedefQName.getLocalName());
+
+        SchemaPath typeSchemaPath = int32Typedef.getPath();
+        List<QName> typePath = typeSchemaPath.getPath();
+        assertEquals(1, typePath.size());
+        assertEquals(int32TypedefQName, typePath.get(0));
+
+        // my-base-int32-type/int32
+        ExtendedType int32Ext = (ExtendedType)int32Typedef.getBaseType();
+        QName int32ExtQName = int32Ext.getQName();
+
+        assertEquals(expectedNS, int32ExtQName.getNamespace());
+        assertEquals(expectedDate, int32ExtQName.getRevision());
+        assertEquals("t2", int32ExtQName.getPrefix());
+        assertEquals("int32", int32ExtQName.getLocalName());
+
+        SchemaPath int32ExtSchemaPath = int32Ext.getPath();
+        List<QName> int32ExtPath = int32ExtSchemaPath.getPath();
+        assertEquals(2, int32ExtPath.size());
+        assertEquals(int32TypedefQName, int32ExtPath.get(0));
+        assertEquals(int32ExtQName, int32ExtPath.get(1));
+
+        // my-base-int32-type/int32/int32
+        Int32 int32 = (Int32)int32Ext.getBaseType();
+        QName int32QName = int32.getQName();
+        assertEquals(URI.create("urn:ietf:params:xml:ns:yang:1"), int32QName.getNamespace());
+        assertNull(int32QName.getRevision());
+        assertEquals("", int32QName.getPrefix());
+        assertEquals("int32", int32QName.getLocalName());
+
+        SchemaPath int32SchemaPath = int32.getPath();
+        List<QName> int32Path = int32SchemaPath.getPath();
+        assertEquals(3, int32Path.size());
+        assertEquals(int32TypedefQName, int32Path.get(0));
+        assertEquals(int32ExtQName, int32Path.get(1));
+        assertEquals(int32QName, int32Path.get(2));
+    }
+
+    @Test
+    public void testTypePath2() throws ParseException {
+        Module test = TestUtils.findModule(modules, "types2");
+        Set<TypeDefinition<?>> types = test.getTypeDefinitions();
+
+        // my-base-int32-type
+        ExtendedType myDecType = (ExtendedType)TestUtils.findTypedef(types, "my-decimal-type");
+        QName myDecTypeQName = myDecType.getQName();
+
+        URI expectedNS = URI.create("urn:simple.types.data.demo");
+        Date expectedDate = simpleDateFormat.parse("2013-02-27");
+        assertEquals(expectedNS, myDecTypeQName.getNamespace());
+        assertEquals(expectedDate, myDecTypeQName.getRevision());
+        assertEquals("t2", myDecTypeQName.getPrefix());
+        assertEquals("my-decimal-type", myDecTypeQName.getLocalName());
+
+        SchemaPath typeSchemaPath = myDecType.getPath();
+        List<QName> typePath = typeSchemaPath.getPath();
+        assertEquals(1, typePath.size());
+        assertEquals(myDecTypeQName, typePath.get(0));
+
+        // my-base-int32-type/int32
+        Decimal64 dec64 = (Decimal64)myDecType.getBaseType();
+        QName dec64QName = dec64.getQName();
+
+        assertEquals(URI.create("urn:ietf:params:xml:ns:yang:1"), dec64QName.getNamespace());
+        assertNull(dec64QName.getRevision());
+        assertEquals("", dec64QName.getPrefix());
+        assertEquals("decimal64", dec64QName.getLocalName());
+
+        SchemaPath dec64SchemaPath = dec64.getPath();
+        List<QName> dec64Path = dec64SchemaPath.getPath();
+        assertEquals(2, dec64Path.size());
+        assertEquals(myDecTypeQName, dec64Path.get(0));
+        assertEquals(dec64QName, dec64Path.get(1));
+    }
+
 }
index 8860e06622fee0d1128649f3386a392138d35aa2..904c8e66fd2c3d8dd8ad9dc2f32588604ffc867f 100644 (file)
@@ -114,6 +114,12 @@ module types2 {
     leaf name {
         type string;
     }
+    
+    leaf count {
+        type int8 {
+            range "1..10";
+        }
+    }
      
     leaf nested-type-leaf {
         type my-type1;
index 0af3c81c6ac3e570c716a3376cf3549d8f3f16fe..baefbf40fe97d413a377a25fc9ba5ebe4e159d94 100644 (file)
@@ -35,29 +35,13 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  *
  */
 public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
-
     private final QName name;
     private final SchemaPath path;
     private final String description;
     private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.2";
-
     private final String units;
     private final List<RangeConstraint> rangeStatements;
 
-    protected AbstractSignedInteger(final QName name, final String description,
-            final Number minRange, final Number maxRange, final String units) {
-        this.name = name;
-        this.description = description;
-        this.path = BaseTypes.schemaPath(name);
-        this.units = units;
-        this.rangeStatements = new ArrayList<RangeConstraint>();
-        final String rangeDescription = "Integer values between " + minRange
-                + " and " + maxRange + ", inclusively.";
-        this.rangeStatements.add(BaseConstraints.rangeConstraint(minRange,
-                maxRange, rangeDescription,
-                "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
-    }
-
     /**
      * @param name
      * @param description
index 013d80d79911c127ef4f3823a2fc996bf70c044f..6d5b5be8a0378dfa27fee06687e6174c860a1078 100644 (file)
@@ -36,25 +36,9 @@ public abstract class AbstractUnsignedInteger implements
     private final SchemaPath path;
     private final String description;
     private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.2";
-
     private final String units;
     private final List<RangeConstraint> rangeStatements;
 
-    protected AbstractUnsignedInteger(final QName name,
-            final String description, final Number minRange,
-            final Number maxRange, final String units) {
-        this.name = name;
-        this.description = description;
-        this.path = BaseTypes.schemaPath(name);
-        this.units = units;
-        this.rangeStatements = new ArrayList<RangeConstraint>();
-        final String rangeDescription = "Integer values between " + minRange
-                + " and " + maxRange + ", inclusively.";
-        this.rangeStatements.add(BaseConstraints.rangeConstraint(minRange,
-                maxRange, rangeDescription,
-                "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
-    }
-
     /**
      *
      * @param actualPath
index 74214dc0c77973a9f5b07777ea77d0735c33f9fc..ea09b65b5daa1382847faff9a4429eadee79d5fd 100644 (file)
@@ -24,65 +24,33 @@ import org.opendaylight.controller.yang.model.api.type.LengthConstraint;
  * @see BinaryTypeDefinition
  */
 public final class BinaryType implements BinaryTypeDefinition {
-
     private final QName name = BaseTypes.constructQName("binary");
     private final SchemaPath path;
     private final String description = "The binary built-in type represents any binary data, i.e., a sequence of octets.";
     private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.8";
     private final BinaryTypeDefinition baseType;
-    private List<Byte> bytes;
+    private final List<Byte> bytes;
     private final List<LengthConstraint> lengthConstraints;
-    private String units = "";
-
-    private BinaryType() {
-        super();
+    private final String units = "";
 
+    public BinaryType(final SchemaPath path) {
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
         constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
                 ""));
         this.lengthConstraints = Collections.unmodifiableList(constraints);
         this.bytes = Collections.emptyList();
-        this.path = BaseTypes.schemaPath(name);
+        this.path = path;
         this.baseType = this;
     }
 
-    public BinaryType(final SchemaPath path) {
-        super();
-
+    public BinaryType(final SchemaPath path, final List<Byte> bytes) {
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
         constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
                 ""));
         this.lengthConstraints = Collections.unmodifiableList(constraints);
-        this.bytes = Collections.emptyList();
-        this.path = path;
-        this.baseType = new BinaryType();
-    }
-
-    /**
-     *
-     *
-     * @param bytes
-     * @param lengthConstraints
-     * @param units
-     */
-    public BinaryType(final SchemaPath path, final List<Byte> bytes,
-            final List<LengthConstraint> lengthConstraints, final String units) {
-        super();
-
-        if ((lengthConstraints == null) || (lengthConstraints.isEmpty())) {
-            final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-            constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE,
-                    "", ""));
-            this.lengthConstraints = Collections.unmodifiableList(constraints);
-        } else {
-            this.lengthConstraints = Collections
-                    .unmodifiableList(lengthConstraints);
-        }
-
-        this.path = path;
         this.bytes = Collections.unmodifiableList(bytes);
-        this.units = units;
-        this.baseType = new BinaryType();
+        this.path = path;
+        this.baseType = this;
     }
 
     /*
index 51e0306e8b8737c1e7450c6fe60a8767b6c43280..94391d2288eace0dc4b6d9265d97ee06893e2dcb 100644 (file)
@@ -22,7 +22,6 @@ import org.opendaylight.controller.yang.model.api.type.BitsTypeDefinition;
  * @see BitsTypeDefinition
  */
 public final class BitsType implements BitsTypeDefinition {
-
     private final QName name = BaseTypes.constructQName("bits");
     private final SchemaPath path;
     private final String description = "The bits built-in type represents a bit set.  "
@@ -32,24 +31,17 @@ public final class BitsType implements BitsTypeDefinition {
     private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.7";
     private final BitsTypeDefinition baseType;
     private final List<Bit> bits;
-    private String units = "";
+    private final String units = "";
 
     /**
      * Default constructor. <br>
      * Instantiates Bits type as empty bits list.
      */
-    private BitsType() {
-        super();
-        this.bits = Collections.emptyList();
-        this.path = BaseTypes.schemaPath(name);
-        this.baseType = this;
-    }
-
     public BitsType(final SchemaPath path) {
         super();
         this.bits = Collections.emptyList();
         this.path = path;
-        this.baseType = new BitsType();
+        this.baseType = this;
     }
 
     /**
@@ -64,27 +56,8 @@ public final class BitsType implements BitsTypeDefinition {
     public BitsType(final SchemaPath path, final List<Bit> bits) {
         super();
         this.bits = Collections.unmodifiableList(bits);
-        this.units = "";
-        this.path = path;
-        this.baseType = new BitsType();
-    }
-
-    /**
-     * Constructor with explicit definition of bits assigned to BitsType and
-     * Units. <br>
-     * The default value of Bits Type is List of bits.
-     *
-     * @param bits
-     *            The bits assigned for Bits Type
-     * @param units
-     *            units for bits type
-     */
-    public BitsType(final SchemaPath path, List<Bit> bits, String units) {
-        super();
-        this.bits = Collections.unmodifiableList(bits);
-        this.units = units;
         this.path = path;
-        this.baseType = new BitsType();
+        this.baseType = this;
     }
 
     /*
index 0cda67c27fe2cf7158c8561bdb44281fb1f24b48..04b2dc90d1ac66f507926d0e9edff0c51b63f682 100644 (file)
@@ -22,30 +22,22 @@ import org.opendaylight.controller.yang.model.api.type.BooleanTypeDefinition;
  * @see BooleanTypeDefinition
  */
 public final class BooleanType implements BooleanTypeDefinition {
-
     private final QName name = BaseTypes.constructQName("boolean");
     private final SchemaPath path;
     private final String description = "The boolean built-in type represents a boolean value.";
     private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.5";
     private final BooleanTypeDefinition baseType;
     private final Boolean defaultValue;
-    private String units = "";
+    private final String units = "";
 
     /**
      * Default constructor with default value set to "false".
      */
-    private BooleanType() {
-        super();
-        this.defaultValue = false;
-        this.path = BaseTypes.schemaPath(name);
-        this.baseType = this;
-    }
-
     public BooleanType(final SchemaPath path) {
         super();
         this.defaultValue = false;
         this.path = path;
-        this.baseType = new BooleanType();
+        this.baseType = this;
     }
 
     /**
@@ -58,23 +50,7 @@ public final class BooleanType implements BooleanTypeDefinition {
         super();
         this.defaultValue = defaultValue;
         this.path = path;
-        this.baseType = new BooleanType();
-    }
-
-    /**
-     * Boolean Type constructor.
-     *
-     * @param defaultValue
-     *            Default Value
-     * @param units
-     *            Units
-     */
-    public BooleanType(final SchemaPath path, final Boolean defaultValue, final String units) {
-        super();
-        this.defaultValue = defaultValue;
-        this.units = units;
-        this.path = path;
-        this.baseType = new BooleanType();
+        this.baseType = this;
     }
 
     /*
index 6a070837bd8e9f3f79cec5c02639ffbdd7f0965b..1387da9b1cf5ead763a14d21b8b3d784ecc6ceb5 100644 (file)
@@ -26,11 +26,10 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  * @see DecimalTypeDefinition
  */
 public final class Decimal64 implements DecimalTypeDefinition {
-
     private final QName name = BaseTypes.constructQName("decimal64");
     private final SchemaPath path;
-    private String units = "";
-    private BigDecimal defaultValue = null;
+    private final String units = "";
+    private final BigDecimal defaultValue = null;
 
     private final String description = "The decimal64 type represents a subset of the real numbers, which can "
             + "be represented by decimal numerals. The value space of decimal64 is the set of numbers that can "
@@ -54,25 +53,14 @@ public final class Decimal64 implements DecimalTypeDefinition {
      * If the fraction digits are not defined inner the definition boundaries
      * the constructor will throw {@link IllegalArgumentException}
      *
+     * @param path
      * @param fractionDigits
      *            integer between 1 and 18 inclusively
      *
      * @see DecimalTypeDefinition
      * @exception IllegalArgumentException
      */
-    private Decimal64(final Integer fractionDigits) {
-        if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
-            throw new IllegalArgumentException(
-                    "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");
-        }
-        this.fractionDigits = fractionDigits;
-        this.rangeStatements = defaultRangeStatements();
-        this.path = BaseTypes.schemaPath(name);
-        this.baseType = this;
-    }
-
     public Decimal64(final SchemaPath path, final Integer fractionDigits) {
-        super();
         if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
             throw new IllegalArgumentException(
                     "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");
@@ -80,97 +68,7 @@ public final class Decimal64 implements DecimalTypeDefinition {
         this.fractionDigits = fractionDigits;
         rangeStatements = defaultRangeStatements();
         this.path = path;
-        this.baseType = new Decimal64(fractionDigits);
-    }
-
-    /**
-     * Decimal64 Type Constructor. <br>
-     *
-     * If parameter <code>Range Statements</code> is <code>null</code> or
-     * defined as <code>empty List</code> the constructor automatically assigns
-     * the boundaries as min and max value defined for Decimal64 in <a
-     * href="https://tools.ietf.org/html/rfc6020#section-9.3">[RFC-6020] The
-     * decimal64 Built-In Type</a> <br>
-     * <br>
-     * The fractions digits MUST be defined as integer between 1 and 18
-     * inclusively as defined interface {@link DecimalTypeDefinition} <br>
-     * If the fraction digits are not defined inner the definition boundaries
-     * the constructor will throw {@link IllegalArgumentException}
-     *
-     * @param actualPath
-     * @param namespace
-     * @param revision
-     * @param rangeStatements
-     *            Range Constraint Statements
-     * @param fractionDigits
-     *            integer between 1 and 18 inclusively
-     * @exception IllegalArgumentException
-     */
-    public Decimal64(final SchemaPath path, final List<RangeConstraint> rangeStatements,
-            Integer fractionDigits) {
-        super();
-        if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
-            throw new IllegalArgumentException(
-                    "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");
-        }
-        if (rangeStatements == null || rangeStatements.isEmpty()) {
-            this.rangeStatements = defaultRangeStatements();
-        } else {
-            this.rangeStatements = Collections
-                    .unmodifiableList(rangeStatements);
-        }
-        this.fractionDigits = fractionDigits;
-        this.path = path;
-        this.baseType = new Decimal64(fractionDigits);
-    }
-
-    /**
-     * Decimal64 Type Constructor. <br>
-     * If parameter <code>Range Statements</code> is <code>null</code> or
-     * defined as <code>empty List</code> the constructor automatically assigns
-     * the boundaries as min and max value defined for Decimal64 in <a
-     * href="https://tools.ietf.org/html/rfc6020#section-9.3">[RFC-6020] The
-     * decimal64 Built-In Type</a> <br>
-     * <br>
-     * The fractions digits MUST be defined as integer between 1 and 18
-     * inclusively as defined interface {@link DecimalTypeDefinition} <br>
-     * If the fraction digits are not defined inner the definition boundaries
-     * the constructor will throw {@link IllegalArgumentException}
-     *
-     * @param actualPath
-     * @param namespace
-     * @param revision
-     * @param units
-     *            units associated with the type
-     * @param defaultValue
-     *            Default Value for type
-     * @param rangeStatements
-     *            Range Constraint Statements
-     * @param fractionDigits
-     *            integer between 1 and 18 inclusively
-     */
-    public Decimal64(final SchemaPath path, final String units,
-            final BigDecimal defaultValue,
-            final List<RangeConstraint> rangeStatements,
-            final Integer fractionDigits) {
-        super();
-        if (!((fractionDigits.intValue() > 1) && (fractionDigits.intValue() <= 18))) {
-            throw new IllegalArgumentException(
-                    "The fraction digits outside of boundaries. Fraction digits MUST be integer between 1 and 18 inclusively");
-        }
-
-        if (rangeStatements == null || rangeStatements.isEmpty()) {
-            this.rangeStatements = defaultRangeStatements();
-
-        } else {
-            this.rangeStatements = Collections
-                    .unmodifiableList(rangeStatements);
-        }
-        this.units = units;
-        this.defaultValue = defaultValue;
-        this.fractionDigits = fractionDigits;
-        this.path = path;
-        this.baseType = new Decimal64(fractionDigits);
+        this.baseType = this;
     }
 
     /**
index 424f313efae6b20ccf35cf78e6b12057594114e0..0e542bc019f3e5fa043fc8fe769bf5457df9d6ea 100644 (file)
@@ -17,21 +17,15 @@ import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.controller.yang.model.api.type.EmptyTypeDefinition;
 
 public final class EmptyType implements EmptyTypeDefinition {
-
     private final QName name = BaseTypes.constructQName("empty");
     private final SchemaPath path;
     private final String description = "The empty built-in type represents a leaf that does not have any value, it conveys information by its presence or absence.";
     private final String reference = "https://tools.ietf.org/html/rfc6020#page-131";
     private final EmptyTypeDefinition baseType;
 
-    private EmptyType() {
-        path = BaseTypes.schemaPath(name);
-        this.baseType = this;
-    }
-
     public EmptyType(final SchemaPath path) {
         this.path = path;
-        this.baseType = new EmptyType();
+        this.baseType = this;
     }
 
     @Override
index 175ea100ca0919c51f8f9a08e841bc9b13cffc9e..de7ee3060347df9337479de99db162c554da0bf8 100644 (file)
@@ -22,7 +22,6 @@ import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
  * @see EnumTypeDefinition
  */
 public final class EnumerationType implements EnumTypeDefinition {
-
     private final QName name = BaseTypes.constructQName("enumeration");
     private final SchemaPath path;
     private final String description = "The enumeration built-in type represents values from a set of assigned names.";
@@ -30,32 +29,24 @@ public final class EnumerationType implements EnumTypeDefinition {
 
     private final EnumPair defaultEnum;
     private final List<EnumPair> enums;
-    private String units = "";
+    private final String units = "";
     private final EnumTypeDefinition baseType;
 
-    private EnumerationType(final List<EnumPair> enums) {
-        this.path = BaseTypes.schemaPath(name);
-        this.enums = Collections.unmodifiableList(enums);
-        this.defaultEnum = null;
-        baseType = this;
-    }
-
     public EnumerationType(final SchemaPath path, final List<EnumPair> enums) {
         super();
         this.path = path;
         this.enums = Collections.unmodifiableList(enums);
         this.defaultEnum = null;
-        baseType = new EnumerationType(enums);
+        this.baseType = this;
     }
 
     public EnumerationType(final SchemaPath path, final EnumPair defaultEnum,
-            final List<EnumPair> enums, final String units) {
+            final List<EnumPair> enums) {
         super();
         this.path = path;
-        baseType = new EnumerationType(enums);
+        this.baseType = this;
         this.defaultEnum = defaultEnum;
         this.enums = Collections.unmodifiableList(enums);
-        this.units = units;
     }
 
     /*
index 6c4598131e496b405e1183ae521b44e507fb00ce..30f0013d240e7e713882eba614efd4d0cd467091 100644 (file)
@@ -22,27 +22,18 @@ import org.opendaylight.controller.yang.model.api.type.IdentityrefTypeDefinition
  * @see IdentityrefTypeDefinition\r
  */\r
 public final class IdentityrefType implements IdentityrefTypeDefinition {\r
-\r
     private final QName name = BaseTypes.constructQName("identityref");\r
     private final SchemaPath path;\r
     private final String description = "The identityref type is used to reference an existing identity.";\r
     private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.10";\r
     private final IdentityrefTypeDefinition baseType;\r
-\r
     private final QName identity;\r
-\r
-    private String units = "";\r
-\r
-    private IdentityrefType(QName identity) {\r
-        this.identity = identity;\r
-        this.path = BaseTypes.schemaPath(name);\r
-        this.baseType = this;\r
-    }\r
+    private final String units = "";\r
 \r
     public IdentityrefType(QName identity, SchemaPath schemaPath) {\r
         this.identity = identity;\r
         this.path = schemaPath;\r
-        this.baseType = new IdentityrefType(identity);\r
+        this.baseType = this;\r
     }\r
 \r
     @Override\r
index 4c17fa6154248fb711c7bd844feb60e65cfd4ba3..8139d5b50b50bb302d1e5802b5a01ac74c8545b8 100644 (file)
@@ -23,7 +23,6 @@ import org.opendaylight.controller.yang.model.api.type.InstanceIdentifierTypeDef
  * @see InstanceIdentifierTypeDefinition
  */
 public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
-
     private static final QName name = BaseTypes
             .constructQName("instance-identifier");
     private static final String description = "The instance-identifier built-in type is used to " +
@@ -36,20 +35,12 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
     private final InstanceIdentifierTypeDefinition baseType;
     private final boolean requireInstance;
 
-    private InstanceIdentifier(RevisionAwareXPath xpath, boolean requireInstance) {
-        super();
-        path = BaseTypes.schemaPath(name);
-        this.xpath = xpath;
-        this.requireInstance = requireInstance;
-        this.baseType = this;
-    }
-
     public InstanceIdentifier(final SchemaPath path, RevisionAwareXPath xpath, boolean requireInstance) {
         super();
         this.path = path;
         this.xpath = xpath;
         this.requireInstance = requireInstance;
-        this.baseType = new InstanceIdentifier(xpath, requireInstance);
+        this.baseType = this;
     }
 
     /*
index 0a24bf2d059166a65345775cbd34734e83813005..829cd140b18a04740e26ba75b4ab5c851e514866 100644 (file)
@@ -7,12 +7,9 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.util.List;
-
 import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
 /**
  * Implementation of Yang int16 built-in type. <br>
@@ -22,29 +19,15 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  * @see AbstractSignedInteger
  */
 public final class Int16 extends AbstractSignedInteger {
-
     private static final QName name = BaseTypes.constructQName("int16");
-    private Short defaultValue = null;
+    private final Short defaultValue = null;
     private static final String description = "int16  represents integer values between -32768 and 32767, inclusively.";
     private final IntegerTypeDefinition baseType;
 
-    private Int16() {
-        super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = this;
-    }
-
     public Int16(final SchemaPath path) {
         super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = new Int16();
-
-    }
+        this.baseType = this;
 
-    public Int16(final SchemaPath path,
-            final List<RangeConstraint> rangeStatements, final String units,
-            final Short defaultValue) {
-        super(path, name, description, rangeStatements, units);
-        this.defaultValue = defaultValue;
-        this.baseType = new Int16();
     }
 
     @Override
index 8d16e268c35c610750d6e129cbcc1d1ad6882e13..025448262e713a43f26356205f83fa107cc5e636 100644 (file)
@@ -7,12 +7,9 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.util.List;
-
 import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
 /**
  * Implementation of Yang int32 built-in type. <br>
@@ -24,34 +21,14 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  *
  */
 public final class Int32 extends AbstractSignedInteger {
-
     private static final QName name = BaseTypes.constructQName("int32");
-    private Integer defaultValue = null;
+    private final Integer defaultValue = null;
     private static final String description = "int32  represents integer values between -2147483648 and 2147483647, inclusively.";
     private final IntegerTypeDefinition baseType;
 
-    private Int32() {
-        super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
-        this.baseType = this;
-    }
-
     public Int32(final SchemaPath path) {
         super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
-        this.baseType = new Int32();
-    }
-
-    public Int32(final SchemaPath path, final Integer defaultValue) {
-        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
-        this.baseType = new Int32();
-        this.defaultValue = defaultValue;
-    }
-
-    public Int32(final SchemaPath path,
-            final List<RangeConstraint> rangeStatements, final String units,
-            final Integer defaultValue) {
-        super(path, name, description, rangeStatements, units);
-        this.baseType = new Int32();
-        this.defaultValue = defaultValue;
+        this.baseType = this;
     }
 
     /*
index 92e92a94a276b8ee22b8c51932db82c5b40d4ea8..d51dcc7a8136912cf83188bd0d2c61becddfbb79 100644 (file)
@@ -7,12 +7,9 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.util.List;
-
 import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
 /**
  * Implementation of Yang int64 built-in type. <br>
@@ -22,34 +19,15 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  *
  */
 public final class Int64 extends AbstractSignedInteger {
-
     private static final QName name = BaseTypes.constructQName("int64");
-    private Long defaultValue = null;
+    private final Long defaultValue = null;
     private static final String description =
             "int64  represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.";
     private final IntegerTypeDefinition baseType;
 
-    private Int64() {
-        super(name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
-        this.baseType = this;
-    }
-
     public Int64(final SchemaPath path) {
         super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
-        this.baseType = new Int64();
-    }
-
-    public Int64(final SchemaPath path, final Long defaultValue) {
-        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
-        this.baseType = new Int64();
-        this.defaultValue = defaultValue;
-    }
-
-    public Int64(final SchemaPath path, final List<RangeConstraint> rangeStatements,
-            final String units, final Long defaultValue) {
-        super(path, name, description, rangeStatements, units);
-        this.baseType = new Int64();
-        this.defaultValue = defaultValue;
+        this.baseType = this;
     }
 
     /*
index f77eebad5223cdc32476ccafa219c873e6d9329d..9f205955492a767ca10e43f4f4aa5979ff1f879f 100644 (file)
@@ -7,12 +7,9 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.util.List;
-
 import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.type.IntegerTypeDefinition;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 
 /**
  * Implementation of Yang int8 built-in type. <br>
@@ -22,34 +19,14 @@ import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
  * @see AbstractSignedInteger
  */
 public final class Int8 extends AbstractSignedInteger {
-
     private static final QName name = BaseTypes.constructQName("int8");
-    private Byte defaultValue = null;
+    private final Byte defaultValue = null;
     private static final String description = "represents integer values between -128 and 127, inclusively.";
     private final IntegerTypeDefinition baseType;
 
-    private Int8() {
-        super(name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
-        this.baseType = this;
-    }
-
     public Int8(final SchemaPath path) {
         super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
-        this.baseType = new Int8();
-    }
-
-    public Int8(final SchemaPath path, final Byte defaultValue) {
-        super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
-        this.baseType = new Int8();
-        this.defaultValue = defaultValue;
-    }
-
-    public Int8(final SchemaPath path,
-            final List<RangeConstraint> rangeStatements, final String units,
-            final Byte defaultValue) {
-        super(path, name, description, rangeStatements, units);
-        this.baseType = new Int8();
-        this.defaultValue = defaultValue;
+        this.baseType = this;
     }
 
     /*
index d17843af898b44adb1d6a5b2c9d140e446e2675b..bd42903184b68a472bf93caa670fe752f1d0c34e 100644 (file)
@@ -33,17 +33,10 @@ public final class Leafref implements LeafrefTypeDefinition {
     private final String units = "";
     private final LeafrefTypeDefinition baseType;
 
-    private Leafref(final RevisionAwareXPath xpath) {
-        this.xpath = xpath;
-        this.path = BaseTypes.schemaPath(name);
-        this.baseType = this;
-    }
-
     public Leafref(final SchemaPath path, final RevisionAwareXPath xpath) {
-        super();
         this.path = path;
         this.xpath = xpath;
-        baseType = new Leafref(xpath);
+        baseType = this;
     }
 
     /*
index 018ba00042d7ec27e9ee9c182c74ea56effdb98b..b430e801dd1be3093a3110605795117de3680e33 100644 (file)
@@ -25,27 +25,16 @@ import org.opendaylight.controller.yang.model.api.type.StringTypeDefinition;
  * @see StringTypeDefinition
  */
 public final class StringType implements StringTypeDefinition {
-
     private final QName name = BaseTypes.constructQName("string");
     private final SchemaPath path;
-    private String defaultValue = "";
+    private final String defaultValue = "";
     private final String description = "";
     private final String reference = "";
     private final List<LengthConstraint> lengthStatements;
     private final List<PatternConstraint> patterns;
-    private String units = "";
+    private final String units = "";
     private final StringTypeDefinition baseType;
 
-    private StringType() {
-        super();
-        path = BaseTypes.schemaPath(name);
-        final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
-        lengthStatements = Collections.unmodifiableList(constraints);
-        patterns = Collections.emptyList();
-        baseType = this;
-    }
-
     /**
      * Default Constructor.
      */
@@ -56,56 +45,7 @@ public final class StringType implements StringTypeDefinition {
         constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
         lengthStatements = Collections.unmodifiableList(constraints);
         patterns = Collections.emptyList();
-        baseType = new StringType();
-    }
-
-    /**
-     *
-     * @param actualPath
-     * @param namespace
-     * @param revision
-     * @param lengthStatements
-     * @param patterns
-     */
-    public StringType(final SchemaPath path, final List<LengthConstraint> lengthStatements,
-            final List<PatternConstraint> patterns) {
-        super();
-        this.path = path;
-        if(lengthStatements == null || lengthStatements.size() == 0) {
-            final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-            constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
-            this.lengthStatements = Collections.unmodifiableList(constraints);
-        } else {
-            this.lengthStatements = Collections.unmodifiableList(lengthStatements);
-        }
-        this.patterns = Collections.unmodifiableList(patterns);
-        baseType = new StringType();
-    }
-
-    /**
-     *
-     *
-     * @param defaultValue
-     * @param lengthStatements
-     * @param patterns
-     * @param units
-     */
-    public StringType(final SchemaPath path, final String defaultValue,
-            final List<LengthConstraint> lengthStatements,
-            final List<PatternConstraint> patterns, final String units) {
-        super();
-        this.path = path;
-        this.defaultValue = defaultValue;
-        if(lengthStatements == null || lengthStatements.size() == 0) {
-            final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-            constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
-            this.lengthStatements = Collections.unmodifiableList(constraints);
-        } else {
-            this.lengthStatements = Collections.unmodifiableList(lengthStatements);
-        }
-        this.patterns = Collections.unmodifiableList(patterns);
-        this.units = units;
-        this.baseType = new StringType();
+        baseType = this;
     }
 
     /*
index 95b438b509f8258c722aa403ee64a8ac08985411..79ae4674b0b48971005c09ad76cad8d528b6a215 100644 (file)
@@ -7,11 +7,8 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.util.List;
-
 import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 /**
@@ -21,33 +18,14 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  *
  */
 public final class Uint16 extends AbstractUnsignedInteger {
-
     private static final QName name = BaseTypes.constructQName("uint16");
     private Integer defaultValue = null;
     private static final String description = "uint16 represents integer values between 0 and 65535, inclusively.";
     private final UnsignedIntegerTypeDefinition baseType;
 
-    private Uint16() {
-        super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = this;
-    }
-
     public Uint16(final SchemaPath path) {
         super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = new Uint16();
-    }
-
-    public Uint16(final SchemaPath path, final Integer defaultValue) {
-        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = new Uint16();
-        this.defaultValue = defaultValue;
-    }
-
-    public Uint16(final SchemaPath path, final List<RangeConstraint> rangeStatements,
-            final String units, final Integer defaultValue) {
-        super(path, name, description, rangeStatements, units);
-        this.baseType = new Uint16();
-        this.defaultValue = defaultValue;
+        this.baseType = this;
     }
 
     /*
index e530e02bbb79357518ccf67fe5fd968da500ac47..fddf0c4008f9c172486a891f49012ef466412a1b 100644 (file)
@@ -7,11 +7,8 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
-import java.util.List;
-
 import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 /**
@@ -21,33 +18,14 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  *
  */
 public final class Uint32 extends AbstractUnsignedInteger {
-
     private static final QName name = BaseTypes.constructQName("uint32");
-    private Long defaultValue = null;
+    private final Long defaultValue = null;
     private static final String description = "uint32 represents integer values between 0 and 4294967295, inclusively.";
     private final UnsignedIntegerTypeDefinition baseType;
 
-    private Uint32() {
-        super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = this;
-    }
-
     public Uint32(final SchemaPath path) {
         super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = new Uint32();
-    }
-
-    public Uint32(final SchemaPath path, final Long defaultValue) {
-        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = new Uint32();
-        this.defaultValue = defaultValue;
-    }
-
-    public Uint32(final SchemaPath path, final List<RangeConstraint> rangeStatements,
-            final String units, final Long defaultValue) {
-        super(path, name, description, rangeStatements, units);
-        this.baseType = new Uint32();
-        this.defaultValue = defaultValue;
+        this.baseType = this;
     }
 
     /*
index a4aabb56c659bc939431fa8a581c83b091d7a63a..9252c08f577715c6744201d1a1b507373ff6f9e8 100644 (file)
@@ -8,11 +8,9 @@
 package org.opendaylight.controller.yang.model.util;
 
 import java.math.BigInteger;
-import java.util.List;
 
 import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 /**
@@ -23,35 +21,14 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
  *
  */
 public final class Uint64 extends AbstractUnsignedInteger {
-
     private static final QName name = BaseTypes.constructQName("uint64");
-
-    private BigInteger defaultValue = null;
+    private final BigInteger defaultValue = null;
     private static final String description = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
     private final UnsignedIntegerTypeDefinition baseType;
 
-    private Uint64() {
-        super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = this;
-    }
-
     public Uint64(final SchemaPath path) {
         super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = new Uint64();
-    }
-
-    public Uint64(final SchemaPath path, final BigInteger defaultValue) {
-        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = new Uint64();
-        this.defaultValue = defaultValue;
-    }
-
-    public Uint64(final SchemaPath path,
-            final List<RangeConstraint> rangeStatements, final String units,
-            final BigInteger defaultValue) {
-        super(path, name, description, rangeStatements, units);
-        this.baseType = new Uint64();
-        this.defaultValue = defaultValue;
+        this.baseType = this;
     }
 
     /*
index c369e037763c7ec821cac453dfe9a413d70d1901..fa9d35ea291b2635aab13dc8f420df9dde1a4b86 100644 (file)
@@ -7,11 +7,8 @@
   */
 package org.opendaylight.controller.yang.model.util;
 
-import java.util.List;
-
 import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.type.RangeConstraint;
 import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 /**
@@ -25,32 +22,14 @@ import org.opendaylight.controller.yang.model.api.type.UnsignedIntegerTypeDefini
 public final class Uint8 extends AbstractUnsignedInteger {
 
     private static final QName name = BaseTypes.constructQName("uint8");
-    private Short defaultValue = null;
+    private final Short defaultValue = null;
     private static final String description =
             "uint8  represents integer values between 0 and 255, inclusively.";
     private final UnsignedIntegerTypeDefinition baseType;
 
-    private Uint8() {
-        super(name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = this;
-    }
-
     public Uint8(final SchemaPath path) {
         super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = new Uint8();
-    }
-
-    public Uint8(final SchemaPath path, final Short defaultValue) {
-        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = new Uint8();
-        this.defaultValue = defaultValue;
-    }
-
-    public Uint8(final SchemaPath path, final List<RangeConstraint> rangeStatements,
-            final String units, final Short defaultValue) {
-        super(path, name, description, rangeStatements, units);
-        this.baseType = new Uint8();
-        this.defaultValue = defaultValue;
+        this.baseType = this;
     }
 
     /*
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