Refactored base yang-java types. 35/935/1
authorMartin Vitez <mvitez@cisco.com>
Wed, 21 Aug 2013 12:56:55 +0000 (14:56 +0200)
committerMartin Vitez <mvitez@cisco.com>
Wed, 21 Aug 2013 12:56:55 +0000 (14:56 +0200)
Updated types resolving in parser. Removed unused methods. Updated tests.

Signed-off-by: Martin Vitez <mvitez@cisco.com>
31 files changed:
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractSignedInteger.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/AbstractUnsignedInteger.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BaseTypes.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BinaryType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/BooleanType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/EmptyType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/InstanceIdentifier.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Int16.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Int32.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Int64.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Int8.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/StringType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Uint16.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Uint32.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Uint64.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/Uint8.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/UnionType.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/YangTypesConverter.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/UnionTypeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangParserImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangParserListenerImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/CopyUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ParserListenerUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/ParserUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/TypeUtils.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/AugmentTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/UsesAugmentTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/YangParserSimpleTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/parser/impl/YangParserTest.java

index 8a5705410dc13b732b70541ed880a8c5c634ec1a..44adb2235d446775dbfaa87f4e7e0652def58ddd 100644 (file)
@@ -7,16 +7,9 @@
  */
 package org.opendaylight.yangtools.sal.binding.generator.impl;
 
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.moduleNamespaceToPackageName;
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.packageNameForGeneratedType;
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.parseToClassName;
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.parseToValidParamName;
-import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.schemaNodeToTransferObjectBuilder;
-import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNode;
-import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;
-
-import java.net.URI;
-import java.net.URISyntaxException;
+import static org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil.*;
+import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.*;
+
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
@@ -32,7 +25,6 @@ import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.
 import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.yangtools.sal.binding.generator.spi.TypeProvider;
-import org.opendaylight.yangtools.sal.binding.model.api.ConcreteType;
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
@@ -113,10 +105,10 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Only parent constructor is invoked.
      */
-    
+
     private final static String YANG_EXT_NAMESPACE = "urn:opendaylight:yang:extension:yang-ext";
     private final static String AUGMENT_IDENTIFIER_NAME = "augment-identifier";
-    
+
     public BindingGeneratorImpl() {
         super();
     }
@@ -124,10 +116,10 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Resolves generated types from <code>context</code> schema nodes of all
      * modules.
-     * 
+     *
      * Generated types are created for modules, groupings, types, containers,
      * lists, choices, augments, rpcs, notification, identities.
-     * 
+     *
      * @param context
      *            schema context which contains data about all schema nodes
      *            saved in modules
@@ -176,10 +168,10 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Resolves generated types from <code>context</code> schema nodes only for
      * modules specified in <code>modules</code>
-     * 
+     *
      * Generated types are created for modules, groupings, types, containers,
      * lists, choices, augments, rpcs, notification, identities.
-     * 
+     *
      * @param context
      *            schema context which contains data about all schema nodes
      *            saved in modules
@@ -244,7 +236,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Converts all extended type definitions of module to the list of
      * <code>Type</code> objects.
-     * 
+     *
      * @param module
      *            module from which is obtained set of type definitions
      * @return list of <code>Type</code> which are generated from extended
@@ -255,7 +247,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if name of module equals null</li>
      *             <li>if type definitions of module equal null</li>
      *             </ul>
-     * 
+     *
      */
     private List<Type> allTypeDefinitionsToGenTypes(final Module module) {
         if (module == null) {
@@ -284,7 +276,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Converts all <b>containers</b> of the module to the list of
      * <code>Type</code> objects.
-     * 
+     *
      * @param module
      *            module from which is obtained DataNodeIterator to iterate over
      *            all containers
@@ -296,7 +288,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if the name of module equals null</li>
      *             <li>if the set of child nodes equals null</li>
      *             </ul>
-     * 
+     *
      */
     private List<Type> allContainersToGenTypes(final Module module) {
         if (module == null) {
@@ -327,7 +319,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Converts all <b>lists</b> of the module to the list of <code>Type</code>
      * objects.
-     * 
+     *
      * @param module
      *            module from which is obtained DataNodeIterator to iterate over
      *            all lists
@@ -339,7 +331,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if the name of module equals null</li>
      *             <li>if the set of child nodes equals null</li>
      *             </ul>
-     * 
+     *
      */
     private List<Type> allListsToGenTypes(final Module module) {
         if (module == null) {
@@ -372,7 +364,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Converts all <b>choices</b> of the module to the list of
      * <code>Type</code> objects.
-     * 
+     *
      * @param module
      *            module from which is obtained DataNodeIterator to iterate over
      *            all choices
@@ -383,7 +375,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if the module equals null</li>
      *             <li>if the name of module equals null</li> *
      *             </ul>
-     * 
+     *
      */
     private List<GeneratedType> allChoicesToGenTypes(final Module module) {
         if (module == null) {
@@ -409,7 +401,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Converts all <b>augmentation</b> of the module to the list
      * <code>Type</code> objects.
-     * 
+     *
      * @param module
      *            module from which is obtained list of all augmentation objects
      *            to iterate over them
@@ -421,7 +413,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if the name of module equals null</li>
      *             <li>if the set of child nodes equals null</li>
      *             </ul>
-     * 
+     *
      */
     private List<Type> allAugmentsToGenTypes(final Module module) {
         if (module == null) {
@@ -448,7 +440,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * Returns list of <code>AugmentationSchema</code> objects. The objects are
      * sorted according to the length of their target path from the shortest to
      * the longest.
-     * 
+     *
      * @param module
      *            module from which is obtained list of all augmentation objects
      * @return list of sorted <code>AugmentationSchema</code> objects obtained
@@ -458,7 +450,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if the module equals null</li>
      *             <li>if the set of augmentation equals null</li>
      *             </ul>
-     * 
+     *
      */
     private List<AugmentationSchema> resolveAugmentations(final Module module) {
         if (module == null) {
@@ -492,7 +484,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * Converts whole <b>module</b> to <code>GeneratedType</code> object.
      * Firstly is created the module builder object from which is finally
      * obtained reference to <code>GeneratedType</code> object.
-     * 
+     *
      * @param module
      *            module from which are obtained the module name, child nodes,
      *            uses and is derived package name
@@ -500,7 +492,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *         the module
      * @throws IllegalArgumentException
      *             if the module equals null
-     * 
+     *
      */
     private GeneratedType moduleToDataType(final Module module) {
         if (module == null) {
@@ -523,7 +515,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * Converts all <b>rpcs</b> inputs and outputs substatements of the module
      * to the list of <code>Type</code> objects. In addition are to containers
      * and lists which belong to input or output also part of returning list.
-     * 
+     *
      * @param module
      *            module from which is obtained set of all rpc objects to
      *            iterate over them
@@ -535,7 +527,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if the name of module equals null</li>
      *             <li>if the set of child nodes equals null</li>
      *             </ul>
-     * 
+     *
      */
     private List<Type> allRPCMethodsToGenType(final Module module) {
         if (module == null) {
@@ -627,7 +619,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * Converts all <b>notifications</b> of the module to the list of
      * <code>Type</code> objects. In addition are to this list added containers
      * and lists which are part of this notification.
-     * 
+     *
      * @param module
      *            module from which is obtained set of all notification objects
      *            to iterate over them
@@ -639,7 +631,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if the name of module equals null</li>
      *             <li>if the set of child nodes equals null</li>
      *             </ul>
-     * 
+     *
      */
     private List<Type> allNotificationsToGenType(final Module module) {
         if (module == null) {
@@ -690,7 +682,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Converts all <b>identities</b> of the module to the list of
      * <code>Type</code> objects.
-     * 
+     *
      * @param module
      *            module from which is obtained set of all identity objects to
      *            iterate over them
@@ -699,7 +691,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *            {@link identityToGenType}
      * @return list of <code>Type</code> which are generated from identities
      *         (object of type <code>IdentitySchemaNode</code>
-     * 
+     *
      */
     private List<Type> allIdentitiesToGenTypes(final Module module, final SchemaContext context) {
         List<Type> genTypes = new ArrayList<>();
@@ -723,7 +715,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * If identity doesn't contain base identity then only reference to abstract
      * class {@link org.opendaylight.yangtools.yang.model.api.BaseIdentity
      * BaseIdentity} is added
-     * 
+     *
      * @param basePackageName
      *            string contains the module package name
      * @param identity
@@ -731,10 +723,10 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * @param context
      *            SchemaContext which is used to get package and name
      *            information about base of identity
-     * 
+     *
      * @return GeneratedType which is generated from identity (object of type
      *         <code>IdentitySchemaNode</code>
-     * 
+     *
      */
     private GeneratedType identityToGenType(final String basePackageName, final IdentitySchemaNode identity,
             final SchemaContext context) {
@@ -768,13 +760,13 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * dependencies. At least dependend (indepedent) groupings are in the list
      * saved at first positions. For every grouping the record is added to map
      * {@link BindingGeneratorImpl#allGroupings allGroupings}
-     * 
+     *
      * @param module
      *            module from which is obtained set of all grouping objects to
      *            iterate over them
      * @return list of <code>Type</code> which are generated from groupings
      *         (object of type <code>GroupingDefinition</code>)
-     * 
+     *
      */
     private List<Type> allGroupingsToGenTypes(final Module module) {
         if (module == null) {
@@ -785,7 +777,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
         final Set<GroupingDefinition> groupings = module.getGroupings();
         List<GroupingDefinition> groupingsSortedByDependencies;
 
-        groupingsSortedByDependencies = GroupingDefinitionDependencySort.sort(groupings); 
+        groupingsSortedByDependencies = GroupingDefinitionDependencySort.sort(groupings);
 
         for (final GroupingDefinition grouping : groupingsSortedByDependencies) {
             GeneratedType genType = groupingToGenType(basePackageName, grouping);
@@ -800,7 +792,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * Converts individual grouping to GeneratedType. Firstly generated type
      * builder is created and every child node of grouping is resolved to the
      * method.
-     * 
+     *
      * @param basePackageName
      *            string contains the module package name
      * @param grouping
@@ -825,7 +817,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * Tries to find EnumTypeDefinition in <code>typeDefinition</code>. If base
      * type of <code>typeDefinition</code> is of the type ExtendedType then this
      * method is recursivelly called with this base type.
-     * 
+     *
      * @param typeDefinition
      *            TypeDefinition in which should be EnumTypeDefinition found as
      *            base type
@@ -846,10 +838,10 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Adds enumeration builder created from <code>enumTypeDef</code> to
      * <code>typeBuilder</code>.
-     * 
+     *
      * Each <code>enumTypeDef</code> item is added to builder with its name and
      * value.
-     * 
+     *
      * @param enumTypeDef
      *            EnumTypeDefinition contains enum data
      * @param enumName
@@ -893,7 +885,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
     /**
      * Generates type builder for <code>module</code>.
-     * 
+     *
      * @param module
      *            Module which is source of package name for generated type
      *            builder
@@ -922,7 +914,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * generated types for all containers, list and choices which are child of
      * <code>augSchema</code> node or a generated types for cases are added if
      * augmented node is choice.
-     * 
+     *
      * @param augmentPackageName
      *            string with the name of the package to which the augmentation
      *            belongs
@@ -983,10 +975,10 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
     /**
      * Returns a generated type builder for an augmentation.
-     * 
+     *
      * The name of the type builder is equal to the name of augmented node with
      * serial number as suffix.
-     * 
+     *
      * @param augmentPackageName
      *            string with contains the package name to which the augment
      *            belongs
@@ -1009,8 +1001,9 @@ public final class BindingGeneratorImpl implements BindingGenerator {
             genTypeBuilders.put(augmentPackageName, augmentBuilders);
         }
         final String augIdentifier = getAugmentIdentifier(augSchema.getUnknownSchemaNodes());
-        
-        final String augTypeName =  augIdentifier != null ? parseToClassName(augIdentifier): augGenTypeName(augmentBuilders, targetTypeName);
+
+        final String augTypeName = augIdentifier != null ? parseToClassName(augIdentifier) : augGenTypeName(
+                augmentBuilders, targetTypeName);
         final Type targetTypeRef = new ReferencedTypeImpl(targetPackageName, targetTypeName);
         final Set<DataSchemaNode> augChildNodes = augSchema.getChildNodes();
 
@@ -1029,8 +1022,8 @@ public final class BindingGeneratorImpl implements BindingGenerator {
         String ret = null;
         for (UnknownSchemaNode unknownSchemaNode : unknownSchemaNodes) {
             QName nodeType = unknownSchemaNode.getNodeType();
-            if(AUGMENT_IDENTIFIER_NAME.equals(nodeType.getLocalName()) &&
-                    YANG_EXT_NAMESPACE.equals(nodeType.getNamespace().toString())) {
+            if (AUGMENT_IDENTIFIER_NAME.equals(nodeType.getLocalName())
+                    && YANG_EXT_NAMESPACE.equals(nodeType.getNamespace().toString())) {
                 return unknownSchemaNode.getNodeParameter();
             }
         }
@@ -1040,13 +1033,13 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Convert a container, list and choice subnodes (and recursivelly their
      * subnodes) of augment to generated types
-     * 
+     *
      * @param augBasePackageName
      *            string with the augment package name
      * @param augChildNodes
      *            set of data schema nodes which represents child nodes of the
      *            augment
-     * 
+     *
      * @return list of <code>Type</code> which represents container, list and
      *         choice subnodes of augment
      */
@@ -1100,7 +1093,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * Returns first unique name for the augment generated type builder. The
      * generated type builder name for augment consists from name of augmented
      * node and serial number of its augmentation.
-     * 
+     *
      * @param builders
      *            map of builders which were created in the package to which the
      *            augmentation belongs
@@ -1124,7 +1117,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * generated type builder is created. The subnodes of
      * <code>containerNode</code> are added as methods and the instance of
      * <code>GeneratedType</code> is returned.
-     * 
+     *
      * @param basePackageName
      *            string contains the module package name
      * @param containerNode
@@ -1148,10 +1141,10 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Adds the methods to <code>typeBuilder</code> which represent subnodes of
      * node for which <code>typeBuilder</code> was created.
-     * 
+     *
      * The subnodes aren't mapped to the methods if they are part of grouping or
      * augment (in this case are already part of them).
-     * 
+     *
      * @param basePackageName
      *            string contains the module package name
      * @param typeBuilder
@@ -1182,7 +1175,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Adds the methods to <code>typeBuilder</code> what represents subnodes of
      * node for which <code>typeBuilder</code> was created.
-     * 
+     *
      * @param basePackageName
      *            string contains the module package name
      * @param typeBuilder
@@ -1212,7 +1205,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Adds to <code>typeBuilder</code> a method which is derived from
      * <code>schemaNode</code>.
-     * 
+     *
      * @param basePackageName
      *            string with the module package name
      * @param schemaNode
@@ -1241,14 +1234,14 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
     /**
      * Creates a getter method for a choice node.
-     * 
+     *
      * Firstly generated type builder for choice is created or found in
      * {@link BindingGeneratorImpl#allGroupings allGroupings}. The package name
      * in the builder is created as concatenation of module package name and
      * names of all parent nodes. In the end the getter method for choice is
      * added to <code>typeBuilder</code> and return type is set to choice
      * builder.
-     * 
+     *
      * @param basePackageName
      *            string with the module package name
      * @param typeBuilder
@@ -1262,7 +1255,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if <code>typeBuilder</code> equals null</li>
      *             <li>if <code>choiceNode</code> equals null</li>
      *             </ul>
-     * 
+     *
      */
     private void resolveChoiceSchemaNode(final String basePackageName, final GeneratedTypeBuilder typeBuilder,
             final ChoiceNode choiceNode) {
@@ -1287,11 +1280,11 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Converts <code>choiceNode</code> to the list of generated types for
      * choice and its cases.
-     * 
+     *
      * The package names for choice and for its cases are created as
      * concatenation of the module package (<code>basePackageName</code>) and
      * names of all parents node.
-     * 
+     *
      * @param basePackageName
      *            string with the module package name
      * @param choiceNode
@@ -1305,7 +1298,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if <code>basePackageName</code> equals null</li>
      *             <li>if <code>choiceNode</code> equals null</li>
      *             </ul>
-     * 
+     *
      */
     private List<GeneratedType> choiceToGeneratedType(final String basePackageName, final ChoiceNode choiceNode) {
         if (basePackageName == null) {
@@ -1332,14 +1325,14 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Converts <code>caseNodes</code> set to list of corresponding generated
      * types.
-     * 
+     *
      * For every <i>case</i> which isn't added through augment or <i>uses</i> is
      * created generated type builder. The package names for the builder is
      * created as concatenation of the module package (
      * <code>basePackageName</code>) and names of all parents nodes of the
      * concrete <i>case</i>. There is also relation "<i>implements type</i>"
      * between every case builder and <i>choice</i> type
-     * 
+     *
      * @param basePackageName
      *            string with the module package name
      * @param refChoiceType
@@ -1388,8 +1381,8 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Generates list of generated types for all the cases of a choice which are
      * added to the choice through the augment.
-     * 
-     * 
+     *
+     *
      * @param basePackageName
      *            string contains name of package to which augment belongs. If
      *            an augmented choice is from an other package (pcg1) than an
@@ -1443,7 +1436,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Converts <code>leaf</code> to the getter method which is added to
      * <code>typeBuilder</code>.
-     * 
+     *
      * @param typeBuilder
      *            generated type builder to which is added getter method as
      *            <code>leaf</code> mapping
@@ -1465,6 +1458,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
                 leafDesc = "";
             }
 
+            final Module parentModule = findParentModule(schemaContext, leaf);
             if (leafName != null && !leaf.isAddedByUses()) {
                 final TypeDefinition<?> typeDef = leaf.getType();
 
@@ -1480,12 +1474,12 @@ public final class BindingGeneratorImpl implements BindingGenerator {
                     }
                     ((TypeProviderImpl) typeProvider).putReferencedType(leaf.getPath(), returnType);
                 } else if (typeDef instanceof UnionType) {
-                    GeneratedTOBuilder genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leafName);
+                    GeneratedTOBuilder genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leafName, parentModule);
                     if (genTOBuilder != null) {
                         returnType = new ReferencedTypeImpl(genTOBuilder.getPackageName(), genTOBuilder.getName());
                     }
                 } else if (typeDef instanceof BitsTypeDefinition) {
-                    GeneratedTOBuilder genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leafName);
+                    GeneratedTOBuilder genTOBuilder = addTOToTypeBuilder(typeDef, typeBuilder, leafName, parentModule);
                     if (genTOBuilder != null) {
                         returnType = new ReferencedTypeImpl(genTOBuilder.getPackageName(), genTOBuilder.getName());
                     }
@@ -1504,7 +1498,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Converts <code>leaf</code> schema node to property of generated TO
      * builder.
-     * 
+     *
      * @param toBuilder
      *            generated TO builder to which is <code>leaf</code> added as
      *            property
@@ -1556,7 +1550,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Converts <code>node</code> leaf list schema node to getter method of
      * <code>typeBuilder</code>.
-     * 
+     *
      * @param typeBuilder
      *            generated type builder to which is <code>node</code> added as
      *            getter method
@@ -1591,14 +1585,14 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
     /**
      * Creates a getter method for a container node.
-     * 
+     *
      * Firstly generated type builder for container is created or found in
      * {@link BindingGeneratorImpl#allGroupings allGroupings}. The package name
      * in the builder is created as concatenation of module package name and
      * names of all parent nodes. In the end the getter method for container is
      * added to <code>typeBuilder</code> and return type is set to container
      * type builder.
-     * 
+     *
      * @param basePackageName
      *            string with the module package name
      * @param typeBuilder
@@ -1634,13 +1628,13 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
     /**
      * Creates a getter method for a list node.
-     * 
+     *
      * Firstly generated type builder for list is created or found in
      * {@link BindingGeneratorImpl#allGroupings allGroupings}. The package name
      * in the builder is created as concatenation of module package name and
      * names of all parent nodes. In the end the getter method for list is added
      * to <code>typeBuilder</code> and return type is set to list type builder.
-     * 
+     *
      * @param basePackageName
      *            string with the module package name
      * @param typeBuilder
@@ -1675,7 +1669,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Instantiates generated type builder with <code>packageName</code> and
      * <code>schemaNode</code>.
-     * 
+     *
      * The new builder always implements
      * {@link org.opendaylight.yangtools.yang.binding.DataObject DataObject}.<br />
      * If <code>schemaNode</code> is instance of GroupingDefinition it also
@@ -1685,7 +1679,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer
      * DataNodeContainer} it can also implement nodes which are specified in
      * <i>uses</i>.
-     * 
+     *
      * @param packageName
      *            string with the name of the package to which
      *            <code>schemaNode</code> belongs.
@@ -1709,7 +1703,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
     /**
      * Wraps the calling of the same overloaded method.
-     * 
+     *
      * @param packageName
      *            string with the package name to which returning generated type
      *            builder belongs
@@ -1724,11 +1718,11 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Returns reference to generated type builder for specified
      * <code>schemaNode</code> with <code>packageName</code>.
-     * 
+     *
      * Firstly the generated type builder is searched in
      * {@link BindingGeneratorImpl#genTypeBuilders genTypeBuilders}. If it isn't
      * found it is created and added to <code>genTypeBuilders</code>.
-     * 
+     *
      * @param packageName
      *            string with the package name to which returning generated type
      *            builder belongs
@@ -1742,7 +1736,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      *             <li>if Q name of schema node is null</li>
      *             <li>if schema node name is nul</li>
      *             </ul>
-     * 
+     *
      */
     private GeneratedTypeBuilder addRawInterfaceDefinition(final String packageName, final SchemaNode schemaNode,
             final String prefix) {
@@ -1783,7 +1777,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
     /**
      * Creates the name of the getter method from <code>methodName</code>.
-     * 
+     *
      * @param methodName
      *            string with the name of the getter method
      * @return string with the name of the getter method for
@@ -1798,7 +1792,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
     /**
      * Creates the name of the setter method from <code>methodName</code>.
-     * 
+     *
      * @param methodName
      *            string with the name of the setter method
      * @return string with the name of the setter method for
@@ -1814,11 +1808,11 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Created a method signature builder as part of
      * <code>interfaceBuilder</code>.
-     * 
+     *
      * The method signature builder is created for the getter method of
      * <code>schemaNodeName</code>. Also <code>comment</code> and
      * <code>returnType</code> information are added to the builder.
-     * 
+     *
      * @param interfaceBuilder
      *            generated type builder for which the getter method should be
      *            created
@@ -1845,12 +1839,12 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Creates a method signature builder as a part of
      * <code>interfaceBuilder</code> for <code>schemaNodeName</code>
-     * 
+     *
      * The method signature builder is created for the setter method of
      * <code>schemaNodeName</code>. Also <code>comment</code>
      * <code>parameterType</code> data are added to the builder. The return type
      * of the method is set to <code>void</code>.
-     * 
+     *
      * @param interfaceBuilder
      *            generated type builder for which the setter method should be
      *            created
@@ -1891,11 +1885,12 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
         final List<String> listKeys = listKeys(list);
         GeneratedTOBuilder genTOBuilder = resolveListKeyTOBuilder(packageName, list);
-        
-        
-        if(genTOBuilder != null) {
-            ParameterizedType identifierMarker = Types.parameterizedTypeFor( Types.typeForClass(Identifier.class), typeBuilder);
-            ParameterizedType identifiableMarker = Types.parameterizedTypeFor(Types.typeForClass(Identifiable.class), genTOBuilder);
+
+        if (genTOBuilder != null) {
+            ParameterizedType identifierMarker = Types.parameterizedTypeFor(Types.typeForClass(Identifier.class),
+                    typeBuilder);
+            ParameterizedType identifiableMarker = Types.parameterizedTypeFor(Types.typeForClass(Identifiable.class),
+                    genTOBuilder);
             genTOBuilder.addImplementsType(identifierMarker);
             typeBuilder.addImplementsType(identifiableMarker);
         }
@@ -1913,7 +1908,7 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Adds <code>schemaNode</code> to <code>typeBuilder</code> as getter method
      * or to <code>genTOBuilder</code> as property.
-     * 
+     *
      * @param basePackageName
      *            string contains the module package name
      * @param schemaNode
@@ -1977,8 +1972,9 @@ public final class BindingGeneratorImpl implements BindingGenerator {
     /**
      * Selects the names of the list keys from <code>list</code> and returns
      * them as the list of the strings
-     * 
-     * @param list of string with names of the list keys
+     *
+     * @param list
+     *            of string with names of the list keys
      * @return list of string which represents names of the list keys. If the
      *         <code>list</code> contains no keys then the empty list is
      *         returned.
@@ -1996,11 +1992,10 @@ public final class BindingGeneratorImpl implements BindingGenerator {
         return listKeys;
     }
 
-
     /**
      * Generates for the <code>list</code> which contains any list keys special
      * generated TO builder.
-     * 
+     *
      * @param packageName
      *            string with package name to which the list belongs
      * @param list
@@ -2027,10 +2022,10 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * {@link org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition
      * BitsTypeDefinition} which are also added to <code>typeBuilder</code> as
      * enclosing transfer object.
-     * 
+     *
      * @param typeDef
-     *            type definition which can be of type <code>UnionType</code>
-     *            or <code>BitsTypeDefinition</code>
+     *            type definition which can be of type <code>UnionType</code> or
+     *            <code>BitsTypeDefinition</code>
      * @param typeBuilder
      *            generated type builder to which is added generated TO created
      *            from <code>typeDef</code>
@@ -2039,16 +2034,16 @@ public final class BindingGeneratorImpl implements BindingGenerator {
      * @return generated TO builder for <code>typeDef</code>
      */
     private GeneratedTOBuilder addTOToTypeBuilder(TypeDefinition<?> typeDef, GeneratedTypeBuilder typeBuilder,
-            String leafName) {
+            String leafName, Module parentModule) {
         final String classNameFromLeaf = parseToClassName(leafName);
         GeneratedTOBuilder genTOBuilder = null;
         final String packageName = typeBuilder.getFullyQualifiedName();
         if (typeDef instanceof UnionTypeDefinition) {
-            genTOBuilder = ((TypeProviderImpl) typeProvider).provideGeneratedTOBuilderForUnionTypeDefinition(packageName, typeDef,
-                    classNameFromLeaf);
+            genTOBuilder = ((TypeProviderImpl) typeProvider).provideGeneratedTOBuilderForUnionTypeDefinition(
+                    packageName, typeDef, classNameFromLeaf, parentModule);
         } else if (typeDef instanceof BitsTypeDefinition) {
-            genTOBuilder = ((TypeProviderImpl) typeProvider).provideGeneratedTOBuilderForBitsTypeDefinition(packageName, typeDef,
-                    classNameFromLeaf);
+            genTOBuilder = ((TypeProviderImpl) typeProvider).provideGeneratedTOBuilderForBitsTypeDefinition(
+                    packageName, typeDef, classNameFromLeaf);
         }
         if (genTOBuilder != null) {
             typeBuilder.addEnclosingTransferObject(genTOBuilder);
@@ -2060,13 +2055,13 @@ public final class BindingGeneratorImpl implements BindingGenerator {
 
     /**
      * Adds the implemented types to type builder.
-     * 
+     *
      * The method passes through the list of <i>uses</i> in
      * {@code dataNodeContainer}. For every <i>use</i> is obtained coresponding
      * generated type from {@link BindingGeneratorImpl#allGroupings
      * allGroupings} which is adde as <i>implements type</i> to
      * <code>builder</code>
-     * 
+     *
      * @param dataNodeContainer
      *            element which contains the list of used YANG groupings
      * @param builder
index 4e6d2632e2f999531c8eeb12a59d0145d76f5a32..a119d4f155c40de1f2d099e98e7f73598c094dd0 100644 (file)
@@ -18,7 +18,6 @@ import java.util.Set;
 import java.util.TreeMap;
 
 import org.apache.commons.lang.StringEscapeUtils;
-import org.opendaylight.yangtools.binding.generator.util.ReferencedTypeImpl;
 import org.opendaylight.yangtools.binding.generator.util.TypeConstants;
 import org.opendaylight.yangtools.binding.generator.util.Types;
 import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.EnumerationBuilderImpl;
@@ -62,7 +61,8 @@ public final class TypeProviderImpl implements TypeProvider {
 
     /**
      * The outter map maps module names to the map of the types for the module.
-     * The inner map maps the name of the concrete type to the JAVA <code>Type</code> (usually it is generated TO).
+     * The inner map maps the name of the concrete type to the JAVA
+     * <code>Type</code> (usually it is generated TO).
      */
     private Map<String, Map<String, Type>> genTypeDefsContextMap;
 
@@ -73,7 +73,7 @@ public final class TypeProviderImpl implements TypeProvider {
 
     /**
      * Creates new instance of class <code>TypeProviderImpl</code>.
-     * 
+     *
      * @param schemaContext
      *            contains the schema data red from YANG files
      * @throws IllegalArgumentException
@@ -92,7 +92,7 @@ public final class TypeProviderImpl implements TypeProvider {
 
     /**
      * Puts <code>refType</code> to map with key <code>refTypePath</code>
-     * 
+     *
      * @param refTypePath
      *            schema path used as the map key
      * @param refType
@@ -102,7 +102,7 @@ public final class TypeProviderImpl implements TypeProvider {
      *             <li>if <code>refTypePath</code> equal null</li>
      *             <li>if <code>refType</code> equal null</li>
      *             </ul>
-     * 
+     *
      */
     public void putReferencedType(final SchemaPath refTypePath, final Type refType) {
         if (refTypePath == null) {
@@ -116,9 +116,9 @@ public final class TypeProviderImpl implements TypeProvider {
     }
 
     /**
-     * 
+     *
      * Converts basic YANG type <code>type</code> to JAVA <code>Type</code>.
-     * 
+     *
      * @param type
      *            string with YANG name of type
      * @returns JAVA <code>Type</code> for YANG type <code>type</code>
@@ -134,7 +134,7 @@ public final class TypeProviderImpl implements TypeProvider {
     /**
      * Converts schema definition type <code>typeDefinition</code> to JAVA
      * <code>Type</code>
-     * 
+     *
      * @param typeDefinition
      *            type definition which is converted to JAVA type
      * @throws IllegalArgumentException
@@ -207,11 +207,11 @@ public final class TypeProviderImpl implements TypeProvider {
      * Seeks for identity reference <code>idref</code> the JAVA
      * <code>type</code>.<br />
      * <br />
-     * 
+     *
      * <i>Example:<br />
      * If identy which is referenced via <code>idref</code> has name <b>Idn</b>
      * then returning type is <b>{@code Class<? extends Idn>}</b></i>
-     * 
+     *
      * @param idref
      *            identityref type definition for which JAVA <code>Type</code>
      *            is sought
@@ -243,7 +243,7 @@ public final class TypeProviderImpl implements TypeProvider {
 
     /**
      * Converts <code>typeDefinition</code> to concrete JAVA <code>Type</code>.
-     * 
+     *
      * @param typeDefinition
      *            type definition which should be converted to JAVA
      *            <code>Type</code>
@@ -290,7 +290,7 @@ public final class TypeProviderImpl implements TypeProvider {
     /**
      * Gets base type definition for <code>extendTypeDef</code>. The method is
      * recursivelly called until non <code>ExtendedType</code> type is found.
-     * 
+     *
      * @param extendTypeDef
      *            type definition for which is the base type definition sought
      * @return type definition which is base type for <code>extendTypeDef</code>
@@ -312,10 +312,10 @@ public final class TypeProviderImpl implements TypeProvider {
 
     /**
      * Converts <code>leafrefType</code> to JAVA <code>Type</code>.
-     * 
+     *
      * The path of <code>leafrefType</code> is followed to find referenced node
      * and its <code>Type</code> is returned.
-     * 
+     *
      * @param leafrefType
      *            leafref type definition for which is the type sought
      * @return JAVA <code>Type</code> of data schema node which is referenced in
@@ -325,7 +325,7 @@ public final class TypeProviderImpl implements TypeProvider {
      *             <li>if <code>leafrefType</code> equal null</li>
      *             <li>if path statement of <code>leafrefType</code> equal null</li>
      *             </ul>
-     * 
+     *
      */
     public Type provideTypeForLeafref(final LeafrefTypeDefinition leafrefType) {
         Type returnType = null;
@@ -369,7 +369,7 @@ public final class TypeProviderImpl implements TypeProvider {
     /**
      * Checks if <code>dataNode</code> is <code>LeafSchemaNode</code> and if it
      * so then checks if it is of type <code>EnumTypeDefinition</code>.
-     * 
+     *
      * @param dataNode
      *            data schema node for which is checked if it is leaf and if it
      *            is of enum type
@@ -392,7 +392,7 @@ public final class TypeProviderImpl implements TypeProvider {
     /**
      * Checks if <code>dataNode</code> is <code>LeafListSchemaNode</code> and if
      * it so then checks if it is of type <code>EnumTypeDefinition</code>.
-     * 
+     *
      * @param dataNode
      *            data schema node for which is checked if it is leaflist and if
      *            it is of enum type
@@ -417,7 +417,7 @@ public final class TypeProviderImpl implements TypeProvider {
      * Converts <code>enumTypeDef</code> to
      * {@link org.opendaylight.yangtools.sal.binding.model.api.Enumeration
      * enumeration}.
-     * 
+     *
      * @param enumTypeDef
      *            enumeration type definition which is converted to enumeration
      * @param enumName
@@ -459,7 +459,7 @@ public final class TypeProviderImpl implements TypeProvider {
     /**
      * Adds enumeration to <code>typeBuilder</code>. The enumeration data are
      * taken from <code>enumTypeDef</code>.
-     * 
+     *
      * @param enumTypeDef
      *            enumeration type definition is source of enumeration data for
      *            <code>typeBuilder</code>
@@ -477,7 +477,7 @@ public final class TypeProviderImpl implements TypeProvider {
      *             <li>if name of <code>enumTypeDef</code> equal null</li>
      *             <li>if name of <code>typeBuilder</code> equal null</li>
      *             </ul>
-     * 
+     *
      */
     private Enumeration addInnerEnumerationToTypeBuilder(final EnumTypeDefinition enumTypeDef, final String enumName,
             final GeneratedTypeBuilder typeBuilder) {
@@ -507,7 +507,7 @@ public final class TypeProviderImpl implements TypeProvider {
     /**
      * Updates <code>enumBuilder</code> with data from <code>enumTypeDef</code>.
      * Specifically this data represents list of value-name pairs.
-     * 
+     *
      * @param enumTypeDef
      *            enum type definition as source of enum data for
      *            <code>enumBuilder</code>
@@ -538,7 +538,7 @@ public final class TypeProviderImpl implements TypeProvider {
 
     /**
      * Converts <code>dataNode</code> to JAVA <code>Type</code>.
-     * 
+     *
      * @param dataNode
      *            contains information about YANG type
      * @return JAVA <code>Type</code> representation of <code>dataNode</code>
@@ -560,7 +560,7 @@ public final class TypeProviderImpl implements TypeProvider {
     /**
      * Passes through all modules and through all its type definitions and
      * convert it to generated types.
-     * 
+     *
      * The modules are firstly sorted by mutual dependencies. The modules are
      * sequentially passed. All type definitions of a module are at the
      * beginning sorted so that type definition with less amount of references
@@ -569,7 +569,7 @@ public final class TypeProviderImpl implements TypeProvider {
      * {@link TypeProviderImpl#genTypeDefsContextMap genTypeDefsContextMap}
      * which map current module name to the map which maps type names to
      * returned types (generated types).
-     * 
+     *
      */
     private void resolveTypeDefsFromContext() {
         final Set<Module> modules = schemaContext.getModules();
@@ -605,7 +605,7 @@ public final class TypeProviderImpl implements TypeProvider {
     }
 
     /**
-     * 
+     *
      * @param basePackageName
      *            string with name of package to which the module belongs
      * @param moduleName
@@ -632,8 +632,9 @@ public final class TypeProviderImpl implements TypeProvider {
                     ExtendedType innerExtendedType = (ExtendedType) innerTypeDefinition;
                     returnType = provideGeneratedTOFromExtendedType(innerExtendedType, basePackageName, typedefName);
                 } else if (innerTypeDefinition instanceof UnionTypeDefinition) {
+                    final Module parentModule = findParentModuleForTypeDefinition(schemaContext, typedef);
                     final GeneratedTOBuilder genTOBuilder = provideGeneratedTOBuilderForUnionTypeDefinition(
-                            basePackageName, typedef, typedefName);
+                            basePackageName, typedef, typedefName, parentModule);
                     returnType = genTOBuilder.toInstance();
                 } else if (innerTypeDefinition instanceof EnumTypeDefinition) {
                     final EnumTypeDefinition enumTypeDef = (EnumTypeDefinition) innerTypeDefinition;
@@ -665,7 +666,7 @@ public final class TypeProviderImpl implements TypeProvider {
 
     /**
      * Wraps base YANG type to generated TO.
-     * 
+     *
      * @param basePackageName
      *            string with name of package to which the module belongs
      * @param typedef
@@ -703,7 +704,7 @@ public final class TypeProviderImpl implements TypeProvider {
      * Converts <code>typedef</code> to generated TO with
      * <code>typeDefName</code>. Every union type from <code>typedef</code> is
      * added to generated TO builder as property.
-     * 
+     *
      * @param basePackageName
      *            string with name of package to which the module belongs
      * @param typedef
@@ -720,7 +721,7 @@ public final class TypeProviderImpl implements TypeProvider {
      *             </ul>
      */
     public GeneratedTOBuilder provideGeneratedTOBuilderForUnionTypeDefinition(final String basePackageName,
-            final TypeDefinition<?> typedef, String typeDefName) {
+            final TypeDefinition<?> typedef, final String typeDefName, final Module parentModule) {
         if (basePackageName == null) {
             throw new IllegalArgumentException("Base Package Name cannot be NULL!");
         }
@@ -791,7 +792,8 @@ public final class TypeProviderImpl implements TypeProvider {
             }
 
             Map<String, Type> genTOsMap = null;
-            final Module parentModule = findParentModuleForTypeDefinition(schemaContext, typedef);
+            // final Module parentModule =
+            // findParentModuleForTypeDefinition(schemaContext, typedef);
             if (parentModule != null && parentModule.getName() != null) {
                 genTOsMap = genTypeDefsContextMap.get(parentModule.getName());
                 genTOsMap.put(typedef.getQName().getLocalName(), unionGenTransObject.toInstance());
@@ -805,7 +807,7 @@ public final class TypeProviderImpl implements TypeProvider {
     /**
      * Adds a new property with the name <code>propertyName</code> and with type
      * <code>type</code> to <code>unonGenTransObject</code>.
-     * 
+     *
      * @param unionGenTransObject
      *            generated TO to which should be property added
      * @param type
@@ -832,7 +834,7 @@ public final class TypeProviderImpl implements TypeProvider {
 
     /**
      * Converts <code>typedef</code> to the generated TO builder.
-     * 
+     *
      * @param basePackageName
      *            string with name of package to which the module belongs
      * @param typedef
@@ -857,10 +859,10 @@ public final class TypeProviderImpl implements TypeProvider {
     /**
      * Converts <code>typeDef</code> which should be of the type
      * <code>BitsTypeDefinition</code> to <code>GeneratedTOBuilder</code>.
-     * 
+     *
      * All the bits of the typeDef are added to returning generated TO as
      * properties.
-     * 
+     *
      * @param basePackageName
      *            string with name of package to which the module belongs
      * @param typeDef
@@ -911,13 +913,13 @@ public final class TypeProviderImpl implements TypeProvider {
     /**
      * Converts the pattern constraints from <code>typedef</code> to the list of
      * the strings which represents these constraints.
-     * 
+     *
      * @param typedef
      *            extended type in which are the pattern constraints sought
      * @return list of strings which represents the constraint patterns
      * @throws IllegalArgumentException
      *             if <code>typedef</code> equals null
-     * 
+     *
      */
     private List<String> resolveRegExpressionsFromTypedef(ExtendedType typedef) {
         final List<String> regExps = new ArrayList<String>();
@@ -941,10 +943,10 @@ public final class TypeProviderImpl implements TypeProvider {
     }
 
     /**
-     * 
+     *
      * Adds to the <code>genTOBuilder</code> the constant which contains regular
      * expressions from the <code>regularExpressions</code>
-     * 
+     *
      * @param genTOBuilder
      *            generated TO builder to which are
      *            <code>regular expressions</code> added
@@ -973,11 +975,11 @@ public final class TypeProviderImpl implements TypeProvider {
      * <code>innerExtendedType</code>, about the package name
      * <code>typedefName</code> and about the generated TO name
      * <code>typedefName</code>.
-     * 
+     *
      * It is supposed that <code>innerExtendedType</code> is already present in
      * {@link TypeProviderImpl#genTypeDefsContextMap genTypeDefsContextMap} to
      * be possible set it as extended type for the returning generated TO.
-     * 
+     *
      * @param innerExtendedType
      *            extended type which is part of some other extended type
      * @param basePackageName
@@ -1033,7 +1035,7 @@ public final class TypeProviderImpl implements TypeProvider {
      * equal depth. In next step are lists from this map concatenated to one
      * list in ascending order according to their depth. All type definitions
      * are in the list behind all type definitions on which depends.
-     * 
+     *
      * @param unsortedTypeDefinitions
      *            list of type definitions which should be sorted by depth
      * @return list of type definitions sorted according their each other
@@ -1067,7 +1069,7 @@ public final class TypeProviderImpl implements TypeProvider {
     /**
      * Returns how many immersion is necessary to get from the type definition
      * to the base type.
-     * 
+     *
      * @param typeDefinition
      *            type definition for which is depth sought.
      * @return number of immersions which are necessary to get from the type
index 1d841848de6914f362aac2ea38d8b46a39a56fd3..23528e52e4e2c8be7adbc2e94cb26ecdccb5ea58 100644 (file)
@@ -49,37 +49,18 @@ public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
      * @param maxRange
      * @param units
      */
-    public AbstractSignedInteger(final SchemaPath path, final QName name,
-            final String description, final Number minRange,
+    public AbstractSignedInteger(final QName name, final String description, final Number minRange,
             final Number maxRange, final String units) {
         this.name = name;
+        this.path = new SchemaPath(Collections.singletonList(name), true);
         this.description = description;
-        this.path = path;
         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,
+        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
-     * @param rangeStatements
-     * @param units
-     */
-    public AbstractSignedInteger(final SchemaPath path, final QName name,
-            final String description,
-            final List<RangeConstraint> rangeStatements, final String units) {
-        this.name = name;
-        this.description = description;
-        this.path = path;
-        this.units = units;
-        this.rangeStatements = rangeStatements;
-    }
-
     @Override
     public String getUnits() {
         return units;
@@ -124,14 +105,11 @@ public abstract class AbstractSignedInteger implements IntegerTypeDefinition {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result
-                + ((description == null) ? 0 : description.hashCode());
+        result = prime * result + ((description == null) ? 0 : description.hashCode());
         result = prime * result + ((name == null) ? 0 : name.hashCode());
         result = prime * result + ((path == null) ? 0 : path.hashCode());
-        result = prime * result
-                + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
-        result = prime * result
-                + ((reference == null) ? 0 : reference.hashCode());
+        result = prime * result + ((rangeStatements == null) ? 0 : rangeStatements.hashCode());
+        result = prime * result + ((reference == null) ? 0 : reference.hashCode());
         result = prime * result + ((units == null) ? 0 : units.hashCode());
         return result;
     }
index e93053c8021ca6094a59d3785008f0592fbff253..7d5a8f68d3b066c28b11466e0a150c4337df4975 100644 (file)
@@ -41,17 +41,15 @@ public abstract class AbstractUnsignedInteger implements UnsignedIntegerTypeDefi
 
     /**
      *
-     * @param path uint type schema path
-     * @param name qname
+     * @param name
      * @param description
      * @param maxRange
      * @param units
      */
-    public AbstractUnsignedInteger(final SchemaPath path, final QName name, final String description,
-            final Number maxRange, final String units) {
+    public AbstractUnsignedInteger(final QName name, final String description, final Number maxRange, final String units) {
         this.name = name;
+        this.path = new SchemaPath(Collections.singletonList(name), true);
         this.description = description;
-        this.path = path;
         this.units = units;
         this.rangeStatements = new ArrayList<RangeConstraint>();
         final String rangeDescription = "Integer values between " + MIN_VALUE + " and " + maxRange + ", inclusively.";
@@ -59,23 +57,6 @@ public abstract class AbstractUnsignedInteger implements UnsignedIntegerTypeDefi
                 "https://tools.ietf.org/html/rfc6020#section-9.2.4"));
     }
 
-    /**
-     *
-     * @param path uint type schema path
-     * @param name qname
-     * @param description
-     * @param rangeStatements
-     * @param units
-     */
-    public AbstractUnsignedInteger(final SchemaPath path, final QName name, final String description,
-            final List<RangeConstraint> rangeStatements, final String units) {
-        this.name = name;
-        this.description = description;
-        this.path = path;
-        this.units = units;
-        this.rangeStatements = rangeStatements;
-    }
-
     @Override
     public String getUnits() {
         return units;
index f08e012b2577578110631dbb761b36c218516123..76157fbcb115769eec7071cf7f928c298072f7d6 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.model.util;
 \r
 import java.net.URI;\r
 import java.util.ArrayList;\r
+import java.util.Collections;\r
 import java.util.Date;\r
 import java.util.List;\r
 \r
@@ -25,7 +26,7 @@ public final class BaseTypes {
     /**\r
      * Construct QName for Built-in base Yang type. The namespace for\r
      * built-in base yang types is defined as: urn:ietf:params:xml:ns:yang:1\r
-     * \r
+     *\r
      * @param typeName yang type name\r
      * @return built-in base yang type QName.\r
      */\r
@@ -35,20 +36,19 @@ public final class BaseTypes {
 \r
     /**\r
      * Creates Schema Path from Qname.\r
-     * \r
+     *\r
      * @param typeName yang type QName\r
      * @return Schema Path from Qname.\r
      */\r
     public static final SchemaPath schemaPath(final QName typeName) {\r
-        final List<QName> pathList = new ArrayList<QName>();\r
-        pathList.add(typeName);\r
+        List<QName> pathList = Collections.singletonList(typeName);\r
         return new SchemaPath(pathList, true);\r
     }\r
-    \r
+\r
     /**\r
      * Creates Schema Path from List of partial paths defined as Strings, module Namespace and\r
      * module latest Revision Date.\r
-     * \r
+     *\r
      * @param actualPath List of partial paths\r
      * @param namespace Module Namespace\r
      * @param revision Revision Date\r
index de7a3058ea437413e48ef2bc082551a9d2abd387..89a78d261470e8ea107702e27f40e9db52cec818 100644 (file)
@@ -24,33 +24,24 @@ import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
  * @see BinaryTypeDefinition
  */
 public final class BinaryType implements BinaryTypeDefinition {
+    private static final BinaryType INSTANCE = new BinaryType();
     private final QName name = BaseTypes.constructQName("binary");
-    private final SchemaPath path;
+    private final SchemaPath path = new SchemaPath(Collections.singletonList(name), true);
     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 final List<Byte> bytes;
     private final List<LengthConstraint> lengthConstraints;
     private final String units = "";
 
-    public BinaryType(final SchemaPath path) {
+    private BinaryType() {
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
-        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "",
-                ""));
+        constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
         this.lengthConstraints = Collections.unmodifiableList(constraints);
         this.bytes = Collections.emptyList();
-        this.path = path;
-        this.baseType = this;
     }
 
-    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.unmodifiableList(bytes);
-        this.path = path;
-        this.baseType = this;
+    public static BinaryType getInstance() {
+        return INSTANCE;
     }
 
     /*
@@ -61,7 +52,7 @@ public final class BinaryType implements BinaryTypeDefinition {
      */
     @Override
     public BinaryTypeDefinition getBaseType() {
-        return baseType;
+        return this;
     }
 
     /*
@@ -159,16 +150,11 @@ public final class BinaryType implements BinaryTypeDefinition {
         final int prime = 31;
         int result = 1;
         result = prime * result + ((bytes == null) ? 0 : bytes.hashCode());
-        result = prime * result
-                + ((description == null) ? 0 : description.hashCode());
-        result = prime
-                * result
-                + ((lengthConstraints == null) ? 0 : lengthConstraints
-                        .hashCode());
+        result = prime * result + ((description == null) ? 0 : description.hashCode());
+        result = prime * result + ((lengthConstraints == null) ? 0 : lengthConstraints.hashCode());
         result = prime * result + ((name == null) ? 0 : name.hashCode());
         result = prime * result + ((path == null) ? 0 : path.hashCode());
-        result = prime * result
-                + ((reference == null) ? 0 : reference.hashCode());
+        result = prime * result + ((reference == null) ? 0 : reference.hashCode());
         result = prime * result + ((units == null) ? 0 : units.hashCode());
         return result;
     }
index b20be97b39a5f8f603d006d1baa5e2c7fb5d8e9e..7ecba89748daf84d4fbf6208d62319e1eb27f22d 100644 (file)
@@ -22,35 +22,21 @@ import org.opendaylight.yangtools.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 static final BooleanType INSTANCE = new BooleanType();
+    private static final QName name = BaseTypes.constructQName("boolean");
+    private static final SchemaPath path = new SchemaPath(Collections.singletonList(name), true);
+    private static final String description = "The boolean built-in type represents a boolean value.";
+    private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.5";
     private final String units = "";
 
     /**
      * Default constructor with default value set to "false".
      */
-    public BooleanType(final SchemaPath path) {
-        super();
-        this.defaultValue = false;
-        this.path = path;
-        this.baseType = this;
+    private BooleanType() {
     }
 
-    /**
-     * Boolean Type constructor.
-     *
-     * @param defaultValue
-     *            Default Value
-     */
-    public BooleanType(final SchemaPath path, final Boolean defaultValue) {
-        super();
-        this.defaultValue = defaultValue;
-        this.path = path;
-        this.baseType = this;
+    public static BooleanType getInstance() {
+        return INSTANCE;
     }
 
     /*
@@ -61,7 +47,7 @@ public final class BooleanType implements BooleanTypeDefinition {
      */
     @Override
     public BooleanTypeDefinition getBaseType() {
-        return baseType;
+        return this;
     }
 
     /*
@@ -83,7 +69,7 @@ public final class BooleanType implements BooleanTypeDefinition {
      */
     @Override
     public Object getDefaultValue() {
-        return defaultValue;
+        return false;
     }
 
     /*
@@ -142,79 +128,6 @@ public final class BooleanType implements BooleanTypeDefinition {
         return Collections.emptyList();
     }
 
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        result = prime * result
-                + ((description == null) ? 0 : description.hashCode());
-        result = prime * result + ((name == null) ? 0 : name.hashCode());
-        result = prime * result + ((path == null) ? 0 : path.hashCode());
-        result = prime * result
-                + ((reference == null) ? 0 : reference.hashCode());
-        result = prime * result + ((units == null) ? 0 : units.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        BooleanType other = (BooleanType) obj;
-        if (defaultValue == null) {
-            if (other.defaultValue != null) {
-                return false;
-            }
-        } else if (!defaultValue.equals(other.defaultValue)) {
-            return false;
-        }
-        if (description == null) {
-            if (other.description != null) {
-                return false;
-            }
-        } else if (!description.equals(other.description)) {
-            return false;
-        }
-        if (name == null) {
-            if (other.name != null) {
-                return false;
-            }
-        } else if (!name.equals(other.name)) {
-            return false;
-        }
-        if (path == null) {
-            if (other.path != null) {
-                return false;
-            }
-        } else if (!path.equals(other.path)) {
-            return false;
-        }
-        if (reference == null) {
-            if (other.reference != null) {
-                return false;
-            }
-        } else if (!reference.equals(other.reference)) {
-            return false;
-        }
-        if (units == null) {
-            if (other.units != null) {
-                return false;
-            }
-        } else if (!units.equals(other.units)) {
-            return false;
-        }
-        return true;
-    }
-
     @Override
     public String toString() {
         StringBuilder builder = new StringBuilder();
@@ -222,14 +135,6 @@ public final class BooleanType implements BooleanTypeDefinition {
         builder.append(name);
         builder.append(", path=");
         builder.append(path);
-        builder.append(", description=");
-        builder.append(description);
-        builder.append(", reference=");
-        builder.append(reference);
-        builder.append(", defaultValue=");
-        builder.append(defaultValue);
-        builder.append(", units=");
-        builder.append(units);
         builder.append("]");
         return builder.toString();
     }
index 3648a179be34c8e26eac2a1c93e6c4d3da3de981..4a1200e129c1cbd28c2cee4f97ed7c3ee54d62e1 100644 (file)
@@ -17,20 +17,25 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.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;
-
-    public EmptyType(final SchemaPath path) {
-        this.path = path;
-        this.baseType = this;
+    private static EmptyType INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("empty");
+    private static final SchemaPath path = new SchemaPath(Collections.singletonList(NAME), true);
+    private static 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 static final String reference = "https://tools.ietf.org/html/rfc6020#page-131";
+
+    private EmptyType() {
+    }
+
+    public static EmptyType getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new EmptyType();
+        }
+        return INSTANCE;
     }
 
     @Override
     public EmptyTypeDefinition getBaseType() {
-        return baseType;
+        return this;
     }
 
     @Override
@@ -45,7 +50,7 @@ public final class EmptyType implements EmptyTypeDefinition {
 
     @Override
     public QName getQName() {
-        return name;
+        return NAME;
     }
 
     @Override
@@ -73,4 +78,9 @@ public final class EmptyType implements EmptyTypeDefinition {
         return Collections.emptyList();
     }
 
+    @Override
+    public String toString() {
+        return "type empty " + NAME;
+    }
+
 }
index 608c35c891ef8691e717d3ab373af1d222faa903..1af0fb8ff04cea9d35f28ce77f8397bd1dac403d 100644 (file)
@@ -25,29 +25,22 @@ import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefi
  */
 public final class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
     private static final QName name = BaseTypes.constructQName("instance-identifier");
+    private static final SchemaPath path = new SchemaPath(Collections.singletonList(name), true);
     private static final String description = "The instance-identifier built-in type is used to "
             + "uniquely identify a particular instance node in the data tree.";
     private static final String reference = "https://tools.ietf.org/html/rfc6020#section-9.13";
 
-    private final transient SchemaPath path;
     private final RevisionAwareXPath xpath;
-    private final String units = "";
-    private final InstanceIdentifierTypeDefinition baseType;
+    private static final String units = "";
     private boolean requireInstance = true;
 
-    public InstanceIdentifier(final SchemaPath path, final RevisionAwareXPath xpath) {
-        super();
-        this.path = path;
+    public InstanceIdentifier(final RevisionAwareXPath xpath) {
         this.xpath = xpath;
-        this.baseType = this;
     }
 
-    public InstanceIdentifier(final SchemaPath path, final RevisionAwareXPath xpath, final boolean requireInstance) {
-        super();
-        this.path = path;
+    public InstanceIdentifier(final RevisionAwareXPath xpath, final boolean requireInstance) {
         this.xpath = xpath;
         this.requireInstance = requireInstance;
-        this.baseType = this;
     }
 
     /*
@@ -58,7 +51,7 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
      */
     @Override
     public InstanceIdentifierTypeDefinition getBaseType() {
-        return baseType;
+        return this;
     }
 
     /*
@@ -168,4 +161,32 @@ public final class InstanceIdentifier implements InstanceIdentifierTypeDefinitio
         return requireInstance;
     }
 
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + (requireInstance ? 1231 : 1237);
+        result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj)
+            return true;
+        if (obj == null)
+            return false;
+        if (getClass() != obj.getClass())
+            return false;
+        InstanceIdentifier other = (InstanceIdentifier) obj;
+        if (requireInstance != other.requireInstance)
+            return false;
+        if (xpath == null) {
+            if (other.xpath != null)
+                return false;
+        } else if (!xpath.equals(other.xpath))
+            return false;
+        return true;
+    }
+
 }
index e24a07038d427646d4daac66909dcdfd58c9117d..629e9ff7d3969af347fdbaae4ba25dd5cf440a01 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 
 /**
@@ -19,66 +18,34 @@ import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
  * @see AbstractSignedInteger
  */
 public final class Int16 extends AbstractSignedInteger {
-    private static final QName name = BaseTypes.constructQName("int16");
-    private final Short defaultValue = null;
-    private static final String description = "int16  represents integer values between -32768 and 32767, inclusively.";
-    private final IntegerTypeDefinition baseType;
+    private static Int16 INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("int16");
+    private static final String DESCRIPTION = "int16  represents integer values between -32768 and 32767, inclusively.";
 
-    public Int16(final SchemaPath path) {
-        super(path, name, description, Short.MIN_VALUE, Short.MAX_VALUE, "");
-        this.baseType = this;
+    private Int16() {
+        super(NAME, DESCRIPTION, Short.MIN_VALUE, Short.MAX_VALUE, "");
+    }
 
+    public static Int16 getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new Int16();
+        }
+        return INSTANCE;
     }
 
     @Override
     public IntegerTypeDefinition getBaseType() {
-        return baseType;
+        return this;
     }
 
     @Override
     public Object getDefaultValue() {
-        return defaultValue;
-    }
-
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        Int16 other = (Int16) obj;
-        if (defaultValue == null) {
-            if (other.defaultValue != null) {
-                return false;
-            }
-        } else if (!defaultValue.equals(other.defaultValue)) {
-            return false;
-        }
-        return true;
+        return null;
     }
 
     @Override
     public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("Int16 [defaultValue=");
-        builder.append(defaultValue);
-        builder.append(", AbstractInteger=");
-        builder.append(super.toString());
-        builder.append("]");
-        return builder.toString();
+        return "type " + NAME;
     }
+
 }
index bafce08d979dace761c2a366f658efde8ce1dc78..82f278c40f8bc36a86787e838f524567cf640827 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 
 /**
@@ -21,78 +20,33 @@ import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
  *
  */
 public final class Int32 extends AbstractSignedInteger {
-    private static final QName name = BaseTypes.constructQName("int32");
-    private final Integer defaultValue = null;
-    private static final String description = "int32  represents integer values between -2147483648 and 2147483647, inclusively.";
-    private final IntegerTypeDefinition baseType;
+    private static Int32 INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("int32");
+    private static final String DESCRIPTION = "int32  represents integer values between -2147483648 and 2147483647, inclusively.";
 
-    public Int32(final SchemaPath path) {
-        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
-        this.baseType = this;
+    private Int32() {
+        super(Int32.NAME, Int32.DESCRIPTION, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
-     */
-    @Override
-    public IntegerTypeDefinition getBaseType() {
-        return baseType;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
-     * ()
-     */
-    @Override
-    public Object getDefaultValue() {
-        return defaultValue;
+    public static Int32 getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new Int32();
+        }
+        return INSTANCE;
     }
 
     @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        return result;
+    public IntegerTypeDefinition getBaseType() {
+        return this;
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        Int32 other = (Int32) obj;
-        if (defaultValue == null) {
-            if (other.defaultValue != null) {
-                return false;
-            }
-        } else if (!defaultValue.equals(other.defaultValue)) {
-            return false;
-        }
-        return true;
+    public Object getDefaultValue() {
+        return null;
     }
 
     @Override
     public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("Int32 [defaultValue=");
-        builder.append(defaultValue);
-        builder.append(", AbstractInteger=");
-        builder.append(super.toString());
-        builder.append("]");
-        return builder.toString();
+        return "type " + NAME;
     }
 }
index eb733b21fae0ebdbf72035f2a890754c43b503d3..0800f3c8c59199ed484e7ec75251a6aac67d85ba 100644 (file)
@@ -1,94 +1,51 @@
 /*
 * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
 * and is available at http://www.eclipse.org/legal/epl-v10.html
 */
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
 package org.opendaylight.yangtools.yang.model.util;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 
 /**
  * Implementation of Yang int64 built-in type. <br>
- * int64  represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.
- * The Java counterpart of Yang int64 built-in type is
- * {@link Long}.
+ * int64 represents integer values between -9223372036854775808 and
+ * 9223372036854775807, inclusively. The Java counterpart of Yang int64 built-in
+ * type is {@link Long}.
  *
  */
 public final class Int64 extends AbstractSignedInteger {
-    private static final QName name = BaseTypes.constructQName("int64");
-    private final Long defaultValue = null;
-    private static final String description =
-            "int64  represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.";
-    private final IntegerTypeDefinition baseType;
-
-    public Int64(final SchemaPath path) {
-        super(path, name, description, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
-        this.baseType = this;
-    }
+    private static Int64 INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("int64");
+    private static final String DESCRIPTION = "int64  represents integer values between -9223372036854775808 and 9223372036854775807, inclusively.";
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
-     */
-    @Override
-    public IntegerTypeDefinition getBaseType() {
-        return baseType;
+    private Int64() {
+        super(NAME, DESCRIPTION, Integer.MIN_VALUE, Integer.MAX_VALUE, "");
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue()
-     */
-    @Override
-    public Object getDefaultValue() {
-        return defaultValue;
+    public static Int64 getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new Int64();
+        }
+        return INSTANCE;
     }
 
     @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        return result;
+    public IntegerTypeDefinition getBaseType() {
+        return this;
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        Int64 other = (Int64) obj;
-        if (defaultValue == null) {
-            if (other.defaultValue != null) {
-                return false;
-            }
-        } else if (!defaultValue.equals(other.defaultValue)) {
-            return false;
-        }
-        return true;
+    public Object getDefaultValue() {
+        return null;
     }
 
     @Override
     public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("Int64 [defaultValue=");
-        builder.append(defaultValue);
-        builder.append(", AbstractInteger=");
-        builder.append(super.toString());
-        builder.append("]");
-        return builder.toString();
+        return "type " + NAME;
     }
+
 }
index cd295f14402f8c23512a6690b1785b301a769c21..537eef44de1f66fc02e0cc67c39dd0ef4bda1ff4 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 
 /**
@@ -19,78 +18,34 @@ import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
  * @see AbstractSignedInteger
  */
 public final class Int8 extends AbstractSignedInteger {
-    private static final QName name = BaseTypes.constructQName("int8");
-    private final Byte defaultValue = null;
-    private static final String description = "represents integer values between -128 and 127, inclusively.";
-    private final IntegerTypeDefinition baseType;
+    private static Int8 INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("int8");
+    private static final String DESCRIPTION = "represents integer values between -128 and 127, inclusively.";
 
-    public Int8(final SchemaPath path) {
-        super(path, name, description, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
-        this.baseType = this;
+    private Int8() {
+        super(NAME, DESCRIPTION, Byte.MIN_VALUE, Byte.MAX_VALUE, "");
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
-     */
-    @Override
-    public IntegerTypeDefinition getBaseType() {
-        return baseType;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
-     * ()
-     */
-    @Override
-    public Object getDefaultValue() {
-        return defaultValue;
+    public static Int8 getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new Int8();
+        }
+        return INSTANCE;
     }
 
     @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result
-                + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        return result;
+    public IntegerTypeDefinition getBaseType() {
+        return this;
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        Int8 other = (Int8) obj;
-        if (defaultValue == null) {
-            if (other.defaultValue != null) {
-                return false;
-            }
-        } else if (!defaultValue.equals(other.defaultValue)) {
-            return false;
-        }
-        return true;
+    public Object getDefaultValue() {
+        return null;
     }
 
     @Override
     public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("Int8 [defaultValue=");
-        builder.append(defaultValue);
-        builder.append(", AbstractInteger=");
-        builder.append(super.toString());
-        builder.append("]");
-        return builder.toString();
+        return "type " + NAME;
     }
+
 }
index 6be448956bfdd858adca8622344e97a4eb74b8b4..bad6067a417c65543810ae76ef1610ceea5ae30b 100644 (file)
@@ -25,27 +25,28 @@ import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
  * @see StringTypeDefinition
  */
 public final class StringType implements StringTypeDefinition {
+    private static final StringType INSTANCE = new StringType();
     private final QName name = BaseTypes.constructQName("string");
-    private final SchemaPath path;
+    private final SchemaPath path = new SchemaPath(Collections.singletonList(name), true);
     private final String defaultValue = "";
     private final String description = "";
     private final String reference = "";
     private final List<LengthConstraint> lengthStatements;
     private final List<PatternConstraint> patterns;
     private final String units = "";
-    private final StringTypeDefinition baseType;
 
     /**
      * Default Constructor.
      */
-    public StringType(final SchemaPath path) {
-        super();
-        this.path = path;
+    private StringType() {
         final List<LengthConstraint> constraints = new ArrayList<LengthConstraint>();
         constraints.add(BaseConstraints.lengthConstraint(0, Long.MAX_VALUE, "", ""));
         lengthStatements = Collections.unmodifiableList(constraints);
         patterns = Collections.emptyList();
-        baseType = this;
+    }
+
+    public static StringType getIntance() {
+        return INSTANCE;
     }
 
     /*
@@ -55,7 +56,7 @@ public final class StringType implements StringTypeDefinition {
      */
     @Override
     public StringTypeDefinition getBaseType() {
-        return baseType;
+        return this;
     }
 
     /*
index 0a45f8aa0b5fa33be7370972dd42e0b780c41558..05cead85ff07f8f51e9f0de5e66545bd2cfe4f3b 100644 (file)
@@ -8,89 +8,44 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 /**
- * Implementation of Yang uint32 built-in type. <br>
+ * Implementation of Yang uint16 built-in type. <br>
  * uint16 represents integer values between 0 and 65535, inclusively. The Java
- * counterpart of Yang uint32 built-in type is {@link Integer}.
+ * counterpart of Yang uint16 built-in type is {@link Integer}.
  *
  */
 public final class Uint16 extends AbstractUnsignedInteger {
     public static final int MAX_VALUE = 65535;
-    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 static Uint16 INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("uint16");
+    private static final String DESCRIPTION = "uint16 represents integer values between 0 and 65535, inclusively.";
 
-    public Uint16(final SchemaPath path) {
-        super(path, name, description, MAX_VALUE, "");
-        this.baseType = this;
+    private Uint16() {
+        super(NAME, DESCRIPTION, MAX_VALUE, "");
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
-     */
-    @Override
-    public UnsignedIntegerTypeDefinition getBaseType() {
-        return baseType;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
-     * ()
-     */
-    @Override
-    public Object getDefaultValue() {
-        return defaultValue;
+    public static Uint16 getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new Uint16();
+        }
+        return INSTANCE;
     }
 
     @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        return result;
+    public UnsignedIntegerTypeDefinition getBaseType() {
+        return this;
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        Uint16 other = (Uint16) obj;
-        if (defaultValue == null) {
-            if (other.defaultValue != null) {
-                return false;
-            }
-        } else if (!defaultValue.equals(other.defaultValue)) {
-            return false;
-        }
-        return true;
+    public Object getDefaultValue() {
+        return null;
     }
 
     @Override
     public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("Uint16 [defaultValue=");
-        builder.append(defaultValue);
-        builder.append(", AbstractInteger=");
-        builder.append(super.toString());
-        builder.append("]");
-        return builder.toString();
+        return "type " + NAME;
     }
 
 }
index d104e4c5960345f258f339c8182df31d0d1199ca..d5d3e9efe6b885d1c37ab0e318e7a512a85c0fed 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 /**
@@ -18,78 +17,34 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  */
 public final class Uint32 extends AbstractUnsignedInteger {
     public static final long MAX_VALUE = 4294967295L;
-    private static final QName name = BaseTypes.constructQName("uint32");
-    private final Long defaultValue = null;
-    private static final String description = "uint32 represents integer values between 0 and 4294967295, inclusively.";
-    private final UnsignedIntegerTypeDefinition baseType;
+    private static Uint32 INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("uint32");
+    private static final String DESCRIPTION = "uint32 represents integer values between 0 and 4294967295, inclusively.";
 
-    public Uint32(final SchemaPath path) {
-        super(path, name, description, MAX_VALUE, "");
-        this.baseType = this;
+    private Uint32() {
+        super(NAME, DESCRIPTION, MAX_VALUE, "");
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
-     */
-    @Override
-    public UnsignedIntegerTypeDefinition getBaseType() {
-        return baseType;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
-     * ()
-     */
-    @Override
-    public Object getDefaultValue() {
-        return defaultValue;
+    public static Uint32 getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new Uint32();
+        }
+        return INSTANCE;
     }
 
     @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        return result;
+    public UnsignedIntegerTypeDefinition getBaseType() {
+        return this;
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        Uint32 other = (Uint32) obj;
-        if (defaultValue == null) {
-            if (other.defaultValue != null) {
-                return false;
-            }
-        } else if (!defaultValue.equals(other.defaultValue)) {
-            return false;
-        }
-        return true;
+    public Object getDefaultValue() {
+        return null;
     }
 
     @Override
     public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("Uint32 [defaultValue=");
-        builder.append(defaultValue);
-        builder.append(", AbstractInteger=");
-        builder.append(super.toString());
-        builder.append("]");
-        return builder.toString();
+        return "type " + NAME;
     }
 
 }
index 7f9dc656055e40ff1baa93ec816b4bb0c1b993d7..078b569e15293ac2f7377872de8f7c4cfbb59530 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.model.util;
 import java.math.BigInteger;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 /**
@@ -22,78 +21,34 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  */
 public final class Uint64 extends AbstractUnsignedInteger {
     public static final BigInteger MAX_VALUE = new BigInteger("18446744073709551615");
-    private static final QName name = BaseTypes.constructQName("uint64");
-    private final BigInteger defaultValue = null;
-    private static final String description = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
-    private final UnsignedIntegerTypeDefinition baseType;
+    private static Uint64 INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("uint64");
+    private static final String DESCRIPTION = "uint64 represents integer values between 0 and 18446744073709551615, inclusively.";
 
-    public Uint64(final SchemaPath path) {
-        super(path, name, description, MAX_VALUE, "");
-        this.baseType = this;
+    private Uint64() {
+        super(NAME, DESCRIPTION, MAX_VALUE, "");
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
-     */
-    @Override
-    public UnsignedIntegerTypeDefinition getBaseType() {
-        return baseType;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
-     * ()
-     */
-    @Override
-    public Object getDefaultValue() {
-        return defaultValue;
+    public static Uint64 getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new Uint64();
+        }
+        return INSTANCE;
     }
 
     @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        return result;
+    public UnsignedIntegerTypeDefinition getBaseType() {
+        return this;
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        Uint64 other = (Uint64) obj;
-        if (defaultValue == null) {
-            if (other.defaultValue != null) {
-                return false;
-            }
-        } else if (!defaultValue.equals(other.defaultValue)) {
-            return false;
-        }
-        return true;
+    public Object getDefaultValue() {
+        return null;
     }
 
     @Override
     public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("Uint64 [defaultValue=");
-        builder.append(defaultValue);
-        builder.append(", AbstractInteger=");
-        builder.append(super.toString());
-        builder.append("]");
-        return builder.toString();
+        return "type " + NAME;
     }
 
 }
index ff8485cd790d7bc55ef9b44b3008806454059348..4befa856ec0e68a15dbdcb11608f19a5a57fd108 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.model.util;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 
 /**
@@ -19,78 +18,34 @@ import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinit
  */
 public final class Uint8 extends AbstractUnsignedInteger {
     public static final int MAX_VALUE = 255;
-    private static final QName name = BaseTypes.constructQName("uint8");
-    private final Short defaultValue = null;
-    private static final String description = "uint8  represents integer values between 0 and 255, inclusively.";
-    private final UnsignedIntegerTypeDefinition baseType;
+    private static Uint8 INSTANCE;
+    private static final QName NAME = BaseTypes.constructQName("uint8");
+    private static final String DESCRIPTION = "uint8  represents integer values between 0 and 255, inclusively.";
 
-    public Uint8(final SchemaPath path) {
-        super(path, name, description, MAX_VALUE, "");
-        this.baseType = this;
+    private Uint8() {
+        super(NAME, DESCRIPTION, MAX_VALUE, "");
     }
 
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getBaseType()
-     */
-    @Override
-    public UnsignedIntegerTypeDefinition getBaseType() {
-        return baseType;
-    }
-
-    /*
-     * (non-Javadoc)
-     *
-     * @see
-     * org.opendaylight.yangtools.yang.model.api.TypeDefinition#getDefaultValue
-     * ()
-     */
-    @Override
-    public Object getDefaultValue() {
-        return defaultValue;
+    public static Uint8 getInstance() {
+        if (INSTANCE == null) {
+            INSTANCE = new Uint8();
+        }
+        return INSTANCE;
     }
 
     @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = super.hashCode();
-        result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
-        return result;
+    public UnsignedIntegerTypeDefinition getBaseType() {
+        return this;
     }
 
     @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (!super.equals(obj)) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        Uint8 other = (Uint8) obj;
-        if (defaultValue == null) {
-            if (other.defaultValue != null) {
-                return false;
-            }
-        } else if (!defaultValue.equals(other.defaultValue)) {
-            return false;
-        }
-        return true;
+    public Object getDefaultValue() {
+        return null;
     }
 
     @Override
     public String toString() {
-        StringBuilder builder = new StringBuilder();
-        builder.append("Uint8 [defaultValue=");
-        builder.append(defaultValue);
-        builder.append(", AbstractInteger=");
-        builder.append(super.toString());
-        builder.append("]");
-        return builder.toString();
+        return "type " + NAME;
     }
 
 }
index 470e904b9d4e5d7f07e438c7bccc036d7fbce1c7..81bda38776c8dca0e6758336644aa19c7caf5800 100644 (file)
@@ -18,37 +18,23 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
 
 public final class UnionType implements UnionTypeDefinition {
-
     private final QName name = BaseTypes.constructQName("union");
-    private final SchemaPath path;
+    private final SchemaPath path = BaseTypes.schemaPath(name);
     private final String description = "The union built-in type represents a value that corresponds to one of its member types.";
     private final String reference = "https://tools.ietf.org/html/rfc6020#section-9.12";
-    private final UnionTypeDefinition baseType;
     private final List<TypeDefinition<?>> types;
 
-    private UnionType(List<TypeDefinition<?>> types) {
-        if (types == null) {
-            throw new NullPointerException(
-                    "When the type is 'union', the 'type' statement MUST be present.");
-        }
-        path = BaseTypes.schemaPath(name);
-        this.types = types;
-        this.baseType = this;
-    }
-
-    public UnionType(final SchemaPath path, List<TypeDefinition<?>> types) {
+    public UnionType(List<TypeDefinition<?>> types) {
         if (types == null) {
             throw new NullPointerException(
                     "When the type is 'union', the 'type' statement MUST be present.");
         }
-        this.path = path;
         this.types = types;
-        this.baseType = new UnionType(types);
     }
 
     @Override
     public UnionTypeDefinition getBaseType() {
-        return baseType;
+        return this;
     }
 
     @Override
@@ -100,8 +86,6 @@ public final class UnionType implements UnionTypeDefinition {
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((name == null) ? 0 : name.hashCode());
-        result = prime * result + ((path == null) ? 0 : path.hashCode());
         result = prime * result + ((types == null) ? 0 : types.hashCode());
         return result;
     }
@@ -118,11 +102,7 @@ public final class UnionType implements UnionTypeDefinition {
             return false;
         }
         UnionType other = (UnionType) obj;
-        if (types == null) {
-            if (other.types != null) {
-                return false;
-            }
-        } else if (!types.equals(other.types)) {
+        if (!types.equals(other.types)) {
             return false;
         }
         return true;
@@ -131,14 +111,13 @@ public final class UnionType implements UnionTypeDefinition {
     @Override
     public String toString() {
         StringBuilder builder = new StringBuilder();
-        builder.append("UnionType [name=");
+        builder.append("type ");
         builder.append(name);
-        builder.append("types=[");
+        builder.append(" (types=[");
         for (TypeDefinition<?> td : types) {
             builder.append(", " + td.getQName().getLocalName());
         }
         builder.append("]");
-        builder.append("]");
         return builder.toString();
     }
 
index f7ea048a0780003c444c1516a8f3a8dae802f0ed..7b75a30247bd72af8773b71bfe7018cd74d11dc1 100644 (file)
@@ -10,7 +10,6 @@ package org.opendaylight.yangtools.yang.model.util;
 import java.util.HashSet;\r
 import java.util.Set;\r
 \r
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;\r
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;\r
 \r
 public final class YangTypesConverter {\r
@@ -42,39 +41,40 @@ public final class YangTypesConverter {
         return baseYangTypes.contains(type);\r
     }\r
 \r
-    public static TypeDefinition<?> javaTypeForBaseYangType(SchemaPath path, String typeName) {\r
+    public static TypeDefinition<?> javaTypeForBaseYangType(String typeName) {\r
         TypeDefinition<?> type = null;\r
 \r
         if (typeName.startsWith("int")) {\r
             if ("int8".equals(typeName)) {\r
-                type = new Int8(path);\r
+                type = Int8.getInstance();\r
             } else if ("int16".equals(typeName)) {\r
-                type = new Int16(path);\r
+                type = Int16.getInstance();\r
             } else if ("int32".equals(typeName)) {\r
-                type = new Int32(path);\r
+                type = Int32.getInstance();\r
             } else if ("int64".equals(typeName)) {\r
-                type = new Int64(path);\r
+                type = Int64.getInstance();\r
             }\r
         } else if (typeName.startsWith("uint")) {\r
             if ("uint8".equals(typeName)) {\r
-                type = new Uint8(path);\r
+                type = Uint8.getInstance();\r
             } else if ("uint16".equals(typeName)) {\r
-                type = new Uint16(path);\r
+                type = Uint16.getInstance();\r
             } else if ("uint32".equals(typeName)) {\r
-                type = new Uint32(path);\r
+                type = Uint32.getInstance();\r
             } else if ("uint64".equals(typeName)) {\r
-                type = new Uint64(path);\r
+                type = Uint64.getInstance();\r
             }\r
         } else if ("string".equals(typeName)) {\r
-            type = new StringType(path);\r
+            type = StringType.getIntance();\r
         } else if("binary".equals(typeName)) {\r
-            type = new BinaryType(path);\r
+            type = BinaryType.getInstance();\r
         } else if("boolean".equals(typeName)) {\r
-            type = new BooleanType(path);\r
+            type = BooleanType.getInstance();\r
         } else if("empty".equals(typeName)) {\r
-            type = new EmptyType(path);\r
+            type = EmptyType.getInstance();\r
         } else if("instance-identifier".equals(typeName)) {\r
-            type = new InstanceIdentifier(path, null, true);\r
+            // FIXME\r
+            type = new InstanceIdentifier(null, true);\r
         }\r
 \r
         return type;\r
index 29598ce8931b71a235a6a55184883fb121c3c619..301a5a3c571bf0f601d7efd0da4eef720f4081b3 100644 (file)
@@ -11,6 +11,7 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
 
+import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
@@ -32,14 +33,13 @@ import org.opendaylight.yangtools.yang.parser.util.YangParseException;
  */
 public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements TypeDefinitionBuilder {
     private final static String NAME = "union";
+    private final static QName QNAME = BaseTypes.constructQName(NAME);
 
     private final List<TypeDefinition<?>> types;
     private final List<TypeDefinitionBuilder> typedefs;
     private UnionType instance;
     private boolean isBuilt;
 
-    private SchemaPath path;
-
     public UnionTypeBuilder(final String moduleName, final int line) {
         super(moduleName, line, BaseTypes.constructQName(NAME));
         types = new ArrayList<TypeDefinition<?>>();
@@ -77,7 +77,7 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
     @Override
     public UnionType build() {
         if (!isBuilt) {
-            instance = new UnionType(path, types);
+            instance = new UnionType(types);
             for (TypeDefinitionBuilder tdb : typedefs) {
                 types.add(tdb.build());
             }
@@ -88,7 +88,7 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setPath(final SchemaPath schemaPath) {
-        this.path = schemaPath;
+        throw new YangParseException(moduleName, line, "Can not set path to " + NAME);
     }
 
     @Override
@@ -128,7 +128,7 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public SchemaPath getPath() {
-        return path;
+        return BaseTypes.schemaPath(QNAME);
     }
 
     @Override
index 604a0c2fcff05a263ea1bcbfd02e1bd9f1af4454..75fa0f2f2f6dc6e81314588f117056bd2037ca5e 100644 (file)
@@ -19,7 +19,6 @@ import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Date;
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.List;
@@ -43,7 +42,6 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
 import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
 import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
@@ -52,7 +50,6 @@ import org.opendaylight.yangtools.yang.parser.builder.api.DataNodeContainerBuild
 import org.opendaylight.yangtools.yang.parser.builder.api.GroupingBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.SchemaNodeBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.TypeAwareBuilder;
-import org.opendaylight.yangtools.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.impl.DeviationBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.impl.ExtensionBuilder;
@@ -61,7 +58,6 @@ import org.opendaylight.yangtools.yang.parser.builder.impl.IdentityrefTypeBuilde
 import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.impl.UnionTypeBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
-import org.opendaylight.yangtools.yang.parser.util.CopyUtils;
 import org.opendaylight.yangtools.yang.parser.util.GroupingUtils;
 import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort;
 import org.opendaylight.yangtools.yang.parser.util.ParserUtils;
@@ -285,7 +281,6 @@ public final class YangParserImpl implements YangModelParser {
                 fixUnresolvedNodes(modules, moduleBuilder);
             }
         }
-        finishResolveDirtyNodes(modules);
         resolveAugments(modules);
         resolveUses(modules);
         resolveDeviations(modules);
@@ -315,7 +310,6 @@ public final class YangParserImpl implements YangModelParser {
                 fixUnresolvedNodesWithContext(modules, moduleBuilder, context);
             }
         }
-        finishResolveDirtyNodes(modules);
         resolveAugmentsWithContext(modules, context);
         resolveUsesWithContext(modules, context);
         resolveDeviationsWithContext(modules, context);
@@ -374,45 +368,6 @@ public final class YangParserImpl implements YangModelParser {
         }
     }
 
-    private void finishResolveDirtyNodes(final Map<String, TreeMap<Date, ModuleBuilder>> modules) {
-        final Set<TypeAwareBuilder> dirtyNodes = new HashSet<>();
-        for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
-            for (Map.Entry<Date, ModuleBuilder> inner : entry.getValue().entrySet()) {
-                dirtyNodes.addAll(inner.getValue().getDirtyNodes());
-            }
-        }
-
-        if (!dirtyNodes.isEmpty()) {
-            for (TypeAwareBuilder nodeToResolve : dirtyNodes) {
-                if (nodeToResolve instanceof UnionTypeBuilder) {
-                    List<TypeDefinitionBuilder> newTypes = new ArrayList<>();
-                    List<TypeDefinitionBuilder> oldTypes = ((UnionTypeBuilder) nodeToResolve).getTypedefs();
-                    for (TypeDefinitionBuilder tdb : oldTypes) {
-                        TypeDefinitionBuilder newType = CopyUtils.copy(tdb, nodeToResolve, false);
-                        ParserUtils.correctTypeAwareNodePath(newType);
-                        newTypes.add(newType);
-                    }
-                    oldTypes.clear();
-                    oldTypes.addAll(newTypes);
-                } else if (nodeToResolve.getType() instanceof IdentityrefType) {
-                    TypeDefinition<?> idRef = ParserUtils.createCorrectTypeDefinition(nodeToResolve.getPath(),
-                            nodeToResolve.getType());
-                    nodeToResolve.setType(idRef);
-                } else {
-                    if (nodeToResolve.getType() == null) {
-                        TypeDefinitionBuilder tdb = CopyUtils.copy(nodeToResolve.getTypedef(), nodeToResolve, false);
-                        ParserUtils.correctTypeAwareNodePath(tdb);
-                        nodeToResolve.setTypedef(tdb);
-                    } else {
-                        TypeDefinition<?> td = ParserUtils.createCorrectTypeDefinition(nodeToResolve.getPath(),
-                                nodeToResolve.getType());
-                        nodeToResolve.setType(td);
-                    }
-                }
-            }
-        }
-    }
-
     private void resolveDirtyNodesWithContext(final Map<String, TreeMap<Date, ModuleBuilder>> modules,
             final ModuleBuilder module, SchemaContext context) {
         final Set<TypeAwareBuilder> dirtyNodes = module.getDirtyNodes();
index 5607f0d53a811306f304f9ec26881ad2a52902e9..cd9f2f49fb94257066cf7324bf45f619ba1c66d9 100644 (file)
@@ -377,21 +377,17 @@ public final class YangParserListenerImpl extends YangParserBaseListener {
                 // check for types which must have body
                 checkMissingBody(typeName, moduleName, line);
                 // if there are no constraints, just grab default base yang type
-                QName qname = BaseTypes.constructQName(typeName);
-                addNodeToPath(qname);
-                SchemaPath path = createActualSchemaPath(actualPath.peek());
-                type = YangTypesConverter.javaTypeForBaseYangType(path, typeName);
+                type = YangTypesConverter.javaTypeForBaseYangType(typeName);
+                addNodeToPath(type.getQName());
                 moduleBuilder.setType(type);
             } else {
                 if ("union".equals(typeName)) {
                     QName qname = BaseTypes.constructQName("union");
                     addNodeToPath(qname);
-                    SchemaPath path = createActualSchemaPath(actualPath.peek());
                     UnionTypeBuilder unionBuilder = moduleBuilder.addUnionType(line, namespace, revision);
                     Builder parent = moduleBuilder.getActualNode();
                     unionBuilder.setParent(parent);
                     moduleBuilder.enterNode(unionBuilder);
-                    unionBuilder.setPath(path);
                 } else if ("identityref".equals(typeName)) {
                     QName qname = BaseTypes.constructQName("identityref");
                     addNodeToPath(qname);
index 225b471a558bb3d3a7fe78e782e7bc57016102ff..f651e4c6af4dd991acc0a64fa4dce795fa3d05e7 100644 (file)
@@ -233,7 +233,7 @@ public class CopyUtils {
         if (old.getType() == null) {
             copy.setTypedef(copy(old.getTypedef(), copy, updateQName));
         } else {
-            copy.setType(ParserUtils.createCorrectTypeDefinition(copy.getPath(), old.getType()));
+            copy.setType(old.getType());
         }
 
         copy.setDefaultStr(old.getDefaultStr());
@@ -265,7 +265,7 @@ public class CopyUtils {
         if (old.getType() == null) {
             copy.setTypedef(copy(old.getTypedef(), copy, updateQName));
         } else {
-            copy.setType(ParserUtils.createCorrectTypeDefinition(copy.getPath(), old.getType()));
+            copy.setType(old.getType());
         }
 
         copy.setUserOrdered(old.isUserOrdered());
@@ -359,9 +359,8 @@ public class CopyUtils {
             UnionTypeBuilder oldUnion = (UnionTypeBuilder)old;
             type = new UnionTypeBuilder(newParent.getModuleName(), newParent.getLine());
             type.setParent(newParent);
-            type.setPath(newSchemaPath);
             for(TypeDefinition<?> td : oldUnion.getTypes()) {
-                type.setType(ParserUtils.createCorrectTypeDefinition(type.getPath(), td));
+                type.setType(td);
             }
             for(TypeDefinitionBuilder tdb : oldUnion.getTypedefs()) {
                 type.setTypedef(copy(tdb, type, updateQName));
@@ -379,7 +378,7 @@ public class CopyUtils {
             if (old.getType() == null) {
                 type.setTypedef(copy(old.getTypedef(), type, updateQName));
             } else {
-                type.setType(ParserUtils.createCorrectTypeDefinition(type.getPath(), old.getType()));
+                type.setType(old.getType());
             }
 
             for (UnknownSchemaNodeBuilder un : old.getUnknownNodeBuilders()) {
index 0766b781ab4dee065e040d049474107020d51c24..9a71a24269080767d7a404c93da648b5f9c4f800 100644 (file)
@@ -1027,7 +1027,7 @@ public final class ParserListenerUtils {
         } else {
             unknownType.setReferenceOnly(true);
         }
-        
+
         return unknownType.build();
     }
 
@@ -1086,13 +1086,13 @@ public final class ParserListenerUtils {
         } else if (typeName.startsWith("int")) {
             IntegerTypeDefinition intType = null;
             if ("int8".equals(typeName)) {
-                intType = new Int8(extBaseTypePath);
+                intType = Int8.getInstance();
             } else if ("int16".equals(typeName)) {
-                intType = new Int16(extBaseTypePath);
+                intType = Int16.getInstance();
             } else if ("int32".equals(typeName)) {
-                intType = new Int32(extBaseTypePath);
+                intType = Int32.getInstance();
             } else if ("int64".equals(typeName)) {
-                intType = new Int64(extBaseTypePath);
+                intType = Int64.getInstance();
             }
             if (intType == null) {
                 throw new YangParseException(moduleName, line, "Unknown yang type " + typeName);
@@ -1102,13 +1102,13 @@ public final class ParserListenerUtils {
         } else if (typeName.startsWith("uint")) {
             UnsignedIntegerTypeDefinition uintType = null;
             if ("uint8".equals(typeName)) {
-                uintType = new Uint8(extBaseTypePath);
+                uintType = Uint8.getInstance();
             } else if ("uint16".equals(typeName)) {
-                uintType = new Uint16(extBaseTypePath);
+                uintType = Uint16.getInstance();
             } else if ("uint32".equals(typeName)) {
-                uintType = new Uint32(extBaseTypePath);
+                uintType = Uint32.getInstance();
             } else if ("uint64".equals(typeName)) {
-                uintType = new Uint64(extBaseTypePath);
+                uintType = Uint64.getInstance();
             }
             if (uintType == null) {
                 throw new YangParseException(moduleName, line, "Unknown yang type " + typeName);
@@ -1119,7 +1119,7 @@ public final class ParserListenerUtils {
             List<EnumTypeDefinition.EnumPair> enumConstants = getEnumConstants(typeBody, actualPath, moduleName);
             return new EnumerationType(baseTypePath, enumConstants);
         } else if ("string".equals(typeName)) {
-            StringTypeDefinition stringType = new StringType(extBaseTypePath);
+            StringTypeDefinition stringType = StringType.getIntance();
             constraints.addLengths(stringType.getLengthStatements());
             baseType = stringType;
         } else if ("bits".equals(typeName)) {
@@ -1130,12 +1130,12 @@ public final class ParserListenerUtils {
             RevisionAwareXPath xpath = new RevisionAwareXPathImpl(path, absolute);
             return new Leafref(baseTypePath, xpath);
         } else if ("binary".equals(typeName)) {
-            BinaryTypeDefinition binaryType = new BinaryType(extBaseTypePath);
+            BinaryTypeDefinition binaryType = BinaryType.getInstance();
             constraints.addLengths(binaryType.getLengthConstraints());
             baseType = binaryType;
         } else if ("instance-identifier".equals(typeName)) {
             boolean requireInstance = isRequireInstance(typeBody);
-            return new InstanceIdentifier(extBaseTypePath, null, requireInstance);
+            return new InstanceIdentifier(null, requireInstance);
         }
 
         if (parent instanceof TypeDefinitionBuilder && !(parent instanceof UnionTypeBuilder)) {
index b6ca8583e4b03c3ea7e2b1c537cf472b407fb7a5..8928786c8cd1634a3060340bf51fcda043278363 100644 (file)
@@ -24,33 +24,6 @@ import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.BooleanTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.EmptyTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.EnumTypeDefinition.EnumPair;
-import org.opendaylight.yangtools.yang.model.api.type.IdentityrefTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
-import org.opendaylight.yangtools.yang.model.util.BinaryType;
-import org.opendaylight.yangtools.yang.model.util.BitsType;
-import org.opendaylight.yangtools.yang.model.util.BooleanType;
-import org.opendaylight.yangtools.yang.model.util.Decimal64;
-import org.opendaylight.yangtools.yang.model.util.EmptyType;
-import org.opendaylight.yangtools.yang.model.util.EnumerationType;
-import org.opendaylight.yangtools.yang.model.util.ExtendedType;
-import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
-import org.opendaylight.yangtools.yang.model.util.InstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.util.Leafref;
-import org.opendaylight.yangtools.yang.model.util.StringType;
-import org.opendaylight.yangtools.yang.model.util.UnionType;
 import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationTargetBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
@@ -58,8 +31,6 @@ import org.opendaylight.yangtools.yang.parser.builder.api.DataNodeContainerBuild
 import org.opendaylight.yangtools.yang.parser.builder.api.DataSchemaNodeBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.GroupingBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.SchemaNodeBuilder;
-import org.opendaylight.yangtools.yang.parser.builder.api.TypeAwareBuilder;
-import org.opendaylight.yangtools.yang.parser.builder.api.TypeDefinitionBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.impl.ChoiceBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.impl.ChoiceBuilder.ChoiceNodeImpl;
@@ -73,7 +44,6 @@ import org.opendaylight.yangtools.yang.parser.builder.impl.ListSchemaNodeBuilder
 import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.impl.NotificationBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.impl.NotificationBuilder.NotificationDefinitionImpl;
-import org.opendaylight.yangtools.yang.parser.builder.impl.UnionTypeBuilder;
 
 public final class ParserUtils {
 
@@ -299,120 +269,6 @@ public final class ParserUtils {
                 correctNodePath(choiceCaseBuilder, node.getPath());
             }
         }
-
-        // if node can contains type, correct path for this type too
-        if (node instanceof TypeAwareBuilder) {
-            TypeAwareBuilder nodeBuilder = (TypeAwareBuilder) node;
-            correctTypeAwareNodePath(nodeBuilder);
-        }
-    }
-
-    /**
-     * Repair schema path of node type.
-     *
-     * @param node
-     *            node which contains type statement
-     * @param parentSchemaPath
-     *            schema path of parent node
-     */
-    public static void correctTypeAwareNodePath(final TypeAwareBuilder node) {
-        final SchemaPath parentSchemaPath = node.getPath();
-        final TypeDefinition<?> nodeType = node.getType();
-
-        // handle union type
-        if (node instanceof UnionTypeBuilder) {
-            for (TypeDefinitionBuilder tdb : ((UnionTypeBuilder) node).getTypedefs()) {
-                SchemaPath newSchemaPath = createSchemaPath(node.getPath(), tdb.getQName());
-                tdb.setPath(newSchemaPath);
-                correctTypeAwareNodePath(tdb);
-            }
-            List<TypeDefinition<?>> oldTypes = ((UnionTypeBuilder) node).getTypes();
-            List<TypeDefinition<?>> newTypes = new ArrayList<>();
-            for (TypeDefinition<?> td : oldTypes) {
-                TypeDefinition<?> newType = createCorrectTypeDefinition(node.getPath(), td);
-                newTypes.add(newType);
-            }
-            oldTypes.clear();
-            oldTypes.addAll(newTypes);
-            return;
-        }
-
-        // handle identityref type
-        if (node instanceof IdentityrefTypeBuilder) {
-            return;
-        }
-
-        // default handling
-        if (nodeType == null) {
-            TypeDefinitionBuilder nodeTypedef = node.getTypedef();
-            SchemaPath newSchemaPath = createSchemaPath(parentSchemaPath, nodeTypedef.getQName());
-            nodeTypedef.setPath(newSchemaPath);
-            correctTypeAwareNodePath(nodeTypedef);
-        } else {
-            TypeDefinition<?> newType = createCorrectTypeDefinition(parentSchemaPath, nodeType);
-            node.setType(newType);
-        }
-
-    }
-
-    public static TypeDefinition<?> createCorrectTypeDefinition(SchemaPath parentSchemaPath, TypeDefinition<?> nodeType) {
-        TypeDefinition<?> result = null;
-
-        if (nodeType != null) {
-            SchemaPath newSchemaPath = createSchemaPath(parentSchemaPath, nodeType.getQName());
-
-            if (nodeType instanceof BinaryTypeDefinition) {
-                BinaryTypeDefinition binType = (BinaryTypeDefinition) nodeType;
-
-                // List<Byte> bytes = (List<Byte>) binType.getDefaultValue();
-                // workaround to get rid of 'Unchecked cast' warning
-                List<Byte> bytes = new ArrayList<Byte>();
-                Object defaultValue = binType.getDefaultValue();
-                if (defaultValue instanceof List) {
-                    for (Object o : List.class.cast(defaultValue)) {
-                        if (o instanceof Byte) {
-                            bytes.add((Byte) o);
-                        }
-                    }
-                }
-                result = new BinaryType(newSchemaPath, bytes);
-            } else if (nodeType instanceof BitsTypeDefinition) {
-                BitsTypeDefinition bitsType = (BitsTypeDefinition) nodeType;
-                result = new BitsType(newSchemaPath, bitsType.getBits());
-            } else if (nodeType instanceof BooleanTypeDefinition) {
-                result = new BooleanType(newSchemaPath);
-            } else if (nodeType instanceof DecimalTypeDefinition) {
-                DecimalTypeDefinition decimalType = (DecimalTypeDefinition) nodeType;
-                result = new Decimal64(newSchemaPath, decimalType.getFractionDigits());
-            } else if (nodeType instanceof EmptyTypeDefinition) {
-                result = new EmptyType(newSchemaPath);
-            } else if (nodeType instanceof EnumTypeDefinition) {
-                EnumTypeDefinition enumType = (EnumTypeDefinition) nodeType;
-                result = new EnumerationType(newSchemaPath, (EnumPair) enumType.getDefaultValue(), enumType.getValues());
-            } else if (nodeType instanceof IdentityrefTypeDefinition) {
-                IdentityrefTypeDefinition idrefType = (IdentityrefTypeDefinition) nodeType;
-                result = new IdentityrefType(idrefType.getIdentity(), newSchemaPath);
-            } else if (nodeType instanceof InstanceIdentifierTypeDefinition) {
-                InstanceIdentifierTypeDefinition instIdType = (InstanceIdentifierTypeDefinition) nodeType;
-                return new InstanceIdentifier(newSchemaPath, instIdType.getPathStatement(),
-                        instIdType.requireInstance());
-            } else if (nodeType instanceof StringTypeDefinition) {
-                result = new StringType(newSchemaPath);
-            } else if (nodeType instanceof IntegerTypeDefinition) {
-                result = TypeUtils.createNewIntType(newSchemaPath, (IntegerTypeDefinition) nodeType);
-            } else if (nodeType instanceof UnsignedIntegerTypeDefinition) {
-                result = TypeUtils.createNewUintType(newSchemaPath, (UnsignedIntegerTypeDefinition) nodeType);
-            } else if (nodeType instanceof LeafrefTypeDefinition) {
-                result = new Leafref(newSchemaPath, ((LeafrefTypeDefinition) nodeType).getPathStatement());
-            } else if (nodeType instanceof UnionTypeDefinition) {
-                UnionTypeDefinition unionType = (UnionTypeDefinition) nodeType;
-                return new UnionType(newSchemaPath, unionType.getTypes());
-            } else if (nodeType instanceof ExtendedType) {
-                ExtendedType extType = (ExtendedType) nodeType;
-                result = TypeUtils.createNewExtendedType(extType, newSchemaPath);
-            }
-        }
-        return result;
     }
 
     /**
index 6d69bff53712210bf5249af1a31fc1d27e3453c6..48753ecfa1c688de841bc2d9fa323c0198731cb6 100644 (file)
@@ -19,23 +19,13 @@ import java.util.TreeMap;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BinaryTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.DecimalTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.IntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
-import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.ExtendedType;
-import org.opendaylight.yangtools.yang.model.util.Int16;
-import org.opendaylight.yangtools.yang.model.util.Int32;
-import org.opendaylight.yangtools.yang.model.util.Int64;
-import org.opendaylight.yangtools.yang.model.util.Int8;
-import org.opendaylight.yangtools.yang.model.util.Uint16;
-import org.opendaylight.yangtools.yang.model.util.Uint32;
-import org.opendaylight.yangtools.yang.model.util.Uint64;
-import org.opendaylight.yangtools.yang.model.util.Uint8;
 import org.opendaylight.yangtools.yang.model.util.UnknownType;
 import org.opendaylight.yangtools.yang.parser.builder.api.Builder;
 import org.opendaylight.yangtools.yang.parser.builder.api.DataNodeContainerBuilder;
@@ -317,62 +307,6 @@ public class TypeUtils {
         }
     }
 
-    /**
-     * Create new ExtendedType based on given type and with schema path.
-     *
-     * @param newPath
-     *            schema path for new type
-     * @param oldType
-     *            type based
-     * @return
-     */
-    static ExtendedType createNewExtendedType(final ExtendedType oldType, final SchemaPath newPath) {
-        QName qname = oldType.getQName();
-        TypeDefinition<?> newBaseType = ParserUtils.createCorrectTypeDefinition(newPath, oldType.getBaseType());
-        String desc = oldType.getDescription();
-        String ref = oldType.getReference();
-        ExtendedType.Builder builder = new ExtendedType.Builder(qname, newBaseType, desc, ref, newPath);
-        builder.status(oldType.getStatus());
-        builder.lengths(oldType.getLengths());
-        builder.patterns(oldType.getPatterns());
-        builder.ranges(oldType.getRanges());
-        builder.fractionDigits(oldType.getFractionDigits());
-        builder.unknownSchemaNodes(oldType.getUnknownSchemaNodes());
-        return builder.build();
-    }
-
-    static IntegerTypeDefinition createNewIntType(final SchemaPath newSchemaPath,
-            final IntegerTypeDefinition type) {
-        final String localName = type.getQName().getLocalName();
-        if ("int8".equals(localName)) {
-            return new Int8(newSchemaPath);
-        } else if ("int16".equals(localName)) {
-            return new Int16(newSchemaPath);
-        } else if ("int32".equals(localName)) {
-            return new Int32(newSchemaPath);
-        } else if ("int64".equals(localName)) {
-            return new Int64(newSchemaPath);
-        } else {
-            return null;
-        }
-    }
-
-    static UnsignedIntegerTypeDefinition createNewUintType(final SchemaPath newSchemaPath,
-            final UnsignedIntegerTypeDefinition type) {
-        final String localName = type.getQName().getLocalName();
-        if ("uint8".equals(localName)) {
-            return new Uint8(newSchemaPath);
-        } else if ("uint16".equals(localName)) {
-            return new Uint16(newSchemaPath);
-        } else if ("uint32".equals(localName)) {
-            return new Uint32(newSchemaPath);
-        } else if ("uint64".equals(localName)) {
-            return new Uint64(newSchemaPath);
-        } else {
-            return null;
-        }
-    }
-
     /**
      * Create new type builder based on old type with new base type.
      *
index 91655a6f5d095c4f02b5042c885127a390c2a155..e4cfd1bb191b90e67e10ddb72d16fd84133df75e 100644 (file)
@@ -14,8 +14,8 @@ import java.net.URI;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
 import java.util.Date;
 import java.util.List;
 import java.util.Set;
@@ -108,8 +108,7 @@ public class AugmentTest {
         assertEquals(expectedPath, ds0ChannelNumber.getPath());
         // type of leaf ds0ChannelNumber
         QName typeQName = BaseTypes.constructQName("string");
-        List<QName> typePath = new ArrayList<>(Arrays.asList(qnames));
-        typePath.add(typeQName);
+        List<QName> typePath = Collections.singletonList(typeQName);
         expectedPath = new SchemaPath(typePath, true);
         assertEquals(expectedPath, ds0ChannelNumber.getType().getPath());
 
index 1cc18cde67f08828d5b84594fda1b6f881be9a43..827a45796f21227554f9e14d2add22c055dfc487 100644 (file)
@@ -30,6 +30,9 @@ import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
+import org.opendaylight.yangtools.yang.model.util.BooleanType;
+import org.opendaylight.yangtools.yang.model.util.Uint32;
+import org.opendaylight.yangtools.yang.model.util.Uint8;
 import org.opendaylight.yangtools.yang.model.util.UnionType;
 
 import com.google.common.collect.Lists;
@@ -118,8 +121,7 @@ public class UsesAugmentTest {
         assertNotNull(version);
         assertEquals(createPath("pcreq", "version"), version.getPath());
         assertEquals(createPath("pcreq", "version", "protocol-version"), version.getType().getPath());
-        assertEquals(createPathForYangType("pcreq", "version", "protocol-version", "uint8"), version.getType()
-                .getBaseType().getPath());
+        assertEquals(Uint8.getInstance(), version.getType().getBaseType());
         assertTrue(version.isAddedByUses());
         // * |-- leaf type (U)
         LeafSchemaNode type = (LeafSchemaNode) pcreq.getDataChildByName("type");
@@ -128,7 +130,7 @@ public class UsesAugmentTest {
         assertEquals(createPath("pcreq", "type"), type.getPath());
         assertEquals(createPath("pcreq", "type", "int-ext"), type.getType().getPath());
         UnionType union = (UnionType)type.getType().getBaseType();
-        assertEquals(createPathForYangType("pcreq", "type", "int-ext", "union"), union.getPath());
+        assertEquals(BaseTypes.schemaPath(BaseTypes.constructQName("union")), union.getPath());
         assertEquals(2, union.getTypes().size());
         // * |-- list requests
         ListSchemaNode requests = (ListSchemaNode) pcreq.getDataChildByName("requests");
@@ -148,9 +150,8 @@ public class UsesAugmentTest {
         LeafSchemaNode priority = (LeafSchemaNode) rp.getDataChildByName("priority");
         assertNotNull(priority);
         assertEquals(createPath("pcreq", "requests", "rp", "priority"), priority.getPath());
-        assertEquals(createPath("pcreq", "requests", "rp", "priority", "uint8"), priority.getType().getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "rp", "priority", "uint8", "uint8"), priority.getType()
-                .getBaseType().getPath());
+        assertEquals(createPath("rp-object", "priority", "uint8"), priority.getType().getPath());
+        assertEquals(Uint8.getInstance(), priority.getType().getBaseType());
         assertTrue(priority.isAddedByUses());
         // * |-- |-- |-- container box (U)
         ContainerSchemaNode box = (ContainerSchemaNode) rp.getDataChildByName("box");
@@ -168,28 +169,25 @@ public class UsesAugmentTest {
         LeafSchemaNode delete = (LeafSchemaNode) order.getDataChildByName("delete");
         assertNotNull(delete);
         assertEquals(createPath("pcreq", "requests", "rp", "box", "order", "delete"), delete.getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "rp", "box", "order", "delete", "uint32"), delete
-                .getType().getPath());
+        assertEquals(Uint32.getInstance(), delete.getType());
         assertTrue(delete.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf ignore (U)
         LeafSchemaNode setup = (LeafSchemaNode) order.getDataChildByName("setup");
         assertNotNull(setup);
         assertEquals(createPath("pcreq", "requests", "rp", "box", "order", "setup"), setup.getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "rp", "box", "order", "setup", "uint32"), setup
-                .getType().getPath());
+        assertEquals(Uint32.getInstance(), setup.getType());
         assertTrue(setup.isAddedByUses());
         // * |-- |-- |-- leaf processing-rule (U)
         LeafSchemaNode processingRule = (LeafSchemaNode) rp.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
         assertEquals(createPath("pcreq", "requests", "rp", "processing-rule"), processingRule.getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "rp", "processing-rule", "boolean"), processingRule
-                .getType().getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
         // * |-- |-- |-- leaf ignore (U)
         LeafSchemaNode ignore = (LeafSchemaNode) rp.getDataChildByName("ignore");
         assertNotNull(ignore);
         assertEquals(createPath("pcreq", "requests", "rp", "ignore"), ignore.getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "rp", "ignore", "boolean"), ignore.getType().getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
         // * |-- |-- path-key-expansion
         ContainerSchemaNode pke = (ContainerSchemaNode) requests.getDataChildByName("path-key-expansion");
@@ -217,9 +215,7 @@ public class UsesAugmentTest {
         assertEquals(
                 createPath("pcreq", "requests", "path-key-expansion", "path-key", "path-keys", "version",
                         "protocol-version"), version.getType().getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "path-key-expansion", "path-key", "path-keys", "version",
-                        "protocol-version", "uint8"), version.getType().getBaseType().getPath());
+        assertEquals(Uint8.getInstance(), version.getType().getBaseType());
         assertTrue(version.isAddedByUses());
         assertFalse(version.isAugmenting());
         // * |-- |-- |-- |-- |-- leaf type (U)
@@ -230,9 +226,6 @@ public class UsesAugmentTest {
         assertEquals(
                 createPath("pcreq", "requests", "path-key-expansion", "path-key", "path-keys", "type",
                         "int-ext"), type.getType().getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "path-key-expansion", "path-key", "path-keys", "type",
-                        "int-ext", "union"), type.getType().getBaseType().getPath());
         assertTrue(type.isAddedByUses());
         assertFalse(type.isAugmenting());
         // * |-- |-- |-- |-- |-- leaf processing-rule (U)
@@ -240,16 +233,13 @@ public class UsesAugmentTest {
         assertNotNull(processingRule);
         assertEquals(createPath("pcreq", "requests", "path-key-expansion", "path-key", "processing-rule"),
                 processingRule.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "path-key-expansion", "path-key", "processing-rule",
-                        "boolean"), processingRule.getType().getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf ignore (U)
         ignore = (LeafSchemaNode) pathKey.getDataChildByName("ignore");
         assertNotNull(ignore);
         assertEquals(createPath("pcreq", "requests", "path-key-expansion", "path-key", "ignore"), ignore.getPath());
-        assertEquals(createPathForYangType("pcreq", "requests", "path-key-expansion", "path-key", "ignore", "boolean"),
-                ignore.getType().getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
         // * |-- |-- container segment-computation
         ContainerSchemaNode sc = (ContainerSchemaNode) requests.getDataChildByName("segment-computation");
@@ -271,18 +261,14 @@ public class UsesAugmentTest {
         assertNotNull(processingRule);
         assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "endpoints", "processing-rule"),
                 processingRule.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "endpoints",
-                        "processing-rule", "boolean"), processingRule.getType().getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf ignore (U)
         ignore = (LeafSchemaNode) endpoints.getDataChildByName("ignore");
         assertNotNull(ignore);
         assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "endpoints", "ignore"),
                 ignore.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "endpoints", "ignore",
-                        "boolean"), ignore.getType().getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
         // * |-- |-- |-- |-- |-- container box
         box = (ContainerSchemaNode) endpoints.getDataChildByName("box");
@@ -319,18 +305,14 @@ public class UsesAugmentTest {
         assertEquals(
                 createPath("pcreq", "requests", "segment-computation", "p2p", "reported-route", "processing-rule"),
                 processingRule.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "reported-route",
-                        "processing-rule", "boolean"), processingRule.getType().getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf ignore (U)
         ignore = (LeafSchemaNode) reportedRoute.getDataChildByName("ignore");
         assertNotNull(ignore);
         assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "reported-route", "ignore"),
                 ignore.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "reported-route", "ignore",
-                        "boolean"), ignore.getType().getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
         // * |-- |-- |-- |-- container bandwidth (U)
         bandwidth = (ContainerSchemaNode) p2p.getDataChildByName("bandwidth");
@@ -348,18 +330,14 @@ public class UsesAugmentTest {
         assertNotNull(processingRule);
         assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "bandwidth", "processing-rule"),
                 processingRule.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "bandwidth",
-                        "processing-rule", "boolean"), processingRule.getType().getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
         // * |-- |-- |-- |-- |-- leaf ignore (U)
         ignore = (LeafSchemaNode) bandwidth.getDataChildByName("ignore");
         assertNotNull(ignore);
         assertEquals(createPath("pcreq", "requests", "segment-computation", "p2p", "bandwidth", "ignore"),
                 ignore.getPath());
-        assertEquals(
-                createPathForYangType("pcreq", "requests", "segment-computation", "p2p", "bandwidth", "ignore",
-                        "boolean"), ignore.getType().getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
         // * |-- list svec
         ListSchemaNode svec = (ListSchemaNode) pcreq.getDataChildByName("svec");
@@ -375,8 +353,7 @@ public class UsesAugmentTest {
         LeafSchemaNode metricType = (LeafSchemaNode) metric.getDataChildByName("metric-type");
         assertNotNull(metricType);
         assertEquals(createPath("pcreq", "svec", "metric", "metric-type"), metricType.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "metric", "metric-type", "uint8"), metricType.getType()
-                .getPath());
+        assertEquals(Uint8.getInstance(), metricType.getType());
         assertTrue(metricType.isAddedByUses());
         // * |-- |-- |-- box (U)
         box = (ContainerSchemaNode) metric.getDataChildByName("box");
@@ -387,33 +364,31 @@ public class UsesAugmentTest {
         processingRule = (LeafSchemaNode) metric.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
         assertEquals(createPath("pcreq", "svec", "metric", "processing-rule"), processingRule.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "metric", "processing-rule", "boolean"), processingRule
-                .getType().getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
         // * |-- |-- |-- leaf ignore (U)
         ignore = (LeafSchemaNode) metric.getDataChildByName("ignore");
         assertNotNull(ignore);
         assertEquals(createPath("pcreq", "svec", "metric", "ignore"), ignore.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "metric", "ignore", "boolean"), ignore.getType().getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
         // * |-- |-- leaf link-diverse (U)
         LeafSchemaNode linkDiverse = (LeafSchemaNode) svec.getDataChildByName("link-diverse");
         assertNotNull(linkDiverse);
         assertEquals(createPath("pcreq", "svec", "link-diverse"), linkDiverse.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "link-diverse", "boolean"), linkDiverse.getType().getPath());
+        assertEquals(BooleanType.getInstance(), linkDiverse.getType());
         assertTrue(linkDiverse.isAddedByUses());
         // * |-- |-- leaf processing-rule (U)
         processingRule = (LeafSchemaNode) svec.getDataChildByName("processing-rule");
         assertNotNull(processingRule);
         assertEquals(createPath("pcreq", "svec", "processing-rule"), processingRule.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "processing-rule", "boolean"), processingRule.getType()
-                .getPath());
+        assertEquals(BooleanType.getInstance(), processingRule.getType());
         assertTrue(processingRule.isAddedByUses());
         // * |-- |-- leaf ignore (U)
         ignore = (LeafSchemaNode) svec.getDataChildByName("ignore");
         assertNotNull(ignore);
         assertEquals(createPath("pcreq", "svec", "ignore"), ignore.getPath());
-        assertEquals(createPathForYangType("pcreq", "svec", "ignore", "boolean"), ignore.getType().getPath());
+        assertEquals(BooleanType.getInstance(), ignore.getType());
         assertTrue(ignore.isAddedByUses());
     }
 
@@ -425,15 +400,6 @@ public class UsesAugmentTest {
         return new SchemaPath(path, true);
     }
 
-    private SchemaPath createPathForYangType(String... names) {
-        List<QName> path = new ArrayList<>();
-        for (int i = 0; i < names.length - 1; i++) {
-            path.add(new QName(ns, rev, prefix, names[i]));
-        }
-        path.add(new QName(URI.create("urn:ietf:params:xml:ns:yang:1"), names[names.length - 1]));
-        return new SchemaPath(path, true);
-    }
-
     @Test
     public void testTypedefs() throws FileNotFoundException {
         modules = TestUtils.loadModules(getClass().getResource("/grouping-test").getPath());
@@ -464,10 +430,9 @@ public class UsesAugmentTest {
         assertNotNull(pv);
 
         SchemaPath expectedPath = null;
-        QName q0 = new QName(ns, rev, prefix, "int-ext");
         QName q1 = BaseTypes.constructQName("union");
 
-        expectedPath = new SchemaPath(Lists.newArrayList(q0, q1), true);
+        expectedPath = new SchemaPath(Lists.newArrayList(q1), true);
         assertEquals(expectedPath, union.getPath());
     }
 
index 55d24f78bd9245859742e66ef4db299b9cbed0c9..8f3ac4c18b909b73c0b27ccf20f3f33302967623 100644 (file)
@@ -179,7 +179,7 @@ public class YangParserSimpleTest {
         LeafListSchemaNode added = (LeafListSchemaNode)nodes.getDataChildByName("added");
         assertNotNull(added);
         assertEquals(createPath("nodes", "added"), added.getPath());
-        assertEquals(createPath("nodes", "added", "mytype"), added.getType().getPath());
+        assertEquals(createPath("mytype"), added.getType().getPath());
 
         ListSchemaNode links = (ListSchemaNode) nodes.getDataChildByName("links");
         assertNotNull(links);
index 5091b1b38bf8461eefbcb4232adb770ba6210cc3..15f6ca805fc428e986e86da6ac716fa47b862766 100644 (file)
@@ -762,32 +762,22 @@ public class YangParserTest {
         Set<TypeDefinition<?>> types = test.getTypeDefinitions();
 
         // int32-ext1
-        ExtendedType int32Typedef = (ExtendedType) TestUtils.findTypedef(types, "int32-ext1");
-        QName int32TypedefQName = int32Typedef.getQName();
+        ExtendedType int32ext1 = (ExtendedType) TestUtils.findTypedef(types, "int32-ext1");
+        QName int32TypedefQName = int32ext1.getQName();
 
         assertEquals(typesNS, int32TypedefQName.getNamespace());
         assertEquals(typesRev, int32TypedefQName.getRevision());
         assertEquals("t", int32TypedefQName.getPrefix());
         assertEquals("int32-ext1", int32TypedefQName.getLocalName());
 
-        SchemaPath typeSchemaPath = int32Typedef.getPath();
+        SchemaPath typeSchemaPath = int32ext1.getPath();
         List<QName> typePath = typeSchemaPath.getPath();
         assertEquals(1, typePath.size());
         assertEquals(int32TypedefQName, typePath.get(0));
 
         // int32-ext1/int32
-        Int32 int32 = (Int32) int32Typedef.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(2, int32Path.size());
-        assertEquals(int32TypedefQName, int32Path.get(0));
-        assertEquals(int32QName, int32Path.get(1));
+        Int32 int32 = (Int32) int32ext1.getBaseType();
+        assertEquals(Int32.getInstance(), int32);
     }
 
     @Test