Merge "Introduce Identifiables"
authorTony Tkacik <ttkacik@cisco.com>
Wed, 18 Jun 2014 17:39:00 +0000 (17:39 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Wed, 18 Jun 2014 17:39:00 +0000 (17:39 +0000)
136 files changed:
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingGeneratorImpl.xtend
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/BindingSchemaContextUtils.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/CodecMapping.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/LazyGeneratedCodecRegistry.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/ModuleContext.java
code-generator/binding-generator-impl/src/main/java/org/opendaylight/yangtools/sal/binding/generator/impl/TransformerGenerator.xtend
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/AbstractTypesTest.java [new file with mode: 0644]
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/AugmentRelativeXPathTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/AugmentedTypeTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/BinaryTypeTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/BitAndUnionTOEnclosingTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/ChoiceCaseGenTypesTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/ControllerTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/ExtendedTypedefTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GenEnumResolvingTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GenTypesSubSetTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratedTypesBitsTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratedTypesLeafrefTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratedTypesStringTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/GeneratedTypesTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/IdentityrefTypeTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/SupportTestUtil.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/TypeProviderIntegrationTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/UnionTypeDefTest.java
code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/UsesTest.java
code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/abstract-topology@2013-02-08.yang
code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/augment-abstract-topology@2013-05-03.yang
code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/iana-if-type@2012-06-05.yang [deleted file]
code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/ietf-inet-types@2010-09-24.yang [deleted file]
code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/ietf-interfaces@2012-11-15.yang
code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/ietf-yang-types@2010-09-24.yang [deleted file]
code-generator/binding-generator-impl/src/test/resources/augment-test-models/abstract-topology@2013-02-08.yang
code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-abstract-topology@2013-05-03.yang
code-generator/binding-generator-impl/src/test/resources/augment-test-models/iana-if-type@2012-06-05.yang [deleted file]
code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-inet-types@2010-09-24.yang [deleted file]
code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-interfaces@2012-11-15.yang
code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-yang-types@2010-09-24.yang [deleted file]
code-generator/binding-generator-impl/src/test/resources/choice-case-type-test-models/choice-monitoring@2013-07-01.yang
code-generator/binding-generator-impl/src/test/resources/choice-case-type-test-models/ietf-inet-types@2010-09-24.yang [deleted file]
code-generator/binding-generator-impl/src/test/resources/choice-case-type-test-models/ietf-yang-types@2010-09-24.yang [deleted file]
code-generator/binding-generator-util/src/main/java/org/opendaylight/yangtools/binding/generator/util/BindingGeneratorUtil.java
code-generator/binding-generator-util/src/test/java/org/opendaylight/yangtools/binding/generator/util/BindingGeneratorUtilTest.java
code-generator/binding-java-api-generator/src/main/java/org/opendaylight/yangtools/sal/java/api/generator/BaseTemplate.xtend
code-generator/binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/CompilationTest.java
code-generator/binding-java-api-generator/src/test/java/org/opendaylight/yangtools/sal/java/api/generator/test/TypedefCompilationTest.java
code-generator/binding-java-api-generator/src/test/resources/compilation/bug1172/nested-uses-augment.yang [new file with mode: 0644]
code-generator/binding-type-provider/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/BaseYangTypes.java
code-generator/binding-type-provider/src/main/java/org/opendaylight/yangtools/sal/binding/yang/types/TypeProviderImpl.java
common/feature/pom.xml [deleted file]
common/features/pom.xml [new file with mode: 0644]
common/features/src/main/resources/features.xml [moved from common/feature/src/main/resources/features.xml with 66% similarity]
common/parent/pom.xml
common/pom.xml
integration-test/bug1196-test-model/pom.xml [new file with mode: 0644]
integration-test/bug1196-test-model/src/main/yang/network-topology-pcep.yang [new file with mode: 0644]
integration-test/bug1196-test-model/src/main/yang/network-topology-unix.yang [new file with mode: 0644]
integration-test/bug1196-test-model/src/main/yang/network-topology@2013-10-21.yang [new file with mode: 0644]
integration-test/bug1196-test-model/src/main/yang/odl-pcep-ietf-stateful07.yang [new file with mode: 0644]
integration-test/bug1196-test-model/src/main/yang/pcep-types.yang [new file with mode: 0644]
integration-test/pom.xml
model/ietf/pom.xml
restconf/restconf-util/pom.xml
restconf/restconf-util/src/test/java/org/opendaylight/yangtools/restconf/utils/Bug1196Test.java [new file with mode: 0644]
restconf/restconf-util/src/test/resources/topology-bug1196-linux.xml [new file with mode: 0644]
restconf/restconf-util/src/test/resources/topology-bug1196-unix.xml [new file with mode: 0644]
yang/yang-binding/pom.xml
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/InstanceIdentifier.java
yang/yang-binding/src/main/java/org/opendaylight/yangtools/yang/binding/util/DataObjectReadingUtil.java
yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/QName.java
yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/QNameModule.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/AttributesContainer.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/InstanceIdentifier.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/Node.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/codec/InstanceIdentifierCodec.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/AnyXmlNode.java [new file with mode: 0644]
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/AugmentationNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/ChoiceNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/ContainerNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/DataContainerChild.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/DataContainerNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafSetEntryNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/LeafSetNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/MapEntryNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/MapNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/NormalizedNodeContainer.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/OrderedLeafSetNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/OrderedMapNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/OrderedNodeContainer.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/UnkeyedListEntryNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/UnkeyedListNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/package-info.java [new file with mode: 0644]
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/Builders.java
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAnyXmlNodeBuilder.java [new file with mode: 0644]
yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAnyXmlNodeSchemaAwareBuilder.java [new file with mode: 0644]
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/AugmentationSchema.java
yang/yang-model-util/src/main/java/org/opendaylight/yangtools/yang/model/util/SchemaContextUtil.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/AbstractBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/AbstractDataNodeContainerBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/AbstractSchemaNodeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/AugmentationSchemaBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/Builder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/DataNodeContainerBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/DataSchemaNodeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/DocumentedNodeBuilder.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/GroupingBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/SchemaNodeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/TypeAwareBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/TypeDefinitionBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/UsesNodeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/AnyXmlBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/AugmentationSchemaBuilderImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ChoiceBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ChoiceCaseBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ContainerSchemaNodeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/DeviationBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/GroupingBuilderImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/IdentityrefTypeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/LeafListSchemaNodeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/LeafSchemaNodeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ListSchemaNodeBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ModuleBuilder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/NotificationBuilder.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/builder/impl/UsesNodeBuilderImpl.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/util/YangModelDependencyInfo.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceContextResolver.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceFromCapabilitiesResolver.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/util/YangSourceFromDependencyInfoResolver.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/BitImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/RefineHolder.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/util/YangParseException.java

index 620efbcee3da17b7fb6146f5bf4f5dedc763f388..ba8259e9b30627c064d1e041312963e4acafb427 100644 (file)
@@ -866,18 +866,17 @@ public class BindingGeneratorImpl implements BindingGenerator {
             return null;
         }
 
-        val String targetSchemaNodeName = result.QName.localName;
         var boolean fromUses = (result as DataSchemaNode).addedByUses
         var Iterator<UsesNode> groupingUses = grouping.uses.iterator;
-        while (fromUses) {
-            if (groupingUses.hasNext()) {
-                grouping = findNodeInSchemaContext(schemaContext, groupingUses.next().groupingPath.path) as GroupingDefinition;
-                result = grouping.getDataChildByName(targetSchemaNodeName);
-                fromUses = (result as DataSchemaNode).addedByUses;
-            } else {
-                throw new NullPointerException("Failed to generate code for augment in " + parentUsesNode);
+        while (groupingUses.hasNext && fromUses) {
+            result = findOriginalTargetFromGrouping(targetPath, groupingUses.next);
+            if (result != null) {
+                fromUses = (result as DataSchemaNode).addedByUses
             }
         }
+        if (fromUses) {
+            throw new NullPointerException("Failed to generate code for augment in " + parentUsesNode);
+        }
 
         return result as DataSchemaNode
     }
@@ -1149,6 +1148,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 val caseTypeBuilder = addDefaultInterfaceDefinition(packageName, caseNode)
                 caseTypeBuilder.addImplementsType(refChoiceType)
                 genCtx.get(module).addCaseType(caseNode.path, caseTypeBuilder)
+                genCtx.get(module).addChoiceToCaseMapping(refChoiceType, caseTypeBuilder,caseNode)
                 val Set<DataSchemaNode> caseChildNodes = caseNode.childNodes
                 if (caseChildNodes !== null) {
                     var Object parentNode = null
@@ -1251,21 +1251,18 @@ public class BindingGeneratorImpl implements BindingGenerator {
                     throw new IllegalArgumentException("Failed to find parent type of choice " + targetNode);
                 }
 
-                if (caseNode instanceof DataNodeContainer) {
-                    val DataNodeContainer dataNodeCase = caseNode as DataNodeContainer;
-                    val Set<DataSchemaNode> childNodes = dataNodeCase.childNodes;
-                    if (childNodes !== null) {
-                        resolveDataSchemaNodes(module, basePackageName, caseTypeBuilder, childOfType, childNodes);
-                    }
-                } else {
-                    val ChoiceCaseNode node = targetNode.getCaseNodeByName(caseNode.getQName().getLocalName());
-                    val Set<DataSchemaNode> childNodes = node.childNodes;
-                    if (childNodes !== null) {
-                        resolveDataSchemaNodes(module, basePackageName, caseTypeBuilder, childOfType, childNodes);
-                    }
+                var ChoiceCaseNode node = null;
+                if (caseNode instanceof ChoiceCaseNode) {
+                    node = caseNode as ChoiceCaseNode;
+                }  else {
+                    node = targetNode.getCaseNodeByName(caseNode.getQName().getLocalName());
+                }
+                val Set<DataSchemaNode> childNodes = node.childNodes;
+                if (childNodes !== null) {
+                    resolveDataSchemaNodes(module, basePackageName, caseTypeBuilder, childOfType, childNodes);
                 }
-
                 genCtx.get(module).addCaseType(caseNode.path, caseTypeBuilder)
+                genCtx.get(module).addChoiceToCaseMapping(targetType, caseTypeBuilder,node);
             }
         }
 
index 6645aba5741a64d4deb339ad2f1cd92dcffb15c2..f0e05f166551189175e454663c14ed605dbb11f4 100644 (file)
@@ -55,7 +55,7 @@ public class BindingSchemaContextUtils {
                 if(pathArguments.hasNext()) {
                     currentArg = pathArguments.next();
                 } else {
-                    return Optional.absent();
+                    return currentContainer;
                 }
             }
             if(ChildOf.class.isAssignableFrom(currentArg.getType()) && BindingReflections.isAugmentationChild(currentArg.getType())) {
index 9a4ce78541f13ed7461bf66153a99a51b2fad3a2..2ef288f79703c09936b77fb486535995db5580b9 100644 (file)
@@ -9,11 +9,10 @@ package org.opendaylight.yangtools.sal.binding.generator.impl;
 
 import java.lang.reflect.Field;
 import java.util.Map;
-
-import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec;
-import org.opendaylight.yangtools.yang.data.impl.codec.InstanceIdentifierCodec;
 import org.opendaylight.yangtools.yang.binding.BindingCodec;
 import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.data.impl.codec.IdentityCodec;
+import org.opendaylight.yangtools.yang.data.impl.codec.InstanceIdentifierCodec;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -27,6 +26,7 @@ public class CodecMapping {
     public static final String CLASS_TO_CASE_MAP = "CLASS_TO_CASE";
     public static final String COMPOSITE_TO_CASE = "COMPOSITE_TO_CASE";
     public static final String AUGMENTATION_CODEC = "AUGMENTATION_CODEC";
+    public static final String DISPATCH_CODEC = "DISPATCH_CODEC";
 
     public static void setIdentifierCodec(Class<?> obj,InstanceIdentifierCodec codec) {
         Field instanceIdField;
@@ -82,6 +82,19 @@ public class CodecMapping {
         }
     }
 
+    public static void setDispatchCodec(Class<? extends BindingCodec<?,?>> codec,
+            BindingCodec<?, ?> dispatchCodec) {
+        Field instanceIdField;
+        try {
+            instanceIdField = codec.getField(DISPATCH_CODEC);
+            instanceIdField.set(null, dispatchCodec);
+        } catch (NoSuchFieldException e) {
+            LOG.debug("BUG: dispatch codec is not needed for {}",codec.getName(),e);
+        } catch (SecurityException | IllegalAccessException e) {
+            LOG.error("Dispatch codec could not be set for {}",codec.getName(),e);
+        }
+    }
+
     public static void setAugmentationCodec(Class<? extends BindingCodec<?,?>> dataCodec,
             BindingCodec<?,?> augmentableCodec) {
             Field instanceIdField;
index e62f28e6469f2ad1f9a2af9e319b7ca92650ec4a..f857c0d7315adaf4d9e9704cb601513bc8d2887a 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.sal.binding.generator.impl;
 
 import java.lang.ref.WeakReference;
 import java.lang.reflect.Field;
+import java.util.AbstractMap.SimpleEntry;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
@@ -18,7 +19,6 @@ import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-import java.util.Objects;
 import java.util.Set;
 import java.util.WeakHashMap;
 import java.util.concurrent.ConcurrentHashMap;
@@ -33,7 +33,6 @@ import org.opendaylight.yangtools.sal.binding.generator.util.CodeGenerationExcep
 import org.opendaylight.yangtools.sal.binding.model.api.ConcreteType;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;
-import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
 import org.opendaylight.yangtools.yang.binding.Augmentable;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 import org.opendaylight.yangtools.yang.binding.BaseIdentity;
@@ -69,7 +68,6 @@ import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -78,6 +76,7 @@ import com.google.common.base.Preconditions;
 import com.google.common.collect.BiMap;
 import com.google.common.collect.HashBiMap;
 import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Iterables;
 import com.google.common.collect.Multimap;
 import com.google.common.collect.Multimaps;
 
@@ -87,7 +86,6 @@ class LazyGeneratedCodecRegistry implements //
         GeneratorListener {
 
     private static final Logger LOG = LoggerFactory.getLogger(LazyGeneratedCodecRegistry.class);
-    private static final LateMixinCodec NOT_READY_CODEC = new LateMixinCodec();
 
     // Concrete class to codecs
     private static final Map<Class<?>, DataContainerCodec<?>> containerCodecs = Collections
@@ -109,8 +107,7 @@ class LazyGeneratedCodecRegistry implements //
     @SuppressWarnings("rawtypes")
     private static final Map<Type, WeakReference<Class>> typeToClass = new ConcurrentHashMap<>();
 
-    @SuppressWarnings("rawtypes")
-    private static final ConcurrentMap<Type, ChoiceCaseCodecImpl> typeToCaseCodecs = new ConcurrentHashMap<>();
+    private static final ConcurrentMap<Type, ChoiceCaseNode> caseTypeToCaseSchema = new ConcurrentHashMap<>();
 
     private static final Map<SchemaPath, Type> pathToType = new ConcurrentHashMap<>();
     private static final Map<List<QName>, Type> pathToInstantiatedType = new ConcurrentHashMap<>();
@@ -124,7 +121,6 @@ class LazyGeneratedCodecRegistry implements //
             .<Type, Type> create());
 
     private final InstanceIdentifierCodec instanceIdentifierCodec = new InstanceIdentifierCodecImpl(this);
-    private final CaseClassMapFacade classToCaseRawCodec = new CaseClassMapFacade();
     private final IdentityCompositeCodec identityRefCodec = new IdentityCompositeCodec();
     private final ClassLoadingStrategy classLoadingStrategy;
     private final AbstractTransformerGenerator generator;
@@ -392,22 +388,14 @@ class LazyGeneratedCodecRegistry implements //
             return potential;
         }
         ConcreteType typeref = Types.typeForClass(caseClass);
-        ChoiceCaseCodecImpl caseCodec = typeToCaseCodecs.get(typeref);
+        ChoiceCaseNode caseSchema = caseTypeToCaseSchema.get(typeref);
 
-        Preconditions.checkState(caseCodec != null, "Case Codec was not created proactivelly for %s",
-                caseClass.getName());
-        Preconditions.checkState(caseCodec.getSchema() != null, "Case schema is not available for %s",
-                caseClass.getName());
-        Class<? extends BindingCodec> newCodec = generator.caseCodecFor(caseClass, caseCodec.getSchema());
+        Preconditions.checkState(caseSchema != null, "Case schema is not available for %s", caseClass.getName());
+        Class<? extends BindingCodec> newCodec = generator.caseCodecFor(caseClass, caseSchema);
         BindingCodec newInstance = newInstanceOf(newCodec);
-        caseCodec.setDelegate(newInstance);
+        @SuppressWarnings("unchecked")
+        ChoiceCaseCodecImpl caseCodec = new ChoiceCaseCodecImpl(caseClass, caseSchema, newInstance);
         caseCodecs.put(caseClass, caseCodec);
-
-        for (Entry<Class<?>, PublicChoiceCodecImpl<?>> choice : choiceCodecs.entrySet()) {
-            if (choice.getKey().isAssignableFrom(caseClass)) {
-                choice.getValue().cases.put(caseClass, caseCodec);
-            }
-        }
         return caseCodec;
     }
 
@@ -437,29 +425,8 @@ class LazyGeneratedCodecRegistry implements //
         synchronized (choiceToCases) {
             choiceToCases.putAll(context.getChoiceToCases());
         }
-        captureCases(context.getCases(), schemaContext);
-    }
-
-    private void captureCases(final Map<SchemaPath, GeneratedTypeBuilder> cases, final SchemaContext module) {
-        for (Entry<SchemaPath, GeneratedTypeBuilder> caseNode : cases.entrySet()) {
-            ReferencedTypeImpl typeref = new ReferencedTypeImpl(caseNode.getValue().getPackageName(), caseNode
-                    .getValue().getName());
-
-            pathToType.put(caseNode.getKey(), caseNode.getValue());
-
-            ChoiceCaseNode node = (ChoiceCaseNode) SchemaContextUtil.findDataSchemaNode(module, caseNode.getKey());
-
-            if (node == null) {
-                LOG.warn("Failed to find YANG SchemaNode for {}, with path {} was not found in context.",
-                        typeref.getFullyQualifiedName(), caseNode.getKey());
-                @SuppressWarnings("rawtypes")
-                ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl();
-                typeToCaseCodecs.putIfAbsent(typeref, value);
-                continue;
-            }
-            @SuppressWarnings("rawtypes")
-            ChoiceCaseCodecImpl value = new ChoiceCaseCodecImpl(node);
-            typeToCaseCodecs.putIfAbsent(typeref, value);
+        synchronized (caseTypeToCaseSchema) {
+            caseTypeToCaseSchema.putAll(context.getCaseTypeToSchemas());
         }
     }
 
@@ -476,43 +443,9 @@ class LazyGeneratedCodecRegistry implements //
         Preconditions.checkState(oldCodec == null);
         BindingCodec<Map<QName, Object>, Object> delegate = newInstanceOf(choiceCodec);
         PublicChoiceCodecImpl<?> newCodec = new PublicChoiceCodecImpl(delegate);
+        DispatchChoiceCodecImpl dispatchCodec = new DispatchChoiceCodecImpl(choiceClass);
         choiceCodecs.put(choiceClass, newCodec);
-        CodecMapping.setClassToCaseMap(choiceCodec, classToCaseRawCodec);
-        CodecMapping.setCompositeNodeToCaseMap(choiceCodec, newCodec.getCompositeToCase());
-
-        tryToCreateCasesCodecs(schema);
-
-    }
-
-    @Deprecated
-    private void tryToCreateCasesCodecs(final ChoiceNode schema) {
-        for (ChoiceCaseNode choiceCase : schema.getCases()) {
-            ChoiceCaseNode caseNode = choiceCase;
-            if (caseNode.isAddedByUses()) {
-                DataSchemaNode origCaseNode = SchemaContextUtil.findOriginal(caseNode, currentSchema);
-                if (origCaseNode instanceof ChoiceCaseNode) {
-                    caseNode = (ChoiceCaseNode) origCaseNode;
-                }
-            }
-            SchemaPath path = caseNode.getPath();
-
-            Type type;
-            if (path != null && (type = pathToType.get(path)) != null) {
-                ReferencedTypeImpl typeref = new ReferencedTypeImpl(type.getPackageName(), type.getName());
-                @SuppressWarnings("rawtypes")
-                ChoiceCaseCodecImpl partialCodec = typeToCaseCodecs.get(typeref);
-                if (partialCodec.getSchema() == null) {
-                    partialCodec.setSchema(caseNode);
-                }
-                try {
-                    Class<?> caseClass = classLoadingStrategy.loadClass(type.getFullyQualifiedName());
-                    getCaseCodecFor(caseClass);
-                } catch (ClassNotFoundException e) {
-                    LOG.trace("Could not proactivelly create case codec for {}", type, e);
-                }
-            }
-        }
-
+        CodecMapping.setDispatchCodec(choiceCodec, dispatchCodec);
     }
 
     @Override
@@ -734,41 +667,22 @@ class LazyGeneratedCodecRegistry implements //
     @SuppressWarnings("rawtypes")
     private static class ChoiceCaseCodecImpl<T extends DataContainer> implements ChoiceCaseCodec<T>, //
             Delegator<BindingCodec>, LocationAwareBindingCodec<Node<?>, ValueWithQName<T>> {
-        private boolean augmenting;
-        private boolean uses;
-        private BindingCodec delegate;
-
-        private Set<String> validNames;
-        private Set<QName> validQNames;
-        private ChoiceCaseNode schema;
-        private Set<InstanceIdentifier<?>> applicableLocations;
+        private final BindingCodec delegate;
+        private final ChoiceCaseNode schema;
+        private final Map<InstanceIdentifier<?>, ChoiceCaseNode> instantiatedLocations;
+        private final Class<?> dataType;
 
         @Override
         public boolean isApplicable(final InstanceIdentifier location) {
-            return applicableLocations.contains(location);
+            return instantiatedLocations.containsKey(location);
         }
 
-        public void setSchema(final ChoiceCaseNode caseNode) {
+        public ChoiceCaseCodecImpl(final Class<?> caseClass, final ChoiceCaseNode caseNode,
+                final BindingCodec newInstance) {
+            this.delegate = newInstance;
+            this.dataType = caseClass;
             this.schema = caseNode;
-            validNames = new HashSet<>();
-            validQNames = new HashSet<>();
-            for (DataSchemaNode node : caseNode.getChildNodes()) {
-                QName qname = node.getQName();
-                validQNames.add(qname);
-                validNames.add(qname.getLocalName());
-            }
-            augmenting = caseNode.isAugmenting();
-            uses = caseNode.isAddedByUses();
-            applicableLocations = new HashSet<>();
-        }
-
-        public ChoiceCaseCodecImpl() {
-            this.delegate = NOT_READY_CODEC;
-        }
-
-        public ChoiceCaseCodecImpl(final ChoiceCaseNode caseNode) {
-            this.delegate = NOT_READY_CODEC;
-            setSchema(caseNode);
+            instantiatedLocations = new HashMap<>();
         }
 
         @Override
@@ -778,7 +692,19 @@ class LazyGeneratedCodecRegistry implements //
 
         @Override
         public ValueWithQName<T> deserialize(final Node<?> input, final InstanceIdentifier<?> bindingIdentifier) {
-            throw new UnsupportedOperationException("Direct invocation of this codec is not allowed.");
+            if (input == null) {
+                return null;
+            }
+            QName qname = input.getNodeType();
+            synchronized (instantiatedLocations) {
+                ChoiceCaseNode instantiation = instantiatedLocations.get(bindingIdentifier);
+                if (instantiation != null) {
+                    qname = instantiatedLocations.get(bindingIdentifier).getQName();
+                }
+            }
+            @SuppressWarnings("unchecked")
+            T value = (T) getDelegate().deserialize(new SimpleEntry(qname, input), bindingIdentifier);
+            return new ValueWithQName<T>(qname, value);
         }
 
         @Override
@@ -791,56 +717,75 @@ class LazyGeneratedCodecRegistry implements //
             return delegate;
         }
 
-        public void setDelegate(final BindingCodec delegate) {
-            this.delegate = delegate;
-        }
-
         public ChoiceCaseNode getSchema() {
             return schema;
         }
 
         @Override
+        @Deprecated
         public boolean isAcceptable(final Node<?> input) {
-            if (input instanceof CompositeNode) {
-                if (augmenting && !uses) {
-                    return checkAugmenting((CompositeNode) input);
-                } else {
-                    return checkLocal((CompositeNode) input);
+            return checkAgainstSchema(schema, input);
+        }
+
+        private static boolean checkAgainstSchema(final ChoiceCaseNode schema, final Node<?> node) {
+            if (node instanceof CompositeNode) {
+                CompositeNode input = (CompositeNode) node;
+                for (Node<?> childNode : input.getValue()) {
+                    QName child = childNode.getNodeType();
+                    if (schema.getDataChildByName(child) != null) {
+                        return true;
+                    }
                 }
             }
             return false;
         }
 
-        @SuppressWarnings("deprecation")
-        private boolean checkLocal(final CompositeNode input) {
-            QName parent = input.getNodeType();
-            for (Node<?> childNode : input.getChildren()) {
-                QName child = childNode.getNodeType();
-                if (!Objects.equals(parent.getNamespace(), child.getNamespace())
-                        || !Objects.equals(parent.getRevision(), child.getRevision())) {
-                    continue;
-                }
-                if (validNames.contains(child.getLocalName())) {
-                    return true;
-                }
+        @Override
+        public Class<?> getDataType() {
+            return dataType;
+        }
+
+        public void adaptForPath(final InstanceIdentifier<?> augTarget, final ChoiceCaseNode choiceCaseNode) {
+            synchronized (instantiatedLocations) {
+                instantiatedLocations.put(augTarget, choiceCaseNode);
             }
-            return false;
         }
 
-        @SuppressWarnings("deprecation")
-        private boolean checkAugmenting(final CompositeNode input) {
-            for (Node<?> child : input.getChildren()) {
-                if (validQNames.contains(child.getNodeType())) {
-                    return true;
-                }
+        public boolean isAcceptable(final InstanceIdentifier path, final CompositeNode input) {
+            ChoiceCaseNode instantiatedSchema = null;
+            synchronized (instantiatedLocations) {
+                instantiatedSchema = instantiatedLocations.get(path);
             }
-            return false;
+            if (instantiatedSchema == null) {
+                return false;
+            }
+            return checkAgainstSchema(instantiatedSchema, input);
         }
 
-        @Override
-        public Class<?> getDataType() {
-            // TODO Auto-generated method stub
-            throw new UnsupportedOperationException("Not implemented Yet.");
+        protected boolean isAugmenting(final QName choiceName,final QName proposedQName) {
+            if (schema.isAugmenting()) {
+                return true;
+            }
+            // Choice QName
+            QName parentQName = Iterables.get(schema.getPath().getPathTowardsRoot(), 1);
+            if (!parentQName.getNamespace().equals(schema.getQName().getNamespace())) {
+                return true;
+            }
+            if (!parentQName.equals(choiceName)) {
+                // This item is instantiation of choice via uses in other YANG module
+                if(choiceName.getNamespace().equals(schema.getQName())) {
+                    // Original definition of grouping is in same namespace
+                    // as original definition of case
+                    // so for sure case is introduced via instantiation of grouping
+                    return false;
+                }
+                // Since we are still here, that means case has same namespace
+                // as its parent, which is instantiation of grouping
+                // but case namespace is different from parent node
+                // so it is augmentation.
+                return true;
+            }
+            return false;
         }
     }
 
@@ -849,15 +794,8 @@ class LazyGeneratedCodecRegistry implements //
 
         private final BindingCodec<Map<QName, Object>, Object> delegate;
 
-        @SuppressWarnings("rawtypes")
-        private final Map<Class, ChoiceCaseCodecImpl<?>> cases = Collections
-                .synchronizedMap(new WeakHashMap<Class, ChoiceCaseCodecImpl<?>>());
-
-        private final CaseCompositeNodeMapFacade CompositeToCase;
-
         public PublicChoiceCodecImpl(final BindingCodec<Map<QName, Object>, Object> delegate) {
             this.delegate = delegate;
-            this.CompositeToCase = new CaseCompositeNodeMapFacade(cases);
         }
 
         @Override
@@ -875,10 +813,6 @@ class LazyGeneratedCodecRegistry implements //
             throw new UnsupportedOperationException("Direct invocation of this codec is not allowed.");
         }
 
-        public CaseCompositeNodeMapFacade getCompositeToCase() {
-            return CompositeToCase;
-        }
-
         @Override
         public BindingCodec<Map<QName, Object>, Object> getDelegate() {
             return delegate;
@@ -886,163 +820,134 @@ class LazyGeneratedCodecRegistry implements //
 
     }
 
-    @SuppressWarnings("unused")
-    private class DispatchChoiceCodecImpl extends LocationAwareDispatchCodec<ChoiceCaseCodecImpl<?>> {
-
-        @Override
-        public Object deserialize(final Object input,
-                @SuppressWarnings("rawtypes") final InstanceIdentifier bindingIdentifier) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        public Object serialize(final Object input) {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        @Override
-        protected ChoiceCaseCodecImpl<?> tryToLoadImplementation(final Class<? extends DataContainer> inputType) {
-            return getCaseCodecFor(inputType);
-        }
-
-        @Override
-        protected void tryToLoadImplementations() {
-            // TODO Auto-generated method stub
-
-        }
-
-        @Override
-        protected void adaptForPathImpl(final InstanceIdentifier<?> path, final DataNodeContainer ctx) {
-            // TODO Auto-generated method stub
+    class DispatchChoiceCodecImpl extends LocationAwareDispatchCodec<ChoiceCaseCodecImpl<?>> {
+        private final Class<?> choiceType;
+        private final QName choiceName;
 
+        private DispatchChoiceCodecImpl(final Class<?> type) {
+            choiceType = type;
+            choiceName = BindingReflections.findQName(type);
         }
-    }
-
-    @SuppressWarnings("rawtypes")
-    private class CaseClassMapFacade extends MapFacadeBase {
 
         @Override
-        public Set<Entry<Class, BindingCodec<Object, Object>>> entrySet() {
-            return Collections.emptySet();
-        }
-
-        @Override
-        public BindingCodec get(final Object key) {
-            if (key instanceof Class) {
-                Class cls = (Class) key;
-                // bindingClassEncountered(cls);
-                ChoiceCaseCodecImpl caseCodec = getCaseCodecFor(cls);
-                return caseCodec.getDelegate();
-            }
-            return null;
-        }
-    }
-
-    @SuppressWarnings("rawtypes")
-    private static class CaseCompositeNodeMapFacade extends MapFacadeBase<CompositeNode> {
-
-        final Map<Class, ChoiceCaseCodecImpl<?>> choiceCases;
-
-        public CaseCompositeNodeMapFacade(final Map<Class, ChoiceCaseCodecImpl<?>> choiceCases) {
-            this.choiceCases = choiceCases;
-        }
+        public Object deserialize(final Object input, @SuppressWarnings("rawtypes") final InstanceIdentifier path) {
+            adaptForPath(path);
 
-        @Override
-        public BindingCodec get(final Object key) {
-            if (!(key instanceof CompositeNode)) {
-                return null;
-            }
-            for (Entry<Class, ChoiceCaseCodecImpl<?>> entry : choiceCases.entrySet()) {
-                ChoiceCaseCodecImpl<?> codec = entry.getValue();
-                if (codec.isAcceptable((CompositeNode) key)) {
-                    return codec.getDelegate();
+            if (input instanceof CompositeNode) {
+                List<Entry<Class, ChoiceCaseCodecImpl<?>>> codecs = new ArrayList<>(getImplementations().entrySet());
+                for (Entry<Class, ChoiceCaseCodecImpl<?>> codec : codecs) {
+                    ChoiceCaseCodecImpl<?> caseCodec = codec.getValue();
+                    if (caseCodec.isAcceptable(path, (CompositeNode) input)) {
+                        ValueWithQName<?> value = caseCodec.deserialize((CompositeNode) input, path);
+                        if (value != null) {
+                            return value.getValue();
+                        }
+                        return null;
+                    }
                 }
             }
             return null;
         }
 
-    }
-
-    /**
-     * This map is used as only facade for
-     * {@link org.opendaylight.yangtools.yang.binding.BindingCodec} in different
-     * classloaders to retrieve codec dynamicly based on provided key.
-     *
-     * @param <T>
-     *            Key type
-     */
-    @SuppressWarnings("rawtypes")
-    private abstract static class MapFacadeBase<T> implements Map<T, BindingCodec<?, ?>> {
-
-        @Override
-        public boolean containsKey(final Object key) {
-            return get(key) != null;
-        }
-
-        @Override
-        public void clear() {
-            throw notModifiable();
-        }
-
-        @Override
-        public boolean equals(final Object obj) {
-            return super.equals(obj);
-        }
-
+        @SuppressWarnings("unchecked")
         @Override
-        public BindingCodec remove(final Object key) {
-            return null;
+        public Object serialize(final Object input) {
+            Preconditions.checkArgument(input instanceof Map.Entry<?, ?>, "Input must be QName, Value");
+            @SuppressWarnings("rawtypes")
+            QName derivedQName =  (QName) ((Map.Entry) input).getKey();
+                    @SuppressWarnings("rawtypes")
+            Object inputValue = ((Map.Entry) input).getValue();
+            Preconditions.checkArgument(inputValue instanceof DataObject);
+            Class<? extends DataContainer> inputType = ((DataObject) inputValue).getImplementedInterface();
+            ChoiceCaseCodecImpl<?> codec = tryToLoadImplementation(inputType);
+            Preconditions.checkState(codec != null, "Unable to get codec for %s", inputType);
+            if (codec.isAugmenting(choiceName,derivedQName)) {
+                // If choice is augmenting we use QName which defined this
+                // augmentation
+                return codec.getDelegate().serialize(new ValueWithQName<>(codec.getSchema().getQName(), inputValue));
+            }
+            return codec.getDelegate().serialize(input);
         }
 
-        @Override
-        public int size() {
-            return 0;
-        }
 
-        @Override
-        public Collection<BindingCodec<?, ?>> values() {
-            return Collections.emptySet();
-        }
 
-        private UnsupportedOperationException notModifiable() {
-            return new UnsupportedOperationException("Not externally modifiable.");
+        @SuppressWarnings("rawtypes")
+        protected Optional<ChoiceCaseCodecImpl> tryToLoadImplementation(final Type potential) {
+            try {
+                @SuppressWarnings("unchecked")
+                Class<? extends DataContainer> clazz = (Class<? extends DataContainer>) classLoadingStrategy
+                        .loadClass(potential);
+                ChoiceCaseCodecImpl codec = tryToLoadImplementation(clazz);
+                addImplementation(codec);
+                return Optional.of(codec);
+            } catch (ClassNotFoundException e) {
+                LOG.warn("Failed to find class for choice {}", potential, e);
+            }
+            return Optional.absent();
         }
 
         @Override
-        public BindingCodec<Map<QName, Object>, Object> put(final T key, final BindingCodec<?, ?> value) {
-            throw notModifiable();
+        protected ChoiceCaseCodecImpl<?> tryToLoadImplementation(final Class<? extends DataContainer> inputType) {
+            ChoiceCaseCodecImpl<?> codec = getCaseCodecFor(inputType);
+            addImplementation(codec);
+            return codec;
         }
 
         @Override
-        public void putAll(final Map<? extends T, ? extends BindingCodec<?, ?>> m) {
-            throw notModifiable();
+        protected void tryToLoadImplementations() {
+            Type type = referencedType(choiceType);
+            Collection<Type> potentialCases;
+            synchronized (choiceToCases) {
+                potentialCases = choiceToCases.get(type);
+            }
+            for (Type potential : potentialCases) {
+                try {
+                    tryToLoadImplementation(potential);
+                } catch (CodeGenerationException e) {
+                    LOG.warn("Failed to proactively generate choice code for {}", type, e);
+                }
+            }
         }
 
         @Override
-        public int hashCode() {
-            return super.hashCode();
+        protected void adaptForPathImpl(final InstanceIdentifier<?> augTarget, final DataNodeContainer ctxNode) {
+            Optional<ChoiceNode> newChoice = findInstantiatedChoice(ctxNode, choiceName);
+            tryToLoadImplementations();
+            Preconditions.checkState(newChoice.isPresent(), "BUG: Unable to find instantiated choice node in schema.");
+            for (@SuppressWarnings("rawtypes")
+            Entry<Class, ChoiceCaseCodecImpl<?>> codec : getImplementations().entrySet()) {
+                ChoiceCaseCodecImpl<?> caseCodec = codec.getValue();
+                Optional<ChoiceCaseNode> instantiatedSchema = findInstantiatedCase(newChoice.get(),
+                        caseCodec.getSchema());
+                if (instantiatedSchema.isPresent()) {
+                    caseCodec.adaptForPath(augTarget, instantiatedSchema.get());
+                }
+            }
         }
 
-        @Override
-        public boolean isEmpty() {
-            return true;
-        }
+        private Optional<ChoiceNode> findInstantiatedChoice(final DataNodeContainer ctxNode, final QName choiceName) {
+            DataSchemaNode potential = ctxNode.getDataChildByName(choiceName);
+            if (potential == null) {
+                potential = ctxNode.getDataChildByName(choiceName.getLocalName());
+            }
 
-        @Override
-        public Set<T> keySet() {
-            return Collections.emptySet();
-        }
+            if (potential instanceof ChoiceNode) {
+                return Optional.of((ChoiceNode) potential);
+            }
 
-        @Override
-        public Set<Entry<T, BindingCodec<?, ?>>> entrySet() {
-            return Collections.emptySet();
+            return Optional.absent();
         }
 
-        @Override
-        public boolean containsValue(final Object value) {
-            return false;
+        private Optional<ChoiceCaseNode> findInstantiatedCase(final ChoiceNode newChoice, final ChoiceCaseNode schema) {
+            ChoiceCaseNode potential = newChoice.getCaseNodeByName(schema.getQName());
+            if (potential != null) {
+                return Optional.of(potential);
+            }
+            // FIXME: Probably requires more extensive check
+            // e.g. we have one choice and two augmentations from different
+            // modules using same local name
+            // but different namespace / contents
+            return Optional.fromNullable(newChoice.getCaseNodeByName(schema.getQName().getLocalName()));
         }
     }
 
@@ -1169,8 +1074,7 @@ class LazyGeneratedCodecRegistry implements //
          *
          * Adaptation consists of:
          * <ol>
-         * <li> scan of available (valid) augmentations for
-         * current location
+         * <li>scan of available (valid) augmentations for current location
          * <li>lookup for Java classes derived from this augmentations
          * <li>generation of missing codecs
          * <li>updating Augmentation codecs to work with new location
@@ -1190,27 +1094,27 @@ class LazyGeneratedCodecRegistry implements //
                         InstanceIdentifier augPath = augTarget.augmentation(augType);
                         try {
 
-                            org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = getInstanceIdentifierCodec().serialize(augPath);
-                            if(domPath == null) {
-                                LOG.error("Unable to serialize instance identifier for {}",augPath);
+                            org.opendaylight.yangtools.yang.data.api.InstanceIdentifier domPath = getInstanceIdentifierCodec()
+                                    .serialize(augPath);
+                            if (domPath == null) {
+                                LOG.error("Unable to serialize instance identifier for {}", augPath);
                             }
                         } catch (Exception e) {
-                            LOG.error("Unable to serialize instance identifiers for {}",augPath,e);
+                            LOG.error("Unable to serialize instance identifiers for {}", augPath, e);
                         }
 
                     }
                 } else {
-                    // Omits warning for empty augmentations since they are not represented in data
-                    if(!aug.getChildNodes().isEmpty()) {
+                    // Omits warning for empty augmentations since they are not
+                    // represented in data
+                    if (!aug.getChildNodes().isEmpty()) {
                         LOG.warn("Could not find generated type for augmentation {} with children {}", aug,
-                            aug.getChildNodes());
+                                aug.getChildNodes());
                     }
                 }
             }
         }
 
-
-
         private Type getTypeForAugmentation(final AugmentationSchema aug) {
             Optional<AugmentationSchema> currentAug = Optional.of(aug);
             while (currentAug.isPresent()) {
@@ -1224,36 +1128,6 @@ class LazyGeneratedCodecRegistry implements //
         }
     }
 
-    @SuppressWarnings({ "rawtypes", "unchecked" })
-    private static class LateMixinCodec implements BindingCodec, Delegator<BindingCodec> {
-
-        private BindingCodec delegate;
-
-        @Override
-        public BindingCodec getDelegate() {
-            if (delegate == null) {
-                throw new IllegalStateException("Codec not initialized yet.");
-            }
-            return delegate;
-        }
-
-        @Override
-        public Object deserialize(final Object input) {
-            return getDelegate().deserialize(input);
-        }
-
-        @Override
-        public Object deserialize(final Object input, final InstanceIdentifier bindingIdentifier) {
-            return getDelegate().deserialize(input, bindingIdentifier);
-        }
-
-        @Override
-        public Object serialize(final Object input) {
-            return getDelegate().serialize(input);
-        }
-
-    }
-
     @SuppressWarnings("rawtypes")
     private static class AugmentationCodecWrapper<T extends Augmentation<?>> implements AugmentationCodec<T>,
             Delegator<BindingCodec>, LocationAwareBindingCodec<Node<?>, ValueWithQName<T>> {
index 48b6947f9a0627b7cab2862561c2115788bf1d05..acb939d14962f0df818af2950bb1e8b5a1c35ede 100644 (file)
@@ -7,25 +7,24 @@
  */
 package org.opendaylight.yangtools.sal.binding.generator.impl;
 
+import com.google.common.collect.BiMap;
+import com.google.common.collect.HashBiMap;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTOBuilder;
 import org.opendaylight.yangtools.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 
-import com.google.common.collect.BiMap;
-import com.google.common.collect.HashBiMap;
-import com.google.common.collect.HashMultimap;
-import com.google.common.collect.Multimap;
-
 public final class ModuleContext {
     private GeneratedTypeBuilder moduleNode;
     private final List<GeneratedTOBuilder> genTOs = new ArrayList<GeneratedTOBuilder>();
@@ -39,6 +38,7 @@ public final class ModuleContext {
     private final BiMap<Type,AugmentationSchema> typeToAugmentation = HashBiMap.create();
 
     private final Multimap<Type, Type> choiceToCases = HashMultimap.create();
+    private final BiMap<Type,ChoiceCaseNode> caseTypeToSchema = HashBiMap.create();
 
     private final Multimap<Type, Type> augmentableToAugmentations = HashMultimap.create();
 
@@ -178,4 +178,13 @@ public final class ModuleContext {
         augmentableToAugmentations.put(target,augmentation);
     }
 
+    public void addChoiceToCaseMapping(Type choiceType, Type caseType, ChoiceCaseNode schema) {
+        choiceToCases.put(choiceType, caseType);
+        caseTypeToSchema.put(caseType, schema);
+    }
+
+    public BiMap<Type, ChoiceCaseNode> getCaseTypeToSchemas() {
+        return caseTypeToSchema;
+    }
+
 }
index 8821411022763d504a06e3fd9f1078005b898ee0..792b0b9cc3d1cc470d4d463d7dfb7a79e2b30102 100644 (file)
@@ -625,8 +625,7 @@ class TransformerGenerator extends AbstractTransformerGenerator {
                 //staticQNameField(inputType);
                 staticField(it, INSTANCE_IDENTIFIER_CODEC, BindingCodec)
                 staticField(it, IDENTITYREF_CODEC, BindingCodec)
-                staticField(it, CLASS_TO_CASE_MAP, Map)
-                staticField(it, COMPOSITE_TO_CASE, Map)
+                staticField(it, DISPATCH_CODEC, BindingCodec)
                 //staticField(it,QNAME_TO_CASE_MAP,BindingCodec)
                 implementsType(BINDING_CODEC)
                 method(List, "toDomStatic", #[QName, Object]) [
@@ -636,14 +635,11 @@ class TransformerGenerator extends AbstractTransformerGenerator {
                             if($2 == null) {
                                 return null;
                             }
-                            Â«DataObject.name» _baValue = («DataObject.name») $2;
-                            Class _baClass = _baValue.getImplementedInterface();
-                            Â«BINDING_CODEC.name» _codec =  Â«CLASS_TO_CASE_MAP».get(_baClass);
-                            if(_codec == null) {
-                                return null;
+                            if («DISPATCH_CODEC» == null) {
+                                throw new Â«IllegalStateException.name»("Implementation of codec was not initialized.");
                             }
-                            java.util.Map.Entry _input = new Â«SimpleEntry.name»($1,_baValue);
-                            Object _ret =  _codec.serialize(_input);
+                            java.util.Map.Entry _input = new Â«SimpleEntry.name»($1,$2);
+                            Object _ret =  Â«DISPATCH_CODEC».serialize(_input);
                             ////System.out.println("«typeSpec.name»#toDomStatic: " + _ret);
                             return («List.name») _ret;
                         }
@@ -658,11 +654,10 @@ class TransformerGenerator extends AbstractTransformerGenerator {
                     modifiers = PUBLIC + FINAL + STATIC
                     bodyChecked = '''
                         {
-                            Â«BINDING_CODEC.name» _codec = («BINDING_CODEC.name») Â«COMPOSITE_TO_CASE».get($2);
-                            if(_codec != null) {
-                                return _codec.deserialize(new Â«SimpleEntry.name»($1,$2),$3);
+                            if («DISPATCH_CODEC» == null) {
+                                throw new Â«IllegalStateException.name»("Implementation of codec was not initialized.");
                             }
-                            return null;
+                            return Â«DISPATCH_CODEC».deserialize($2,$3);
                         }
                     '''
                 ]
diff --git a/code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/AbstractTypesTest.java b/code-generator/binding-generator-impl/src/test/java/org/opendaylight/yangtools/sal/binding/generator/impl/AbstractTypesTest.java
new file mode 100644 (file)
index 0000000..58b5133
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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.sal.binding.generator.impl;
+
+import com.google.common.base.Preconditions;
+import java.io.File;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.HashSet;
+import java.util.Set;
+import org.junit.Before;
+
+public abstract class AbstractTypesTest {
+
+    private final URL testSourcesDirUrl;
+    protected Set<File> testModels;
+
+    AbstractTypesTest(final URL testSourcesDirUrl) {
+        this.testSourcesDirUrl = testSourcesDirUrl;
+    }
+
+    @Before
+    public void loadTestResources() throws URISyntaxException {
+        File testSourcesDir = new File(testSourcesDirUrl.toURI());
+        File[] testFiles = Preconditions.checkNotNull(testSourcesDir.listFiles(), testSourcesDir
+                + " does not denote a directory");
+        testModels = new HashSet<>();
+        for (File file : testFiles) {
+            if (file.isFile()) {
+                testModels.add(file);
+            }
+        }
+    }
+
+}
index 6611ac40e81af93fc2216dddbe852f184d11e061..de566eea1ec6c46eb40a5969738167be25d75186 100644 (file)
@@ -11,14 +11,8 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
+import java.io.IOException;
 import java.util.List;
-import java.util.Set;
-
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
@@ -26,33 +20,20 @@ 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.MethodSignature;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
-public class AugmentRelativeXPathTest {
-
-    private final static List<File> augmentModels = new ArrayList<>();
-    private final static URL augmentFolderPath = AugmentedTypeTest.class
-            .getResource("/augment-relative-xpath-models");
-
-    @BeforeClass
-    public static void loadTestResources() throws URISyntaxException {
-        final File augFolder = new File(augmentFolderPath.toURI());
+public class AugmentRelativeXPathTest extends AbstractTypesTest {
 
-        for (final File fileEntry : augFolder.listFiles()) {
-            if (fileEntry.isFile()) {
-                augmentModels.add(fileEntry);
-            }
-        }
+    public AugmentRelativeXPathTest() {
+        super(AugmentRelativeXPathTest.class.getResource("/augment-relative-xpath-models"));
     }
 
     @Test
-    public void AugmentationWithRelativeXPathTest() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(augmentModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public void AugmentationWithRelativeXPathTest() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull("context is null", context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -69,19 +50,21 @@ public class AugmentRelativeXPathTest {
         for (final Type type : genTypes) {
             if (type.getName().equals("InterfaceKey") && type.getPackageName().contains("augment._abstract.topology")) {
                 gtInterfaceKey = (GeneratedTransferObject) type;
-            } else if (type.getName().equals("Interface") && type.getPackageName().contains("augment._abstract.topology")) {
+            } else if (type.getName().equals("Interface")
+                    && type.getPackageName().contains("augment._abstract.topology")) {
                 gtInterface = (GeneratedType) type;
             } else if (type.getName().equals("Tunnel") && type.getPackageName().contains("augment._abstract.topology")) {
                 gtTunnel = (GeneratedType) type;
-            } else if (type.getName().equals("TunnelKey") && type.getPackageName().contains("augment._abstract.topology")) {
+            } else if (type.getName().equals("TunnelKey")
+                    && type.getPackageName().contains("augment._abstract.topology")) {
                 gtTunnelKey = (GeneratedTransferObject) type;
             }
         }
 
         // 'Interface
-        assertNotNull("gtInterface is null", gtInterface);
+        assertNotNull("Interface is null", gtInterface);
         final List<MethodSignature> gtInterfaceMethods = gtInterface.getMethodDefinitions();
-        assertNotNull("gtInterfaceMethods is null", gtInterfaceMethods);
+        assertNotNull("Interface methods are null", gtInterfaceMethods);
         MethodSignature getIfcKeyMethod = null;
         for (final MethodSignature method : gtInterfaceMethods) {
             if (method.getName().equals("getKey")) {
@@ -89,17 +72,15 @@ public class AugmentRelativeXPathTest {
                 break;
             }
         }
-        assertNotNull("getIfcKeyMethod is null", getIfcKeyMethod);
-        assertNotNull("getIfcKeyMethod.getReturnType() is null", getIfcKeyMethod.getReturnType());
-        assertFalse("getIfcKeyMethod.getReturnType() should not be Void",
-                getIfcKeyMethod.getReturnType().equals("java.lang.Void"));
-        assertTrue("getIfcKeyMethod.getReturnType().getName() must be InterfaceKey",
-                getIfcKeyMethod.getReturnType().getName().equals("InterfaceKey"));
+        assertNotNull("getKey method is null", getIfcKeyMethod);
+        assertNotNull("getKey method return type is null", getIfcKeyMethod.getReturnType());
+        assertTrue("getKey method return type name must be InterfaceKey", getIfcKeyMethod.getReturnType().getName()
+                .equals("InterfaceKey"));
 
         // 'InterfaceKey'
-        assertNotNull("gtInterfaceKey is null", gtInterfaceKey);
+        assertNotNull("InterfaceKey is null", gtInterfaceKey);
         final List<GeneratedProperty> properties = gtInterfaceKey.getProperties();
-        assertNotNull("properties is null", properties);
+        assertNotNull("InterfaceKey properties are null", properties);
         GeneratedProperty gtInterfaceId = null;
         for (final GeneratedProperty property : properties) {
             if (property.getName().equals("interfaceId")) {
@@ -107,17 +88,15 @@ public class AugmentRelativeXPathTest {
                 break;
             }
         }
-        assertNotNull("gtInterfaceId is null", gtInterfaceId);
-        assertNotNull("gtInterfaceId.getReturnType() is null", gtInterfaceId.getReturnType());
-        assertFalse("gtInterfaceId.getReturnType() should not be Void",
-                gtInterfaceId.getReturnType().equals("java.lang.Void"));
-        assertTrue("gtInterfaceId.getReturnType().getName() must be String",
+        assertNotNull("interfaceId is null", gtInterfaceId);
+        assertNotNull("interfaceId return type is null", gtInterfaceId.getReturnType());
+        assertTrue("interfaceId return type name must be String",
                 gtInterfaceId.getReturnType().getName().equals("String"));
 
         // 'Tunnel'
-        assertNotNull("gtTunnel is null", gtTunnel);
+        assertNotNull("Tunnel is null", gtTunnel);
         final List<MethodSignature> tunnelMethods = gtTunnel.getMethodDefinitions();
-        assertNotNull("tunnelMethods is null", tunnelMethods);
+        assertNotNull("Tunnel methods are null", tunnelMethods);
         MethodSignature getTunnelKeyMethod = null;
         for (MethodSignature method : tunnelMethods) {
             if (method.getName().equals("getKey")) {
@@ -125,18 +104,15 @@ public class AugmentRelativeXPathTest {
                 break;
             }
         }
-        assertNotNull("getTunnelKeyMethod is null", getTunnelKeyMethod);
-        assertNotNull("getTunnelKeyMethod.getReturnType()",
-                getTunnelKeyMethod.getReturnType());
-        assertFalse("getTunnelKeyMethod.getReturnType() should not be Void",
-                getTunnelKeyMethod.getReturnType().equals("java.lang.Void"));
-        assertTrue("getTunnelKeyMethod.getReturnType().getName() must be TunnelKey",
-                getTunnelKeyMethod.getReturnType().getName().equals("TunnelKey"));
+        assertNotNull("getKey method is null", getTunnelKeyMethod);
+        assertNotNull("getKey method return type", getTunnelKeyMethod.getReturnType());
+        assertTrue("getKey method return type name must be TunnelKey", getTunnelKeyMethod.getReturnType().getName()
+                .equals("TunnelKey"));
 
         // 'TunnelKey'
-        assertNotNull("gtTunnelKey is null", gtTunnelKey);
+        assertNotNull("TunnelKey is null", gtTunnelKey);
         final List<GeneratedProperty> tunnelKeyProperties = gtTunnelKey.getProperties();
-        assertNotNull("tunnelKeyProperties is null", tunnelKeyProperties);
+        assertNotNull("TunnelKey properties are null", tunnelKeyProperties);
 
         GeneratedProperty gtTunnelId = null;
         for (final GeneratedProperty property : tunnelKeyProperties) {
@@ -144,13 +120,9 @@ public class AugmentRelativeXPathTest {
                 gtTunnelId = property;
             }
         }
-        assertNotNull("gtTunnelId is null", gtTunnelId);
-        assertNotNull("gtTunnelId.getReturnType() is null",
-                gtTunnelId.getReturnType());
-        assertFalse("gtTunnelId.getReturnType() should not be Void",
-                gtTunnelId.getReturnType().equals("java.lang.Void"));
-        assertTrue("gtTunnelId.getReturnType().getName() must be Uri",
-                gtTunnelId.getReturnType().getName().equals("Uri"));
+        assertNotNull("tunnelId is null", gtTunnelId);
+        assertNotNull("tunnelId return type is null", gtTunnelId.getReturnType());
+        assertTrue("tunnelId return type name must be Uri", gtTunnelId.getReturnType().getName().equals("Uri"));
     }
 
 }
index 933db8dc8a7c6c4c0e8b44f2942fe8e05bdc885e..9bc10e4dd833669b0b9567c0da3d44976cc62f8a 100644 (file)
@@ -11,14 +11,8 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
+import java.io.IOException;
 import java.util.List;
-import java.util.Set;
-
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
@@ -26,33 +20,20 @@ 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.MethodSignature;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
-public class AugmentedTypeTest {
-
-    private final static List<File> augmentModels = new ArrayList<>();
-    private final static URL augmentFolderPath = AugmentedTypeTest.class
-            .getResource("/augment-test-models");
-
-    @BeforeClass
-    public static void loadTestResources() throws URISyntaxException {
-        final File augFolder = new File(augmentFolderPath.toURI());
+public class AugmentedTypeTest extends AbstractTypesTest {
 
-        for (final File fileEntry : augFolder.listFiles()) {
-            if (fileEntry.isFile()) {
-                augmentModels.add(fileEntry);
-            }
-        }
+    public AugmentedTypeTest() {
+        super(AugmentedTypeTest.class.getResource("/augment-test-models"));
     }
 
     @Test
-    public void augmentedAbstractTopologyTest() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(augmentModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public void augmentedAbstractTopologyTest() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull("context is null", context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -70,13 +51,16 @@ public class AugmentedTypeTest {
         for (final Type type : genTypes) {
             if (type.getName().equals("InterfaceKey") && type.getPackageName().contains("augment._abstract.topology")) {
                 gtInterfaceKey = (GeneratedTransferObject) type;
-            } else if (type.getName().equals("Interface") && type.getPackageName().contains("augment._abstract.topology")) {
+            } else if (type.getName().equals("Interface")
+                    && type.getPackageName().contains("augment._abstract.topology")) {
                 gtInterface = (GeneratedType) type;
             } else if (type.getName().equals("Tunnel") && type.getPackageName().contains("augment._abstract.topology")) {
                 gtTunnel = (GeneratedType) type;
-            } else if (type.getName().equals("TunnelKey") && type.getPackageName().contains("augment._abstract.topology")) {
+            } else if (type.getName().equals("TunnelKey")
+                    && type.getPackageName().contains("augment._abstract.topology")) {
                 gtTunnelKey = (GeneratedTransferObject) type;
-            } else if (type.getName().equals("NetworkLink2") && type.getPackageName().contains("augment._abstract.topology")) {
+            } else if (type.getName().equals("NetworkLink2")
+                    && type.getPackageName().contains("augment._abstract.topology")) {
                 gtNetworkLink2 = (GeneratedType) type;
             }
         }
@@ -96,8 +80,8 @@ public class AugmentedTypeTest {
         assertNotNull("getIfcKeyMethod.getReturnType() is null", getIfcKeyMethod.getReturnType());
         assertFalse("getIfcKeyMethod.getReturnType() should not be Void",
                 getIfcKeyMethod.getReturnType().equals("java.lang.Void"));
-        assertTrue("getIfcKeyMethod.getReturnType().getName() must be InterfaceKey",
-                getIfcKeyMethod.getReturnType().getName().equals("InterfaceKey"));
+        assertTrue("getIfcKeyMethod.getReturnType().getName() must be InterfaceKey", getIfcKeyMethod.getReturnType()
+                .getName().equals("InterfaceKey"));
 
         MethodSignature getHigherLayerIfMethod = null;
         for (final MethodSignature method : gtInterfaceMethods) {
@@ -106,16 +90,13 @@ public class AugmentedTypeTest {
                 break;
             }
         }
-        assertNotNull("getHigherLayerIfMethod is null", getHigherLayerIfMethod);
-        assertNotNull("getHigherLayerIfMethod.getReturnType() is null",
-                getHigherLayerIfMethod.getReturnType());
-        assertFalse("getHigherLayerIfMethod.getReturnType() should not be Void",
-                getHigherLayerIfMethod.getReturnType().equals("java.lang.Void"));
-        assertTrue("getHigherLayerIfMethod.getReturnType().getName() must be List",
-                getHigherLayerIfMethod.getReturnType().getName().equals("List"));
+        assertNotNull("getHigherLayerIf method is null", getHigherLayerIfMethod);
+        assertNotNull("getHigherLayerIf method return type is null", getHigherLayerIfMethod.getReturnType());
+        assertTrue("getHigherLayerIf method return type name must be List", getHigherLayerIfMethod.getReturnType()
+                .getName().equals("List"));
 
         // 'InterfaceKey'
-        assertNotNull("gtInterfaceKey is null", gtInterfaceKey);
+        assertNotNull("InterfaceKey is null", gtInterfaceKey);
         final List<GeneratedProperty> properties = gtInterfaceKey.getProperties();
         assertNotNull("properties is null", properties);
         GeneratedProperty gtInterfaceId = null;
@@ -125,17 +106,15 @@ public class AugmentedTypeTest {
                 break;
             }
         }
-        assertNotNull("gtInterfaceId is null", gtInterfaceId);
-        assertNotNull("gtInterfaceId.getReturnType() is null", gtInterfaceId.getReturnType());
-        assertFalse("gtInterfaceId.getReturnType() should not be Void",
-                gtInterfaceId.getReturnType().equals("java.lang.Void"));
-        assertTrue("gtInterfaceId.getReturnType().getName() must be String",
+        assertNotNull("interfaceId is null", gtInterfaceId);
+        assertNotNull("interfaceId return type is null", gtInterfaceId.getReturnType());
+        assertTrue("interfaceId return type name must be String",
                 gtInterfaceId.getReturnType().getName().equals("String"));
 
         // 'Tunnel'
-        assertNotNull("gtTunnel is null", gtTunnel);
+        assertNotNull("Tunnel is null", gtTunnel);
         final List<MethodSignature> tunnelMethods = gtTunnel.getMethodDefinitions();
-        assertNotNull("tunnelMethods is null", tunnelMethods);
+        assertNotNull("Tunnel methods are null", tunnelMethods);
         MethodSignature getTunnelKeyMethod = null;
         for (MethodSignature method : tunnelMethods) {
             if (method.getName().equals("getKey")) {
@@ -143,18 +122,15 @@ public class AugmentedTypeTest {
                 break;
             }
         }
-        assertNotNull("getTunnelKeyMethod is null", getTunnelKeyMethod);
-        assertNotNull("getTunnelKeyMethod.getReturnType()",
-                getTunnelKeyMethod.getReturnType());
-        assertFalse("getTunnelKeyMethod.getReturnType() should not be Void",
-                getTunnelKeyMethod.getReturnType().equals("java.lang.Void"));
-        assertTrue("getTunnelKeyMethod.getReturnType().getName() must be TunnelKey",
-                getTunnelKeyMethod.getReturnType().getName().equals("TunnelKey"));
+        assertNotNull("getKey method of Tunnel is null", getTunnelKeyMethod);
+        assertNotNull("getKey method return type is null", getTunnelKeyMethod.getReturnType());
+        assertTrue("getKey method return type name must be TunnelKey", getTunnelKeyMethod.getReturnType().getName()
+                .equals("TunnelKey"));
 
         // 'TunnelKey'
-        assertNotNull("gtTunnelKey is null", gtTunnelKey);
+        assertNotNull("TunnelKey is null", gtTunnelKey);
         final List<GeneratedProperty> tunnelKeyProperties = gtTunnelKey.getProperties();
-        assertNotNull("tunnelKeyProperties is null", tunnelKeyProperties);
+        assertNotNull("TunnelKey properties are null", tunnelKeyProperties);
 
         GeneratedProperty gtTunnelId = null;
         for (final GeneratedProperty property : tunnelKeyProperties) {
@@ -162,33 +138,28 @@ public class AugmentedTypeTest {
                 gtTunnelId = property;
             }
         }
-        assertNotNull("gtTunnelId is null", gtTunnelId);
-        assertNotNull("gtTunnelId.getReturnType() is null",
-                gtTunnelId.getReturnType());
-        assertFalse("gtTunnelId.getReturnType() should not be Void",
-                gtTunnelId.getReturnType().equals("java.lang.Void"));
-        assertTrue("gtTunnelId.getReturnType().getName() must be Integer",
-                gtTunnelId.getReturnType().getName().equals("Integer"));
+        assertNotNull("tunnelId is null", gtTunnelId);
+        assertNotNull("tunnelId return type is null", gtTunnelId.getReturnType());
+        assertTrue("tunnelId returnType name must be Integer", gtTunnelId.getReturnType().getName().equals("Integer"));
 
         // 'NetworkLink2'
-        assertNotNull("gtNetworkLink2 is null", gtNetworkLink2);
+        assertNotNull("NetworkLink2 is null", gtNetworkLink2);
 
         final List<MethodSignature> networkLink2Methods = gtNetworkLink2.getMethodDefinitions();
-        assertNotNull("networkLink2Methods is null", networkLink2Methods);
-
-//        FIXME: in some cases getIfcMethod is null which causes test fail. fix ASAP
-//      MethodSignature getIfcMethod = null;
-//      for (MethodSignature method : networkLink2Methods) {
-//          if (method.getName().equals("getInterface")) {
-//              getIfcMethod = method;
-//              break;
-//          }
-//      }
-//
-//      assertNotNull("getIfcMethod is null", getIfcMethod);
-//      assertNotNull("getIfcMethod.getReturnType() is null", getIfcMethod.getReturnType());
-//      assertFalse("getIfcMethod.getReturnType() should not be Void", getIfcMethod.getReturnType().equals("java.lang.Void"));
-//      assertTrue("getIfcMethod.getReturnType().getName() must be String", getIfcMethod.getReturnType().getName().equals("String"));
+        assertNotNull("NetworkLink2 methods are null", networkLink2Methods);
+
+        MethodSignature getIfcMethod = null;
+        for (MethodSignature method : networkLink2Methods) {
+            if (method.getName().equals("getInterface")) {
+                getIfcMethod = method;
+                break;
+            }
+        }
+
+        assertNotNull("getInterface method is null", getIfcMethod);
+        assertNotNull("getInterface method return type is null", getIfcMethod.getReturnType());
+        assertTrue("getInterface method return type name must be String", getIfcMethod.getReturnType().getName()
+                .equals("String"));
     }
 
     @Test
@@ -200,4 +171,5 @@ public class AugmentedTypeTest {
     public void augmentedTopologyTunnelsTest() {
 
     }
+
 }
index 06f2844a0023cdbd63f5666b112cc04485110df4..f5c2c1b2aa65b902ac0aabbd606d4c35b6a3d100 100644 (file)
@@ -11,19 +11,17 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class BinaryTypeTest {
@@ -42,10 +40,9 @@ public class BinaryTypeTest {
     }
 
     @Test
-    public void binaryTypeTest() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(yangModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public void binaryTypeTest() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(yangModels);
 
         assertNotNull("context is null", context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
index a9be781252f36b24763494044e845b42fe0a3cee..030cd11757544a5ceb2eb131680560f22c309e4a 100644 (file)
@@ -13,11 +13,10 @@ import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestU
 import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestUtil.containsMethods;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
@@ -25,9 +24,8 @@ import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
 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.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class BitAndUnionTOEnclosingTest {
@@ -36,10 +34,9 @@ public class BitAndUnionTOEnclosingTest {
     private static List<Type> genTypes = null;
     private static GeneratedType parentContainer = null;
 
-    public static void parseResources() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public static void parseResources() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -56,7 +53,7 @@ public class BitAndUnionTOEnclosingTest {
     }
 
     @BeforeClass
-    public static void loadTestResources() throws URISyntaxException {
+    public static void loadTestResources() throws IOException, URISyntaxException {
         final File listModelFile = new File(ExtendedTypedefTest.class.getResource("/bit_and_union.yang").toURI());
         testModels.add(listModelFile);
         parseResources();
index 8e5b95f07c13745e6723f83a0b3be8b803be7c81..7498a10a64a04eb1ed47b314c24bf1307abd571f 100644 (file)
@@ -13,42 +13,24 @@ import static org.junit.Assert.assertNotNull;
 import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestUtil.containsInterface;
 import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestUtil.containsMethods;
 
-import java.io.File;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
+import java.io.IOException;
 import java.util.List;
-import java.util.Set;
-
-import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 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.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
-public class ChoiceCaseGenTypesTest {
-
-    private final static List<File> yangModels = new ArrayList<>();
-    private final static URL yangModelsFolder = AugmentedTypeTest.class.getResource("/choice-case-type-test-models")
-            ;
+public class ChoiceCaseGenTypesTest extends AbstractTypesTest {
 
-    @BeforeClass
-    public static void loadTestResources() throws URISyntaxException {
-        final File augFolder = new File(yangModelsFolder.toURI());
-        for (final File fileEntry : augFolder.listFiles()) {
-            if (fileEntry.isFile()) {
-                yangModels.add(fileEntry);
-            }
-        }
+    public ChoiceCaseGenTypesTest() {
+        super(ChoiceCaseGenTypesTest.class.getResource("/choice-case-type-test-models"));
     }
 
-    private static GeneratedType checkGeneratedType(List<Type> genTypes, String genTypeName, String packageName,
-            int occurences) {
+    private GeneratedType checkGeneratedType(List<Type> genTypes, String genTypeName, String packageName, int occurences) {
         GeneratedType searchedGenType = null;
         int searchedGenTypeCounter = 0;
         for (Type type : genTypes) {
@@ -67,16 +49,14 @@ public class ChoiceCaseGenTypesTest {
 
     }
 
-    private static GeneratedType checkGeneratedType(List<Type> genTypes, String genTypeName, String packageName) {
+    private GeneratedType checkGeneratedType(List<Type> genTypes, String genTypeName, String packageName) {
         return checkGeneratedType(genTypes, genTypeName, packageName, 1);
     }
 
     @Test
-    public void choiceCaseResolvingTypeTest() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(yangModels);
-
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public void choiceCaseResolvingTypeTest() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull("context is null", context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -147,7 +127,6 @@ public class ChoiceCaseGenTypesTest {
 
         genType = checkGeneratedType(genTypes, "LeafAugCase", pcgPref
                 + ".netconf.state.datastores.datastore.locks.lock.type"); // choice
-        // FIXME
         containsMethods(genType, new NameTypePattern("getLeafAugCase", "String"));
         containsInterface("LockType", genType);
 
index 93362b9c884aa689b254c857f4ebbf23ccb31733..34705a9e86983f234334d33df1900a3d7dd0c9aa 100644 (file)
@@ -12,19 +12,17 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class ControllerTest {
@@ -45,10 +43,9 @@ public class ControllerTest {
     }
 
     @Test
-    public void controllerAugmentationTest() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(controllerModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public void controllerAugmentationTest() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(controllerModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
index 481d6149ede4e007e3c8680c058ed7fbb015b145..7c7fb9de550c8ab9148cf7915b9f6498d449a1ce 100644 (file)
@@ -13,12 +13,11 @@ import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
@@ -26,9 +25,8 @@ import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.sal.binding.yang.types.BaseYangTypes;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class ExtendedTypedefTest {
@@ -48,10 +46,9 @@ public class ExtendedTypedefTest {
     }
 
     @Test
-    public void constantGenerationTest() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public void constantGenerationTest() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
index ce37ca5e25f6e090c8e18621c38979a29fafbfb1..8aefb6b175283719a69c2e7da8b8bd454aee5d75 100644 (file)
@@ -12,48 +12,42 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.yangtools.sal.binding.model.api.Enumeration;
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedType;
 import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class GenEnumResolvingTest {
 
-    private SchemaContext resolveSchemaContextFromFiles(
-            final URI... yangFiles) {
-        final YangModelParser parser = new YangParserImpl();
+    private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+        final YangContextParser parser = new YangParserImpl();
 
         final List<File> inputFiles = new ArrayList<File>();
         for (int i = 0; i < yangFiles.length; ++i) {
             inputFiles.add(new File(yangFiles[i]));
         }
 
-        final Set<Module> modules = parser.parseYangModels(inputFiles);
-        return parser.resolveSchemaContext(modules);
+        return parser.parseFiles(inputFiles);
     }
 
     @Test
-    public void testLeafEnumResolving() throws URISyntaxException {
-        final URI ietfInterfacesPath = getClass().getResource(
-                "/enum-test-models/ietf-interfaces@2012-11-15.yang").toURI();
-        final URI ifTypePath = getClass().getResource(
-                "/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
-        final URI yangTypesPath = getClass().getResource(
-                "/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
-
-        final SchemaContext context = resolveSchemaContextFromFiles(
-                ietfInterfacesPath, ifTypePath, yangTypesPath);
+    public void testLeafEnumResolving() throws URISyntaxException, IOException {
+        final URI ietfInterfacesPath = getClass().getResource("/enum-test-models/ietf-interfaces@2012-11-15.yang")
+                .toURI();
+        final URI ifTypePath = getClass().getResource("/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
+        final URI yangTypesPath = getClass().getResource("/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
+
+        final SchemaContext context = resolveSchemaContextFromFiles(ietfInterfacesPath, ifTypePath, yangTypesPath);
         assertTrue(context != null);
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -70,16 +64,13 @@ public class GenEnumResolvingTest {
                 }
             }
         }
-        assertNotNull("Generated Type Interface is not present in list of " +
-                "Generated Types", genInterface);
+        assertNotNull("Generated Type Interface is not present in list of Generated Types", genInterface);
 
         Enumeration linkUpDownTrapEnable = null;
         Enumeration operStatus = null;
         final List<Enumeration> enums = genInterface.getEnumerations();
-        assertNotNull("Generated Type Interface cannot contain NULL reference" +
-                " to Enumeration types!", enums);
-        assertEquals("Generated Type Interface MUST contain 2 Enumeration " +
-                "Types", 2, enums.size());
+        assertNotNull("Generated Type Interface cannot contain NULL reference to Enumeration types!", enums);
+        assertEquals("Generated Type Interface MUST contain 2 Enumeration Types", 2, enums.size());
         for (final Enumeration e : enums) {
             if (e.getName().equals("LinkUpDownTrapEnable")) {
                 linkUpDownTrapEnable = e;
@@ -88,46 +79,36 @@ public class GenEnumResolvingTest {
             }
         }
 
-        assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!",
-                linkUpDownTrapEnable);
+        assertNotNull("Expected Enum LinkUpDownTrapEnable, but was NULL!", linkUpDownTrapEnable);
         assertNotNull("Expected Enum OperStatus, but was NULL!", operStatus);
 
-        assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition " +
-                "not NULL reference!", linkUpDownTrapEnable.getValues());
-        assertNotNull("Enum OperStatus MUST contain Values definition not " +
-                "NULL reference!", operStatus.getValues());
-        assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2,
-                linkUpDownTrapEnable.getValues().size());
-        assertEquals("Enum OperStatus MUST contain 7 values!", 7,
-                operStatus.getValues().size());
+        assertNotNull("Enum LinkUpDownTrapEnable MUST contain Values definition not NULL reference!",
+                linkUpDownTrapEnable.getValues());
+        assertNotNull("Enum OperStatus MUST contain Values definition not NULL reference!", operStatus.getValues());
+        assertEquals("Enum LinkUpDownTrapEnable MUST contain 2 values!", 2, linkUpDownTrapEnable.getValues().size());
+        assertEquals("Enum OperStatus MUST contain 7 values!", 7, operStatus.getValues().size());
 
-        final List<MethodSignature> methods = genInterface
-                .getMethodDefinitions();
+        final List<MethodSignature> methods = genInterface.getMethodDefinitions();
 
-        assertNotNull("Generated Interface cannot contain NULL reference for " +
-                "Method Signature Definitions!", methods);
+        assertNotNull("Generated Interface cannot contain NULL reference for Method Signature Definitions!", methods);
 
-        assertEquals("Expected count of method signature definitions is 15",
-                15, methods.size());
+        assertEquals("Expected count of method signature definitions is 15", 15, methods.size());
         Enumeration ianaIfType = null;
         for (final MethodSignature method : methods) {
             if (method.getName().equals("getType")) {
                 if (method.getReturnType() instanceof Enumeration) {
-                    ianaIfType = (Enumeration)method.getReturnType();
+                    ianaIfType = (Enumeration) method.getReturnType();
                 }
             }
         }
 
-        assertNotNull("Method getType MUST return Enumeration Type, " +
-                "not NULL reference!", ianaIfType);
-        assertEquals("Enumeration getType MUST contain 272 values!", 272,
-                ianaIfType.getValues().size());
+        assertNotNull("Method getType MUST return Enumeration Type not NULL reference!", ianaIfType);
+        assertEquals("Enumeration getType MUST contain 272 values!", 272, ianaIfType.getValues().size());
     }
 
     @Test
-    public void testTypedefEnumResolving() throws URISyntaxException {
-        final URI ianaIfTypePath = getClass().getResource(
-                "/leafref-test-models/iana-if-type@2012-06-05.yang").toURI();
+    public void testTypedefEnumResolving() throws URISyntaxException, IOException {
+        final URI ianaIfTypePath = getClass().getResource("/leafref-test-models/iana-if-type@2012-06-05.yang").toURI();
 
         final SchemaContext context = resolveSchemaContextFromFiles(ianaIfTypePath);
         assertTrue(context != null);
@@ -140,27 +121,19 @@ public class GenEnumResolvingTest {
         assertTrue(type instanceof Enumeration);
 
         final Enumeration enumer = (Enumeration) type;
-        assertEquals("Enumeration type MUST contain 272 values!", 272,
-                enumer.getValues().size());
+        assertEquals("Enumeration type MUST contain 272 values!", 272, enumer.getValues().size());
     }
 
     @Test
-    public void testLeafrefEnumResolving() throws URISyntaxException {
-        final URI ietfInterfacesPath = getClass().getResource(
-                "/enum-test-models/ietf-interfaces@2012-11-15.yang").toURI();
-        final URI ifTypePath = getClass().getResource(
-                "/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
-        final URI yangTypesPath = getClass().getResource(
-                "/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
-        final URI topologyPath = getClass().getResource(
-                "/enum-test-models/abstract-topology@2013-02-08.yang")
+    public void testLeafrefEnumResolving() throws URISyntaxException, IOException {
+        final URI ietfInterfacesPath = getClass().getResource("/enum-test-models/ietf-interfaces@2012-11-15.yang")
                 .toURI();
-        final URI inetTypesPath = getClass().getResource(
-                "/enum-test-models/ietf-inet-types@2010-09-24.yang")
-                .toURI();
-        final SchemaContext context = resolveSchemaContextFromFiles(
-                ietfInterfacesPath, ifTypePath, yangTypesPath, topologyPath,
-                inetTypesPath);
+        final URI ifTypePath = getClass().getResource("/enum-test-models/iana-if-type@2012-06-05.yang").toURI();
+        final URI yangTypesPath = getClass().getResource("/enum-test-models/ietf-yang-types@2010-09-24.yang").toURI();
+        final URI topologyPath = getClass().getResource("/enum-test-models/abstract-topology@2013-02-08.yang").toURI();
+        final URI inetTypesPath = getClass().getResource("/enum-test-models/ietf-inet-types@2010-09-24.yang").toURI();
+        final SchemaContext context = resolveSchemaContextFromFiles(ietfInterfacesPath, ifTypePath, yangTypesPath,
+                topologyPath, inetTypesPath);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -171,22 +144,20 @@ public class GenEnumResolvingTest {
         GeneratedType genInterface = null;
         for (final Type type : genTypes) {
             if (type instanceof GeneratedType) {
-                if (type.getPackageName().equals("org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208.topology.interfaces")
+                if (type.getPackageName().equals(
+                        "org.opendaylight.yang.gen.v1.urn.model._abstract.topology.rev130208.topology.interfaces")
                         && type.getName().equals("Interface")) {
                     genInterface = (GeneratedType) type;
                 }
             }
         }
-        assertNotNull("Generated Type Interface is not present in list of " +
-                "Generated Types", genInterface);
+        assertNotNull("Generated Type Interface is not present in list of Generated Types", genInterface);
 
         Type linkUpDownTrapEnable = null;
         Type operStatus = null;
         final List<MethodSignature> methods = genInterface.getMethodDefinitions();
-        assertNotNull("Generated Type Interface cannot contain NULL reference" +
-                " to Enumeration types!", methods);
-        assertEquals("Generated Type Interface MUST contain 5 Methods ",
-                5, methods.size());
+        assertNotNull("Generated Type Interface cannot contain NULL reference to Enumeration types!", methods);
+        assertEquals("Generated Type Interface MUST contain 5 Methods ", 5, methods.size());
         for (final MethodSignature method : methods) {
             if (method.getName().equals("getLinkUpDownTrapEnable")) {
                 linkUpDownTrapEnable = method.getReturnType();
@@ -195,16 +166,15 @@ public class GenEnumResolvingTest {
             }
         }
 
-        assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!",
-                linkUpDownTrapEnable);
+        assertNotNull("Expected Referenced Enum LinkUpDownTrapEnable, but was NULL!", linkUpDownTrapEnable);
         assertTrue("Expected LinkUpDownTrapEnable of type Enumeration", linkUpDownTrapEnable instanceof Enumeration);
         assertEquals(linkUpDownTrapEnable.getPackageName(),
                 "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");
 
-        assertNotNull("Expected Referenced Enum OperStatus, but was NULL!",
-                operStatus);
+        assertNotNull("Expected Referenced Enum OperStatus, but was NULL!", operStatus);
         assertTrue("Expected OperStatus of type Enumeration", operStatus instanceof Enumeration);
         assertEquals(operStatus.getPackageName(),
                 "org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev121115.interfaces.Interface");
     }
+
 }
index 3f5295b02f7135ddf6ee1804f0af199bbcdd0dbc..c3443eb7d879727cf3790b66b5e15d0bf6e92def 100644 (file)
@@ -12,20 +12,20 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class GenTypesSubSetTest {
@@ -46,10 +46,10 @@ public class GenTypesSubSetTest {
     }
 
     @Test
-    public void genTypesFromSubsetOfTwoModulesTest() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(yangModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public void genTypesFromSubsetOfTwoModulesTest() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(yangModels);
+        Set<Module> modules = context.getModules();
 
         final Set<Module> toGenModules = new HashSet<>();
         for (final Module module : modules) {
@@ -73,10 +73,10 @@ public class GenTypesSubSetTest {
     }
 
     @Test
-    public void genTypesFromSubsetOfThreeModulesTest() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(yangModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public void genTypesFromSubsetOfThreeModulesTest() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(yangModels);
+        final Set<Module> modules = context.getModules();
 
         final Set<Module> toGenModules = new HashSet<>();
         for (final Module module : modules) {
index 153ca3acdcfeb8b2c1ef5bfe4f6ccb450dfc31ae..1dc8f00dde6757309805380aa0ff635f7c558fb2 100644 (file)
@@ -13,9 +13,7 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.util.List;
-
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
@@ -30,7 +28,7 @@ public class GeneratedTypesBitsTest {
 
 
     @Test
-    public void testGeneretedTypesBitsTest() throws URISyntaxException {
+    public void testGeneretedTypesBitsTest() throws Exception {
         final URI yangTypesPath = getClass().getResource("/simple-bits-demo.yang").toURI();
 
         final SchemaContext context = SupportTestUtil.resolveSchemaContextFromFiles(yangTypesPath);
@@ -51,7 +49,6 @@ public class GeneratedTypesBitsTest {
         int hashPropertiesNum = 0;
 
         String nameReturnParamType = "";
-        String nameMethodeParamType = "";
         boolean getByteLeafMethodFound = false;
         boolean setByteLeafMethodFound = false;
         int setByteLeafMethodParamNum = 0;
@@ -100,10 +97,6 @@ public class GeneratedTypesBitsTest {
 
                                 List<Parameter> parameters = methodSignature.getParameters();
                                 setByteLeafMethodParamNum = parameters.size();
-                                for (Parameter parameter : parameters) {
-                                    nameMethodeParamType = parameter.getType().getName();
-                                }
-
                             }
 
                         }
index dff47a37406b4f24c428c91df864d1620df2561d..3eccac64aaab46c94b0031e1cbf9a9fdd5ca35d7 100644 (file)
@@ -7,15 +7,17 @@
  */
 package org.opendaylight.yangtools.sal.binding.generator.impl;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.fail;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
-
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
@@ -23,27 +25,25 @@ 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.MethodSignature;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class GeneratedTypesLeafrefTest {
 
-    private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {
-        final YangModelParser parser = new YangParserImpl();
+    private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+        final YangContextParser parser = new YangParserImpl();
 
         final List<File> inputFiles = new ArrayList<File>();
         for (int i = 0; i < yangFiles.length; ++i) {
             inputFiles.add(new File(yangFiles[i]));
         }
 
-        final Set<Module> modules = parser.parseYangModels(inputFiles);
-        return parser.resolveSchemaContext(modules);
+        return parser.parseFiles(inputFiles);
     }
 
     @Test
-    public void testLeafrefResolving() throws URISyntaxException {
+    public void testLeafrefResolving() throws URISyntaxException, IOException {
         final URI topologyPath = getClass().getResource("/leafref-test-models/abstract-topology@2013-02-08.yang")
                 .toURI();
         final URI interfacesPath = getClass().getResource("/leafref-test-models/ietf-interfaces@2012-11-15.yang")
@@ -236,7 +236,7 @@ public class GeneratedTypesLeafrefTest {
     }
 
     @Test
-    public void testLeafrefInvalidPathResolving() throws URISyntaxException {
+    public void testLeafrefInvalidPathResolving() throws URISyntaxException, IOException {
         final URI resource = getClass().getResource("/leafref-test-invalid-model/foo.yang").toURI();
         assertNotNull(resource);
 
index ada474a78ed2206c44bf89357fb2cbb2b299dae9..d0f15174f384d2aa3e58d8d4d05dfc4d92b56ccd 100644 (file)
@@ -7,14 +7,14 @@
  */
 package org.opendaylight.yangtools.sal.binding.generator.impl;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
@@ -22,9 +22,8 @@ import org.opendaylight.yangtools.sal.binding.model.api.Constant;
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class GeneratedTypesStringTest {
@@ -39,10 +38,9 @@ public class GeneratedTypesStringTest {
     }
 
     @Test
-    public void constantGenerationTest() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public void constantGenerationTest() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
index e28a31697f68de80f3729515613e3f98ed326762..014c7112d48bb0b69ac455ca4fdd879de1db0675 100644 (file)
@@ -7,15 +7,15 @@
  */
 package org.opendaylight.yangtools.sal.binding.generator.impl;
 
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
-
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
@@ -23,27 +23,25 @@ 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.MethodSignature;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class GeneratedTypesTest {
 
-    private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {
-        final YangModelParser parser = new YangParserImpl();
+    private SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+        final YangContextParser parser = new YangParserImpl();
 
         final List<File> inputFiles = new ArrayList<File>();
         for (int i = 0; i < yangFiles.length; ++i) {
             inputFiles.add(new File(yangFiles[i]));
         }
 
-        final Set<Module> modules = parser.parseYangModels(inputFiles);
-        return parser.resolveSchemaContext(modules);
+        return parser.parseFiles(inputFiles);
     }
 
     @Test
-    public void testMultipleModulesResolving() throws URISyntaxException {
+    public void testMultipleModulesResolving() throws URISyntaxException, IOException {
         final URI topologyPath = getClass().getResource("/abstract-topology.yang").toURI();
         final URI typesPath = getClass().getResource("/ietf-inet-types@2010-09-24.yang").toURI();
         final SchemaContext context = resolveSchemaContextFromFiles(topologyPath, typesPath);
@@ -57,7 +55,7 @@ public class GeneratedTypesTest {
     }
 
     @Test
-    public void testContainerResolving() throws URISyntaxException {
+    public void testContainerResolving() throws URISyntaxException, IOException {
         final URI filePath = getClass().getResource("/simple-container-demo.yang").toURI();
         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
         assert (context != null);
@@ -142,7 +140,7 @@ public class GeneratedTypesTest {
     }
 
     @Test
-    public void testLeafListResolving() throws URISyntaxException {
+    public void testLeafListResolving() throws URISyntaxException, IOException {
         final URI filePath = getClass().getResource("/simple-leaf-list-demo.yang").toURI();
         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
         assertNotNull(context);
@@ -226,7 +224,7 @@ public class GeneratedTypesTest {
     }
 
     @Test
-    public void testListResolving() throws URISyntaxException {
+    public void testListResolving() throws URISyntaxException, IOException {
         final URI filePath = getClass().getResource("/simple-list-demo.yang").toURI();
         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
         assertNotNull(context);
@@ -349,7 +347,7 @@ public class GeneratedTypesTest {
     }
 
     @Test
-    public void testListCompositeKeyResolving() throws URISyntaxException {
+    public void testListCompositeKeyResolving() throws URISyntaxException, IOException {
         final URI filePath = getClass().getResource("/list-composite-key.yang").toURI();
         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
 
@@ -402,7 +400,7 @@ public class GeneratedTypesTest {
     }
 
     @Test
-    public void testGeneratedTypes() throws URISyntaxException {
+    public void testGeneratedTypes() throws URISyntaxException, IOException {
         final URI filePath = getClass().getResource("/demo-topology.yang").toURI();
         final SchemaContext context = resolveSchemaContextFromFiles(filePath);
         assertNotNull(context);
index 378ccc708017f055209abf7be28cf6f9ef8a2362..ff81f55bebbe62a670986625e080471e7b6905f4 100644 (file)
@@ -11,12 +11,11 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
-
 import org.junit.Before;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
@@ -25,9 +24,8 @@ import org.opendaylight.yangtools.sal.binding.model.api.MethodSignature;
 import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.sal.binding.yang.types.TypeProviderImpl;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class IdentityrefTypeTest {
@@ -57,10 +55,9 @@ public class IdentityrefTypeTest {
      * provideTypeForIdentityref}
      */
     @Test
-    public void testIdentityrefYangBuiltInType() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public void testIdentityrefYangBuiltInType() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
index 1a767ea63b96637590337ff39f83fb922dba5e92..59a04ff4e68e172a86859e216373d3857a1571eb 100644 (file)
@@ -11,34 +11,31 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
-
 import org.opendaylight.yangtools.sal.binding.model.api.GeneratedProperty;
 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.MethodSignature;
 import org.opendaylight.yangtools.sal.binding.model.api.ParameterizedType;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class SupportTestUtil {
 
-    public static SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) {
-        final YangModelParser parser = new YangParserImpl();
+    public static SchemaContext resolveSchemaContextFromFiles(final URI... yangFiles) throws IOException {
+        final YangContextParser parser = new YangParserImpl();
 
         final List<File> inputFiles = new ArrayList<File>();
         for (int i = 0; i < yangFiles.length; ++i) {
             inputFiles.add(new File(yangFiles[i]));
         }
 
-        final Set<Module> modules = parser.parseYangModels(inputFiles);
-        return parser.resolveSchemaContext(modules);
+        return parser.parseFiles(inputFiles);
     }
 
     public static void containsMethods(final GeneratedType genType, final NameTypePattern... searchedSignsWhat) {
index 8df0beee7b2417fc39c0c084ab9d1e9bcd96471e..5fce20947b358392743f7eb38101ce5269d518d4 100644 (file)
@@ -11,11 +11,9 @@ import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertNotNull;
 
 import java.net.URI;
-import java.net.URISyntaxException;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.Set;
-
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -33,7 +31,7 @@ public class TypeProviderIntegrationTest {
     private Module m;
 
     @BeforeClass
-    public static void setup() throws ParseException, URISyntaxException {
+    public static void setup() throws Exception {
         final URI path1 = TypeProviderIntegrationTest.class.getResource("/type-provider/test.yang").toURI();
         final URI path2 = TypeProviderIntegrationTest.class.getResource(
                 "/type-provider/ietf-inet-types@2010-09-24.yang").toURI();
index daf8de55885ed19182b468aab6827c70f4e605b2..18610d2b9d6e6e8f206134e354221a7f8b5e8cb9 100644 (file)
@@ -11,19 +11,17 @@ import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertNotNull;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
-
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class UnionTypeDefTest {
@@ -43,10 +41,9 @@ public class UnionTypeDefTest {
     }
 
     @Test
-    public void unionTypeResolvingTest() {
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(yangModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+    public void unionTypeResolvingTest() throws IOException {
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(yangModels);
 
         assertNotNull("context is null", context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
index 42620a26a276936176107ce98e0733e5c84cd98d..8c4cb56c361e7323b36748f776a56c216e23d063 100644 (file)
@@ -14,19 +14,17 @@ import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestU
 import static org.opendaylight.yangtools.sal.binding.generator.impl.SupportTestUtil.containsMethods;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
-import java.util.Set;
-
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.generator.api.BindingGenerator;
 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.Type;
-import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 
 public class UsesTest {
@@ -43,11 +41,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInGroupingDependenciesTest() {
+    public void usesInGroupingDependenciesTest() throws IOException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-dependencies.yang");
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -99,11 +96,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInCaseTest() {
+    public void usesInCaseTest() throws IOException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-case.yang");
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -148,11 +144,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInContainerTest() {
+    public void usesInContainerTest() throws IOException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-container.yang");
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -202,11 +197,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInGroupingTest() {
+    public void usesInGroupingTest() throws IOException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-grouping.yang");
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -254,11 +248,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInListTest() {
+    public void usesInListTest() throws IOException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-list.yang");
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -337,11 +330,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInModulTest() {
+    public void usesInModulTest() throws IOException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-modul.yang");
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -389,11 +381,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInRpcTest() {
+    public void usesInRpcTest() throws IOException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-rpc.yang");
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -483,11 +474,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInAugmentTest() {
+    public void usesInAugmentTest() throws IOException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-augment.yang");
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
@@ -537,11 +527,10 @@ public class UsesTest {
     }
 
     @Test
-    public void usesInNotification() {
+    public void usesInNotification() throws IOException {
         List<File> testModels = loadTestResources("/uses-of-grouping/uses-of-grouping-notification.yang");
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
-        final SchemaContext context = parser.resolveSchemaContext(modules);
+        final YangContextParser parser = new YangParserImpl();
+        final SchemaContext context = parser.parseFiles(testModels);
 
         assertNotNull(context);
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
index d80a3e9fdd1cfd14dfe58c4a1631c692bf170a53..7fe9e7419747238e763e0c86e8f15c97b28354a4 100644 (file)
@@ -3,48 +3,29 @@ module abstract-topology {
     namespace "urn:model:abstract:topology";
     prefix "tp";
 
-    import ietf-inet-types { 
-        prefix "inet"; 
-        revision-date 2010-09-24;
-    }
-
-    organization "OPEN DAYLIGHT";
-    contact "http://www.opendaylight.org/";
-
-    description
-        "This module contains the definitions of elements that creates network 
-    topology i.e. definition of network nodes and links. This module is not designed 
-    to be used solely for network representation. This module SHOULD be used as base 
-    module in defining the network topology.";
-
     revision "2013-02-08" {
-        reference "http://www.opendaylight.org/";
     }
-    
+
     typedef node-id-ref {
         type leafref {
             path "/tp:topology/tp:network-nodes/tp:network-node/tp:node-id";
         }
-        description "This type is used for leafs that reference network node instance.";
     }
 
     typedef link-id-ref {
         type leafref {
             path "/tp:topology/tp:network-links/tp:network-link/tp:link-id";
         }
-        description "This type is used for leafs that reference network link instance.";
+    }
+
+    typedef uri {
+        type string;
     }
 
     container topology {
-        description "This is the model of abstract topology which contains 
-        only Network Nodes and Network Links. Each topology MUST be identified by unique 
-        topology-id for reason that the store could contain many topologies.";
 
         leaf topology-id {
-            type inet:uri;
-            description "It is presumed that datastore will contain many topologies. 
-            To distinguish between topologies it is vital to have
-            UNIQUE topology identifier.";
+            type uri;
         }
 
         container network-nodes {
@@ -52,50 +33,39 @@ module abstract-topology {
                 key "node-id";
 
                 leaf node-id {
-                    type inet:uri;
-                    description "The Topology identifier of network-node.";
+                    type uri;
                 }
 
                 container attributes {
-                    description "Aditional attributes that can Network Node contains.";
                 }
-                description "The list of network nodes defined for topology.";
             }
         }
-        
+
         container network-links {
             list network-link {
                 key "link-id";
 
                 leaf link-id {
-                    type inet:uri;
+                    type uri;
                     description "";
                 }
 
                 container source-node {
                     leaf id {
                         type node-id-ref;
-                        description "Source node identifier.";
                     }
                 }
 
                 container destination-node {
                     leaf id {
                         type node-id-ref;
-                        description "Destination node identifier.";
                     }
                 }
 
                 container attributes {
-                    description "Aditional attributes that can Network Link contains.";
                 }
-                description "The Network Link which is defined by Local (Source) and Remote (Destination) 
-                Network Nodes. Every link MUST be defined either by identifier and
-                his local and remote Network Nodes (In real applications it is common that 
-                many links are originated from one node and end up in same remote node). 
-                To ensure that we would always know to distinguish between links, every link 
-                SHOULD have identifier.";
             }
         }
     }
-}
\ No newline at end of file
+
+}
index f016a4901be5d42efcb0f207287ff171c743da55..6e6aec1ae89190016e7a1030df0ac48a083e16dc 100644 (file)
@@ -3,11 +3,6 @@ module augment-abstract-topology {
     namespace "urn:model:augment:abstract:topology";
     prefix "atp";
 
-    import ietf-inet-types { 
-        prefix "inet";
-        revision-date 2010-09-24;
-    }
-
     import ietf-interfaces {
         prefix "if";
         revision-date 2012-11-15;
@@ -18,11 +13,7 @@ module augment-abstract-topology {
         revision-date 2013-02-08;
     }
 
-    organization "OPEN DAYLIGHT";
-    contact "http://www.opendaylight.org/";
-
     revision "2013-05-03" {
-        reference "http://www.opendaylight.org/";
     }
 
     augment "/at:topology" {
@@ -66,4 +57,4 @@ module augment-abstract-topology {
             }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/iana-if-type@2012-06-05.yang b/code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/iana-if-type@2012-06-05.yang
deleted file mode 100644 (file)
index a7fa137..0000000
+++ /dev/null
@@ -1,1516 +0,0 @@
-module iana-if-type {
-  namespace "urn:ietf:params:xml:ns:yang:iana-if-type";
-  prefix ianaift;
-
-  organization "IANA";
-  contact
-    "        Internet Assigned Numbers Authority
-
-     Postal: ICANN
-             4676 Admiralty Way, Suite 330
-             Marina del Rey, CA 90292
-
-     Tel:    +1 310 823 9358
-     E-Mail: iana&iana.org";
-  description
-    "This YANG module defines the iana-if-type typedef, which
-     contains YANG definitions for IANA-registered interface types.
-
-     This YANG module is maintained by IANA, and reflects the
-     'ifType definitions' registry.
-
-     The latest revision of this YANG module can be obtained from
-     the IANA web site.
-
-     Copyright (c) 2011 IETF Trust and the persons identified as
-     authors of the code.  All rights reserved.
-
-     Redistribution and use in source and binary forms, with or
-     without modification, is permitted pursuant to, and subject
-     to the license terms contained in, the Simplified BSD License
-     set forth in Section 4.c of the IETF Trust's Legal Provisions
-     Relating to IETF Documents
-     (http://trustee.ietf.org/license-info).
-
-     This version of this YANG module is part of RFC XXXX; see
-     the RFC itself for full legal notices.";
-  // RFC Ed.: replace XXXX with actual RFC number and remove this
-  // note.
-
-  // RFC Ed.: update the date below with the date of RFC publication
-  // and remove this note.
-  revision 2012-06-05 {
-    description
-      "Initial revision.";
-    reference
-      "RFC XXXX: TITLE";
-  }
-
-  typedef iana-if-type {
-    type enumeration {
-      enum "other" {
-        value 1;
-        description
-          "None of the following";
-      }
-      enum "regular1822" {
-        value 2;
-      }
-      enum "hdh1822" {
-        value 3;
-      }
-      enum "ddnX25" {
-        value 4;
-      }
-      enum "rfc877x25" {
-        value 5;
-        reference
-          "RFC 1382 - SNMP MIB Extension for the X.25 Packet Layer";
-      }
-      enum "ethernetCsmacd" {
-        value 6;
-        description
-          "For all ethernet-like interfaces, regardless of speed,
-           as per RFC3635.";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "iso88023Csmacd" {
-        value 7;
-        status deprecated;
-        description
-          "Deprecated via RFC3635.
-           Use ethernetCsmacd(6) instead.";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "iso88024TokenBus" {
-        value 8;
-      }
-      enum "iso88025TokenRing" {
-        value 9;
-      }
-      enum "iso88026Man" {
-        value 10;
-      }
-      enum "starLan" {
-        value 11;
-        status deprecated;
-        description
-          "Deprecated via RFC3635.
-           Use ethernetCsmacd(6) instead.";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "proteon10Mbit" {
-        value 12;
-      }
-      enum "proteon80Mbit" {
-        value 13;
-      }
-      enum "hyperchannel" {
-        value 14;
-      }
-      enum "fddi" {
-        value 15;
-        reference
-          "RFC 1512 - FDDI Management Information Base";
-      }
-      enum "lapb" {
-        value 16;
-        reference
-          "RFC 1381 - SNMP MIB Extension for X.25 LAPB";
-      }
-      enum "sdlc" {
-        value 17;
-      }
-      enum "ds1" {
-        value 18;
-        description
-          "DS1-MIB";
-        reference
-          "RFC 4805 - Definitions of Managed Objects for the
-                      DS1, J1, E1, DS2, and E2 Interface Types";
-      }
-      enum "e1" {
-        value 19;
-        status obsolete;
-        description
-          "Obsolete see DS1-MIB";
-        reference
-          "RFC 4805 - Definitions of Managed Objects for the
-                      DS1, J1, E1, DS2, and E2 Interface Types";
-      }
-      enum "basicISDN" {
-        value 20;
-        description
-          "see also RFC2127";
-      }
-      enum "primaryISDN" {
-        value 21;
-      }
-      enum "propPointToPointSerial" {
-        value 22;
-        description
-          "proprietary serial";
-      }
-      enum "ppp" {
-        value 23;
-      }
-      enum "softwareLoopback" {
-        value 24;
-      }
-      enum "eon" {
-        value 25;
-        description
-          "CLNP over IP";
-      }
-      enum "ethernet3Mbit" {
-        value 26;
-      }
-      enum "nsip" {
-        value 27;
-        description
-          "XNS over IP";
-      }
-      enum "slip" {
-        value 28;
-        description
-          "generic SLIP";
-      }
-      enum "ultra" {
-        value 29;
-        description
-          "ULTRA technologies";
-      }
-      enum "ds3" {
-        value 30;
-        description
-          "DS3-MIB";
-        reference
-          "RFC 3896 - Definitions of Managed Objects for the
-                      DS3/E3 Interface Type";
-      }
-      enum "sip" {
-        value 31;
-        description
-          "SMDS, coffee";
-        reference
-          "RFC 1694 - Definitions of Managed Objects for SMDS
-                      Interfaces using SMIv2";
-      }
-      enum "frameRelay" {
-        value 32;
-        description
-          "DTE only.";
-        reference
-          "RFC 2115 - Management Information Base for Frame Relay
-                      DTEs Using SMIv2";
-      }
-      enum "rs232" {
-        value 33;
-        reference
-          "RFC 1659 - Definitions of Managed Objects for RS-232-like
-                      Hardware Devices using SMIv2";
-      }
-      enum "para" {
-        value 34;
-        description
-          "parallel-port";
-        reference
-          "RFC 1660 - Definitions of Managed Objects for
-                      Parallel-printer-like Hardware Devices using
-                      SMIv2";
-      }
-      enum "arcnet" {
-        value 35;
-        description
-          "arcnet";
-      }
-      enum "arcnetPlus" {
-        value 36;
-        description
-          "arcnet plus";
-      }
-      enum "atm" {
-        value 37;
-        description
-          "ATM cells";
-      }
-      enum "miox25" {
-        value 38;
-        reference
-          "RFC 1461 - SNMP MIB extension for Multiprotocol
-                      Interconnect over X.25";
-      }
-      enum "sonet" {
-        value 39;
-        description
-          "SONET or SDH";
-      }
-      enum "x25ple" {
-        value 40;
-        reference
-          "RFC 2127 - ISDN Management Information Base using SMIv2";
-      }
-      enum "iso88022llc" {
-        value 41;
-      }
-      enum "localTalk" {
-        value 42;
-      }
-      enum "smdsDxi" {
-        value 43;
-      }
-      enum "frameRelayService" {
-        value 44;
-        description
-          "FRNETSERV-MIB";
-        reference
-          "RFC 2954 - Definitions of Managed Objects for Frame
-                      Relay Service";
-      }
-      enum "v35" {
-        value 45;
-      }
-      enum "hssi" {
-        value 46;
-      }
-      enum "hippi" {
-        value 47;
-      }
-      enum "modem" {
-        value 48;
-        description
-          "Generic modem";
-      }
-      enum "aal5" {
-        value 49;
-        description
-          "AAL5 over ATM";
-      }
-      enum "sonetPath" {
-        value 50;
-      }
-      enum "sonetVT" {
-        value 51;
-      }
-      enum "smdsIcip" {
-        value 52;
-        description
-          "SMDS InterCarrier Interface";
-      }
-      enum "propVirtual" {
-        value 53;
-        description
-          "proprietary virtual/internal";
-        reference
-          "RFC 2863 - The Interfaces Group MIB";
-      }
-      enum "propMultiplexor" {
-        value 54;
-        description
-          "proprietary multiplexing";
-        reference
-          "RFC 2863 - The Interfaces Group MIB";
-      }
-      enum "ieee80212" {
-        value 55;
-        description
-          "100BaseVG";
-      }
-      enum "fibreChannel" {
-        value 56;
-        description
-          "Fibre Channel";
-      }
-      enum "hippiInterface" {
-        value 57;
-        description
-          "HIPPI interfaces";
-      }
-      enum "frameRelayInterconnect" {
-        value 58;
-        status obsolete;
-        description
-          "Obsolete use either
-           frameRelay(32) or frameRelayService(44).";
-      }
-      enum "aflane8023" {
-        value 59;
-        description
-          "ATM Emulated LAN for 802.3";
-      }
-      enum "aflane8025" {
-        value 60;
-        description
-          "ATM Emulated LAN for 802.5";
-      }
-      enum "cctEmul" {
-        value 61;
-        description
-         "ATM Emulated circuit";
-      }
-      enum "fastEther" {
-        value 62;
-        status deprecated;
-        description
-          "Obsoleted via RFC3635.
-          ethernetCsmacd(6) should be used instead";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "isdn" {
-        value 63;
-        description
-          "ISDN and X.25";
-        reference
-          "RFC 1356 - Multiprotocol Interconnect on X.25 and ISDN
-                      in the Packet Mode";
-      }
-      enum "v11" {
-        value 64;
-        description
-         "CCITT V.11/X.21";
-      }
-      enum "v36" {
-        value 65;
-        description
-          "CCITT V.36";
-      }
-      enum "g703at64k" {
-        value 66;
-        description
-          "CCITT G703 at 64Kbps";
-      }
-      enum "g703at2mb" {
-        value 67;
-        status obsolete;
-        description
-          "Obsolete see DS1-MIB";
-      }
-      enum "qllc" {
-        value 68;
-        description
-          "SNA QLLC";
-      }
-      enum "fastEtherFX" {
-        value 69;
-        status deprecated;
-        description
-          "Obsoleted via RFC3635
-          ethernetCsmacd(6) should be used instead";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "channel" {
-        value 70;
-        description
-          "channel";
-      }
-      enum "ieee80211" {
-        value 71;
-        description
-          "radio spread spectrum";
-      }
-      enum "ibm370parChan" {
-        value 72;
-        description
-          "IBM System 360/370 OEMI Channel";
-      }
-      enum "escon" {
-        value 73;
-        description
-          "IBM Enterprise Systems Connection";
-      }
-      enum "dlsw" {
-        value 74;
-        description
-          "Data Link Switching";
-      }
-      enum "isdns" {
-        value 75;
-        description
-          "ISDN S/T interface";
-      }
-      enum "isdnu" {
-        value 76;
-        description
-          "ISDN U interface";
-      }
-      enum "lapd" {
-        value 77;
-        description
-          "Link Access Protocol D";
-      }
-      enum "ipSwitch" {
-        value 78;
-        description
-          "IP Switching Objects";
-      }
-      enum "rsrb" {
-        value 79;
-        description
-          "Remote Source Route Bridging";
-      }
-      enum "atmLogical" {
-        value 80;
-        description
-          "ATM Logical Port";
-        reference
-          "RFC 3606 - Definitions of Supplemental Managed Objects
-                      for ATM Interface";
-      }
-      enum "ds0" {
-        value 81;
-        description
-          "Digital Signal Level 0";
-        reference
-          "RFC 2494 - Definitions of Managed Objects for the DS0
-                      and DS0 Bundle Interface Type";
-      }
-      enum "ds0Bundle" {
-        value 82;
-        description
-          "group of ds0s on the same ds1";
-        reference
-          "RFC 2494 - Definitions of Managed Objects for the DS0
-                      and DS0 Bundle Interface Type";
-      }
-      enum "bsc" {
-        value 83;
-        description
-          "Bisynchronous Protocol";
-      }
-      enum "async" {
-        value 84;
-        description
-          "Asynchronous Protocol";
-      }
-      enum "cnr" {
-        value 85;
-        description
-          "Combat Net Radio";
-      }
-      enum "iso88025Dtr" {
-        value 86;
-        description
-          "ISO 802.5r DTR";
-      }
-      enum "eplrs" {
-        value 87;
-        description
-          "Ext Pos Loc Report Sys";
-      }
-      enum "arap" {
-        value 88;
-        description
-          "Appletalk Remote Access Protocol";
-      }
-      enum "propCnls" {
-        value 89;
-        description
-          "Proprietary Connectionless Protocol";
-      }
-      enum "hostPad" {
-        value 90;
-        description
-          "CCITT-ITU X.29 PAD Protocol";
-      }
-      enum "termPad" {
-        value 91;
-        description
-          "CCITT-ITU X.3 PAD Facility";
-      }
-      enum "frameRelayMPI" {
-        value 92;
-        description
-          "Multiproto Interconnect over FR";
-      }
-      enum "x213" {
-        value 93;
-        description
-          "CCITT-ITU X213";
-      }
-      enum "adsl" {
-        value 94;
-        description
-          "Asymmetric Digital Subscriber Loop";
-      }
-      enum "radsl" {
-        value 95;
-        description
-          "Rate-Adapt. Digital Subscriber Loop";
-      }
-      enum "sdsl" {
-        value 96;
-        description
-          "Symmetric Digital Subscriber Loop";
-      }
-      enum "vdsl" {
-        value 97;
-        description
-          "Very H-Speed Digital Subscrib. Loop";
-      }
-      enum "iso88025CRFPInt" {
-        value 98;
-        description
-          "ISO 802.5 CRFP";
-      }
-      enum "myrinet" {
-        value 99;
-        description
-          "Myricom Myrinet";
-      }
-      enum "voiceEM" {
-        value 100;
-        description
-          "voice recEive and transMit";
-      }
-      enum "voiceFXO" {
-        value 101;
-        description
-          "voice Foreign Exchange Office";
-      }
-      enum "voiceFXS" {
-        value 102;
-        description
-          "voice Foreign Exchange Station";
-      }
-      enum "voiceEncap" {
-        value 103;
-        description
-          "voice encapsulation";
-      }
-      enum "voiceOverIp" {
-        value 104;
-        description
-          "voice over IP encapsulation";
-      }
-      enum "atmDxi" {
-        value 105;
-        description
-          "ATM DXI";
-      }
-      enum "atmFuni" {
-        value 106;
-        description
-          "ATM FUNI";
-      }
-      enum "atmIma" {
-        value 107;
-        description
-          "ATM IMA";
-      }
-      enum "pppMultilinkBundle" {
-        value 108;
-        description
-          "PPP Multilink Bundle";
-      }
-      enum "ipOverCdlc" {
-        value 109;
-        description
-          "IBM ipOverCdlc";
-      }
-      enum "ipOverClaw" {
-        value 110;
-        description
-          "IBM Common Link Access to Workstn";
-      }
-      enum "stackToStack" {
-        value 111;
-        description
-          "IBM stackToStack";
-      }
-      enum "virtualIpAddress" {
-        value 112;
-        description
-          "IBM VIPA";
-      }
-      enum "mpc" {
-        value 113;
-        description
-          "IBM multi-protocol channel support";
-      }
-      enum "ipOverAtm" {
-        value 114;
-        description
-          "IBM ipOverAtm";
-        reference
-          "RFC 2320 - Definitions of Managed Objects for Classical IP
-                      and ARP Over ATM Using SMIv2 (IPOA-MIB)";
-      }
-      enum "iso88025Fiber" {
-        value 115;
-        description
-          "ISO 802.5j Fiber Token Ring";
-      }
-      enum "tdlc" {
-        value 116;
-        description
-          "IBM twinaxial data link control";
-      }
-      enum "gigabitEthernet" {
-        value 117;
-        status deprecated;
-        description
-          "Obsoleted via RFC3635
-           ethernetCsmacd(6) should be used instead";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "hdlc" {
-        value 118;
-        description
-          "HDLC";
-      }
-      enum "lapf" {
-        value 119;
-        description
-          "LAP F";
-      }
-      enum "v37" {
-        value 120;
-        description
-          "V.37";
-      }
-      enum "x25mlp" {
-        value 121;
-        description
-          "Multi-Link Protocol";
-      }
-      enum "x25huntGroup" {
-        value 122;
-        description
-          "X25 Hunt Group";
-      }
-      enum "transpHdlc" {
-        value 123;
-        description
-          "Transp HDLC";
-      }
-      enum "interleave" {
-        value 124;
-        description
-          "Interleave channel";
-      }
-      enum "fast" {
-        value 125;
-        description
-          "Fast channel";
-      }
-      enum "ip" {
-        value 126;
-        description
-          "IP (for APPN HPR in IP networks)";
-      }
-      enum "docsCableMaclayer" {
-        value 127;
-        description
-          "CATV Mac Layer";
-      }
-      enum "docsCableDownstream" {
-        value 128;
-        description
-          "CATV Downstream interface";
-      }
-      enum "docsCableUpstream" {
-        value 129;
-        description
-          "CATV Upstream interface";
-      }
-      enum "a12MppSwitch" {
-        value 130;
-        description
-          "Avalon Parallel Processor";
-      }
-      enum "tunnel" {
-        value 131;
-        description
-          "Encapsulation interface";
-      }
-      enum "coffee" {
-        value 132;
-        description
-          "coffee pot";
-        reference
-          "RFC 2325 - Coffee MIB";
-      }
-      enum "ces" {
-        value 133;
-        description
-          "Circuit Emulation Service";
-      }
-      enum "atmSubInterface" {
-        value 134;
-        description
-          "ATM Sub Interface";
-      }
-      enum "l2vlan" {
-        value 135;
-        description
-          "Layer 2 Virtual LAN using 802.1Q";
-      }
-      enum "l3ipvlan" {
-        value 136;
-        description
-          "Layer 3 Virtual LAN using IP";
-      }
-      enum "l3ipxvlan" {
-        value 137;
-        description
-          "Layer 3 Virtual LAN using IPX";
-      }
-      enum "digitalPowerline" {
-        value 138;
-        description
-          "IP over Power Lines";
-      }
-      enum "mediaMailOverIp" {
-        value 139;
-        description
-          "Multimedia Mail over IP";
-      }
-      enum "dtm" {
-        value 140;
-        description
-          "Dynamic syncronous Transfer Mode";
-      }
-      enum "dcn" {
-        value 141;
-        description
-          "Data Communications Network";
-      }
-      enum "ipForward" {
-        value 142;
-        description
-          "IP Forwarding Interface";
-      }
-      enum "msdsl" {
-        value 143;
-        description
-          "Multi-rate Symmetric DSL";
-      }
-      enum "ieee1394" {
-        value 144;
-        description
-          "IEEE1394 High Performance Serial Bus";
-      }
-      enum "if-gsn" {
-        value 145;
-        description
-          "HIPPI-6400";
-      }
-      enum "dvbRccMacLayer" {
-        value 146;
-        description
-          "DVB-RCC MAC Layer";
-      }
-      enum "dvbRccDownstream" {
-        value 147;
-        description
-          "DVB-RCC Downstream Channel";
-      }
-      enum "dvbRccUpstream" {
-        value 148;
-        description
-          "DVB-RCC Upstream Channel";
-      }
-      enum "atmVirtual" {
-        value 149;
-        description
-          "ATM Virtual Interface";
-      }
-      enum "mplsTunnel" {
-        value 150;
-        description
-          "MPLS Tunnel Virtual Interface";
-      }
-      enum "srp" {
-        value 151;
-        description
-          "Spatial Reuse Protocol       ";
-      }
-      enum "voiceOverAtm" {
-        value 152;
-        description
-          "Voice Over ATM";
-      }
-      enum "voiceOverFrameRelay" {
-        value 153;
-        description
-          "Voice Over Frame Relay";
-      }
-      enum "idsl" {
-        value 154;
-        description
-          "Digital Subscriber Loop over ISDN";
-      }
-      enum "compositeLink" {
-        value 155;
-        description
-          "Avici Composite Link Interface";
-      }
-      enum "ss7SigLink" {
-        value 156;
-        description
-          "SS7 Signaling Link";
-      }
-      enum "propWirelessP2P" {
-        value 157;
-        description
-          "Prop. P2P wireless interface";
-      }
-      enum "frForward" {
-        value 158;
-        description
-          "Frame Forward Interface";
-      }
-      enum "rfc1483" {
-        value 159;
-        description
-          "Multiprotocol over ATM AAL5";
-        reference
-          "RFC 1483 - Multiprotocol Encapsulation over ATM
-                      Adaptation Layer 5";
-      }
-      enum "usb" {
-        value 160;
-        description
-          "USB Interface";
-      }
-      enum "ieee8023adLag" {
-        value 161;
-        description
-          "IEEE 802.3ad Link Aggregate";
-      }
-      enum "bgppolicyaccounting" {
-        value 162;
-        description
-          "BGP Policy Accounting";
-      }
-      enum "frf16MfrBundle" {
-        value 163;
-        description
-          "FRF .16 Multilink Frame Relay";
-      }
-      enum "h323Gatekeeper" {
-        value 164;
-        description
-          "H323 Gatekeeper";
-      }
-      enum "h323Proxy" {
-        value 165;
-        description
-          "H323 Voice and Video Proxy";
-      }
-      enum "mpls" {
-        value 166;
-        description
-          "MPLS";
-      }
-      enum "mfSigLink" {
-        value 167;
-        description
-          "Multi-frequency signaling link";
-      }
-      enum "hdsl2" {
-        value 168;
-        description
-          "High Bit-Rate DSL - 2nd generation";
-      }
-      enum "shdsl" {
-        value 169;
-        description
-          "Multirate HDSL2";
-      }
-      enum "ds1FDL" {
-        value 170;
-        description
-          "Facility Data Link 4Kbps on a DS1";
-      }
-      enum "pos" {
-        value 171;
-        description
-          "Packet over SONET/SDH Interface";
-      }
-      enum "dvbAsiIn" {
-        value 172;
-        description
-          "DVB-ASI Input";
-      }
-      enum "dvbAsiOut" {
-        value 173;
-        description
-          "DVB-ASI Output";
-      }
-      enum "plc" {
-        value 174;
-        description
-          "Power Line Communtications";
-      }
-      enum "nfas" {
-        value 175;
-        description
-          "Non Facility Associated Signaling";
-      }
-      enum "tr008" {
-        value 176;
-        description
-          "TR008";
-      }
-      enum "gr303RDT" {
-        value 177;
-        description
-          "Remote Digital Terminal";
-      }
-      enum "gr303IDT" {
-        value 178;
-        description
-          "Integrated Digital Terminal";
-      }
-      enum "isup" {
-        value 179;
-        description
-          "ISUP";
-      }
-      enum "propDocsWirelessMaclayer" {
-        value 180;
-        description
-          "Cisco proprietary Maclayer";
-      }
-      enum "propDocsWirelessDownstream" {
-        value 181;
-        description
-          "Cisco proprietary Downstream";
-      }
-      enum "propDocsWirelessUpstream" {
-        value 182;
-        description
-          "Cisco proprietary Upstream";
-      }
-      enum "hiperlan2" {
-        value 183;
-        description
-          "HIPERLAN Type 2 Radio Interface";
-      }
-      enum "propBWAp2Mp" {
-        value 184;
-        description
-          "PropBroadbandWirelessAccesspt2multipt use of this value
-           for IEEE 802.16 WMAN interfaces as per IEEE Std 802.16f
-           is deprecated and ieee80216WMAN(237) should be used
-           instead.";
-      }
-      enum "sonetOverheadChannel" {
-        value 185;
-        description
-          "SONET Overhead Channel";
-      }
-      enum "digitalWrapperOverheadChannel" {
-        value 186;
-        description
-          "Digital Wrapper";
-      }
-      enum "aal2" {
-        value 187;
-        description
-          "ATM adaptation layer 2";
-      }
-      enum "radioMAC" {
-        value 188;
-        description
-          "MAC layer over radio links";
-      }
-      enum "atmRadio" {
-        value 189;
-        description
-          "ATM over radio links";
-      }
-      enum "imt" {
-        value 190;
-        description
-          "Inter Machine Trunks";
-      }
-      enum "mvl" {
-        value 191;
-        description
-          "Multiple Virtual Lines DSL";
-      }
-      enum "reachDSL" {
-        value 192;
-        description
-          "Long Reach DSL";
-      }
-      enum "frDlciEndPt" {
-        value 193;
-        description
-          "Frame Relay DLCI End Point";
-      }
-      enum "atmVciEndPt" {
-        value 194;
-        description
-          "ATM VCI End Point";
-      }
-      enum "opticalChannel" {
-        value 195;
-        description
-          "Optical Channel";
-      }
-      enum "opticalTransport" {
-        value 196;
-        description
-          "Optical Transport";
-      }
-      enum "propAtm" {
-        value 197;
-        description
-          "Proprietary ATM";
-      }
-      enum "voiceOverCable" {
-        value 198;
-        description
-          "Voice Over Cable Interface";
-      }
-      enum "infiniband" {
-        value 199;
-        description
-          "Infiniband";
-      }
-      enum "teLink" {
-        value 200;
-        description
-          "TE Link";
-      }
-      enum "q2931" {
-        value 201;
-        description
-          "Q.2931";
-      }
-      enum "virtualTg" {
-        value 202;
-        description
-          "Virtual Trunk Group";
-      }
-      enum "sipTg" {
-        value 203;
-        description
-          "SIP Trunk Group";
-      }
-      enum "sipSig" {
-        value 204;
-        description
-          "SIP Signaling";
-      }
-      enum "docsCableUpstreamChannel" {
-        value 205;
-        description
-          "CATV Upstream Channel";
-      }
-      enum "econet" {
-        value 206;
-        description
-          "Acorn Econet";
-      }
-      enum "pon155" {
-        value 207;
-        description
-          "FSAN 155Mb Symetrical PON interface";
-      }
-      enum "pon622" {
-        value 208;
-        description
-          "FSAN622Mb Symetrical PON interface";
-      }
-      enum "bridge" {
-        value 209;
-        description
-          "Transparent bridge interface";
-      }
-      enum "linegroup" {
-        value 210;
-        description
-          "Interface common to multiple lines";
-      }
-      enum "voiceEMFGD" {
-        value 211;
-        description
-          "voice E&M Feature Group D";
-      }
-      enum "voiceFGDEANA" {
-        value 212;
-        description
-          "voice FGD Exchange Access North American";
-      }
-      enum "voiceDID" {
-        value 213;
-        description
-          "voice Direct Inward Dialing";
-      }
-      enum "mpegTransport" {
-        value 214;
-        description
-          "MPEG transport interface";
-      }
-      enum "sixToFour" {
-        value 215;
-        status deprecated;
-        description
-          "6to4 interface (DEPRECATED)";
-        reference
-          "RFC 4087 - IP Tunnel MIB";
-      }
-      enum "gtp" {
-        value 216;
-        description
-          "GTP (GPRS Tunneling Protocol)";
-      }
-      enum "pdnEtherLoop1" {
-        value 217;
-        description
-          "Paradyne EtherLoop 1";
-      }
-      enum "pdnEtherLoop2" {
-        value 218;
-        description
-          "Paradyne EtherLoop 2";
-      }
-      enum "opticalChannelGroup" {
-        value 219;
-        description
-          "Optical Channel Group";
-      }
-      enum "homepna" {
-        value 220;
-        description
-          "HomePNA ITU-T G.989";
-      }
-      enum "gfp" {
-        value 221;
-        description
-          "Generic Framing Procedure (GFP)";
-      }
-      enum "ciscoISLvlan" {
-        value 222;
-        description
-          "Layer 2 Virtual LAN using Cisco ISL";
-      }
-      enum "actelisMetaLOOP" {
-        value 223;
-        description
-          "Acteleis proprietary MetaLOOP High Speed Link";
-      }
-      enum "fcipLink" {
-        value 224;
-        description
-          "FCIP Link";
-      }
-      enum "rpr" {
-        value 225;
-        description
-          "Resilient Packet Ring Interface Type";
-      }
-      enum "qam" {
-        value 226;
-        description
-          "RF Qam Interface";
-      }
-      enum "lmp" {
-        value 227;
-        description
-          "Link Management Protocol";
-        reference
-          "RFC 4327 - Link Management Protocol (LMP) Management
-                      Information Base (MIB)";
-      }
-      enum "cblVectaStar" {
-        value 228;
-        description
-          "Cambridge Broadband Networks Limited VectaStar";
-      }
-      enum "docsCableMCmtsDownstream" {
-        value 229;
-        description
-          "CATV Modular CMTS Downstream Interface";
-      }
-      enum "adsl2" {
-        value 230;
-        status deprecated;
-        description
-          "Asymmetric Digital Subscriber Loop Version 2
-           (DEPRECATED/OBSOLETED - please use adsl2plus(238)
-           instead)";
-        reference
-          "RFC 4706 - Definitions of Managed Objects for Asymmetric
-                      Digital Subscriber Line 2 (ADSL2)";
-      }
-      enum "macSecControlledIF" {
-        value 231;
-        description
-          "MACSecControlled";
-      }
-      enum "macSecUncontrolledIF" {
-        value 232;
-        description
-          "MACSecUncontrolled";
-      }
-      enum "aviciOpticalEther" {
-        value 233;
-        description
-         "Avici Optical Ethernet Aggregate";
-      }
-      enum "atmbond" {
-        value 234;
-        description
-          "atmbond";
-      }
-      enum "voiceFGDOS" {
-        value 235;
-        description
-          "voice FGD Operator Services";
-      }
-      enum "mocaVersion1" {
-        value 236;
-        description
-          "MultiMedia over Coax Alliance (MoCA) Interface
-           as documented in information provided privately to IANA";
-      }
-      enum "ieee80216WMAN" {
-        value 237;
-        description
-          "IEEE 802.16 WMAN interface";
-      }
-      enum "adsl2plus" {
-        value 238;
-        description
-          "Asymmetric Digital Subscriber Loop Version 2,
-           Version 2 Plus and all variants";
-      }
-      enum "dvbRcsMacLayer" {
-        value 239;
-        description
-          "DVB-RCS MAC Layer";
-        reference
-          "RFC 5728 - The SatLabs Group DVB-RCS MIB";
-      }
-      enum "dvbTdm" {
-        value 240;
-        description
-          "DVB Satellite TDM";
-        reference
-          "RFC 5728 - The SatLabs Group DVB-RCS MIB";
-      }
-      enum "dvbRcsTdma" {
-        value 241;
-        description
-          "DVB-RCS TDMA";
-        reference
-          "RFC 5728 - The SatLabs Group DVB-RCS MIB";
-      }
-      enum "x86Laps" {
-        value 242;
-        description
-          "LAPS based on ITU-T X.86/Y.1323";
-      }
-      enum "wwanPP" {
-        value 243;
-        description
-          "3GPP WWAN";
-      }
-      enum "wwanPP2" {
-        value 244;
-        description
-          "3GPP2 WWAN";
-      }
-      enum "voiceEBS" {
-        value 245;
-        description
-          "voice P-phone EBS physical interface";
-      }
-      enum "ifPwType" {
-        value 246;
-        description
-          "Pseudowire interface type";
-        reference
-          "RFC 5601 - Pseudowire (PW) Management Information Base";
-      }
-      enum "ilan" {
-        value 247;
-        description
-          "Internal LAN on a bridge per IEEE 802.1ap";
-      }
-      enum "pip" {
-        value 248;
-        description
-          "Provider Instance Port on a bridge per IEEE 802.1ah PBB";
-      }
-      enum "aluELP" {
-        value 249;
-        description
-          "Alcatel-Lucent Ethernet Link Protection";
-      }
-      enum "gpon" {
-        value 250;
-        description
-          "Gigabit-capable passive optical networks (G-PON) as per
-           ITU-T G.948";
-      }
-      enum "vdsl2" {
-        value 251;
-        description
-          "Very high speed digital subscriber line Version 2
-           (as per ITU-T Recommendation G.993.2)";
-        reference
-          "RFC 5650 - Definitions of Managed Objects for Very High
-                      Speed Digital Subscriber Line 2 (VDSL2)";
-      }
-      enum "capwapDot11Profile" {
-        value 252;
-        description
-          "WLAN Profile Interface";
-        reference
-          "RFC 5834 - Control and Provisioning of Wireless Access
-                      Points (CAPWAP) Protocol Binding MIB for
-                      IEEE 802.11";
-      }
-      enum "capwapDot11Bss" {
-        value 253;
-        description
-          "WLAN BSS Interface";
-        reference
-          "RFC 5834 - Control and Provisioning of Wireless Access
-                      Points (CAPWAP) Protocol Binding MIB for
-                      IEEE 802.11";
-      }
-      enum "capwapWtpVirtualRadio" {
-        value 254;
-        description
-          "WTP Virtual Radio Interface";
-        reference
-          "RFC 5833 - Control and Provisioning of Wireless Access
-                      Points (CAPWAP) Protocol Base MIB";
-      }
-      enum "bits" {
-        value 255;
-        description
-          "bitsport";
-      }
-      enum "docsCableUpstreamRfPort" {
-        value 256;
-        description
-          "DOCSIS CATV Upstream RF Port";
-      }
-      enum "cableDownstreamRfPort" {
-        value 257;
-        description
-          "CATV downstream RF port";
-      }
-      enum "vmwareVirtualNic" {
-        value 258;
-        description
-          "VMware Virtual Network Interface";
-      }
-      enum "ieee802154" {
-        value 259;
-        description
-          "IEEE 802.15.4 WPAN interface";
-        reference
-          "IEEE 802.15.4-2006";
-      }
-      enum "otnOdu" {
-        value 260;
-        description
-          "OTN Optical Data Unit";
-      }
-      enum "otnOtu" {
-        value 261;
-        description
-          "OTN Optical channel Transport Unit";
-      }
-      enum "ifVfiType" {
-        value 262;
-        description
-          "VPLS Forwarding Instance Interface Type";
-      }
-      enum "g9981" {
-        value 263;
-        description
-          "G.998.1 bonded interface";
-      }
-      enum "g9982" {
-        value 264;
-        description
-          "G.998.2 bonded interface";
-      }
-      enum "g9983" {
-        value 265;
-        description
-          "G.998.3 bonded interface";
-      }
-      enum "aluEpon" {
-        value 266;
-        description
-          "Ethernet Passive Optical Networks (E-PON)";
-      }
-      enum "aluEponOnu" {
-        value 267;
-        description
-          "EPON Optical Network Unit";
-      }
-      enum "aluEponPhysicalUni" {
-        value 268;
-        description
-          "EPON physical User to Network interface";
-      }
-      enum "aluEponLogicalLink" {
-        value 269;
-        description
-          "The emulation of a point-to-point link over the EPON
-           layer";
-      }
-      enum "aluGponOnu" {
-        value 270;
-        description
-          "GPON Optical Network Unit";
-        reference
-          "ITU-T G.984.2";
-      }
-      enum "aluGponPhysicalUni" {
-        value 271;
-        description
-          "GPON physical User to Network interface";
-        reference
-          "ITU-T G.984.2";
-      }
-      enum "vmwareNicTeam" {
-        value 272;
-        description
-          "VMware NIC Team";
-      }
-    }
-    description
-      "This data type is used as the syntax of the 'type'
-       leaf in the 'interface' list in the YANG module
-       ietf-interface.
-
-       The definition of this typedef with the
-       addition of newly assigned values is published
-       periodically by the IANA, in either the Assigned
-       Numbers RFC, or some derivative of it specific to
-       Internet Network Management number assignments.  (The
-       latest arrangements can be obtained by contacting the
-       IANA.)
-
-       Requests for new values should be made to IANA via
-       email (iana&iana.org).";
-    reference
-      "ifType definitions registry.
-       <http://www.iana.org/assignments/smi-numbers>";
-  }
-}
\ No newline at end of file
diff --git a/code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/ietf-inet-types@2010-09-24.yang b/code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/ietf-inet-types@2010-09-24.yang
deleted file mode 100644 (file)
index de20feb..0000000
+++ /dev/null
@@ -1,418 +0,0 @@
- module ietf-inet-types {
-
-   namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types";
-   prefix "inet";
-
-   organization
-    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
-   contact
-    "WG Web:   <http://tools.ietf.org/wg/netmod/>
-     WG List:  <mailto:netmod@ietf.org>
-
-     WG Chair: David Partain
-               <mailto:david.partain@ericsson.com>
-
-     WG Chair: David Kessens
-               <mailto:david.kessens@nsn.com>
-
-     Editor:   Juergen Schoenwaelder
-               <mailto:j.schoenwaelder@jacobs-university.de>";
-
-   description
-    "This module contains a collection of generally useful derived
-     YANG data types for Internet addresses and related things.
-
-     Copyright (c) 2010 IETF Trust and the persons identified as
-     authors of the code.  All rights reserved.
-
-     Redistribution and use in source and binary forms, with or without
-     modification, is permitted pursuant to, and subject to the license
-     terms contained in, the Simplified BSD License set forth in Section
-     4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
-     (http://trustee.ietf.org/license-info).
-
-     This version of this YANG module is part of RFC 6021; see
-     the RFC itself for full legal notices.";
-
-   revision 2010-09-24 {
-     description
-      "Initial revision.";
-     reference
-      "RFC 6021: Common YANG Data Types";
-   }
-
-   /*** collection of protocol field related types ***/
-
-   typedef ip-version {
-     type enumeration {
-       enum unknown {
-         value "0";
-         description
-          "An unknown or unspecified version of the Internet protocol.";
-       }
-       enum ipv4 {
-         value "1";
-         description
-          "The IPv4 protocol as defined in RFC 791.";
-       }
-       enum ipv6 {
-         value "2";
-         description
-          "The IPv6 protocol as defined in RFC 2460.";
-       }
-     }
-     description
-      "This value represents the version of the IP protocol.
-
-       In the value set and its semantics, this type is equivalent
-       to the InetVersion textual convention of the SMIv2.";
-     reference
-      "RFC  791: Internet Protocol
-       RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
-       RFC 4001: Textual Conventions for Internet Network Addresses";
-   }
-
-   typedef dscp {
-     type uint8 {
-       range "0..63";
-     }
-     description
-      "The dscp type represents a Differentiated Services Code-Point
-       that may be used for marking packets in a traffic stream.
-
-       In the value set and its semantics, this type is equivalent
-       to the Dscp textual convention of the SMIv2.";
-     reference
-      "RFC 3289: Management Information Base for the Differentiated
-                 Services Architecture
-       RFC 2474: Definition of the Differentiated Services Field
-                 (DS Field) in the IPv4 and IPv6 Headers
-       RFC 2780: IANA Allocation Guidelines For Values In
-                 the Internet Protocol and Related Headers";
-   }
-
-   typedef ipv6-flow-label {
-     type uint32 {
-       range "0..1048575";
-     }
-     description
-      "The flow-label type represents flow identifier or Flow Label
-       in an IPv6 packet header that may be used to discriminate
-       traffic flows.
-
-       In the value set and its semantics, this type is equivalent
-       to the IPv6FlowLabel textual convention of the SMIv2.";
-     reference
-      "RFC 3595: Textual Conventions for IPv6 Flow Label
-       RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
-   }
-
-   typedef port-number {
-     type uint16 {
-       range "0..65535";
-     }
-     description
-      "The port-number type represents a 16-bit port number of an
-       Internet transport layer protocol such as UDP, TCP, DCCP, or
-       SCTP.  Port numbers are assigned by IANA.  A current list of
-       all assignments is available from <http://www.iana.org/>.
-
-       Note that the port number value zero is reserved by IANA.  In
-       situations where the value zero does not make sense, it can
-       be excluded by subtyping the port-number type.
-
-       In the value set and its semantics, this type is equivalent
-       to the InetPortNumber textual convention of the SMIv2.";
-     reference
-      "RFC  768: User Datagram Protocol
-       RFC  793: Transmission Control Protocol
-       RFC 4960: Stream Control Transmission Protocol
-       RFC 4340: Datagram Congestion Control Protocol (DCCP)
-       RFC 4001: Textual Conventions for Internet Network Addresses";
-   }
-
-   /*** collection of autonomous system related types ***/
-
-   typedef as-number {
-     type uint32;
-     description
-      "The as-number type represents autonomous system numbers
-       which identify an Autonomous System (AS).  An AS is a set
-       of routers under a single technical administration, using
-       an interior gateway protocol and common metrics to route
-       packets within the AS, and using an exterior gateway
-       protocol to route packets to other ASs'.  IANA maintains
-       the AS number space and has delegated large parts to the
-       regional registries.
-
-       Autonomous system numbers were originally limited to 16
-       bits.  BGP extensions have enlarged the autonomous system
-       number space to 32 bits.  This type therefore uses an uint32
-       base type without a range restriction in order to support
-       a larger autonomous system number space.
-
-       In the value set and its semantics, this type is equivalent
-       to the InetAutonomousSystemNumber textual convention of
-       the SMIv2.";
-     reference
-      "RFC 1930: Guidelines for creation, selection, and registration
-                 of an Autonomous System (AS)
-       RFC 4271: A Border Gateway Protocol 4 (BGP-4)
-       RFC 4893: BGP Support for Four-octet AS Number Space
-       RFC 4001: Textual Conventions for Internet Network Addresses";
-   }
-
-   /*** collection of IP address and hostname related types ***/
-
-   typedef ip-address {
-     type union {
-       type inet:ipv4-address;
-       type inet:ipv6-address;
-     }
-     description
-      "The ip-address type represents an IP address and is IP
-       version neutral.  The format of the textual representations
-       implies the IP version.";
-   }
-
-   typedef ipv4-address {
-     type string {
-       pattern
-         '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
-       +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
-       + '(%[\p{N}\p{L}]+)?';
-     }
-     description
-       "The ipv4-address type represents an IPv4 address in
-        dotted-quad notation.  The IPv4 address may include a zone
-        index, separated by a % sign.
-
-        The zone index is used to disambiguate identical address
-        values.  For link-local addresses, the zone index will
-        typically be the interface index number or the name of an
-        interface.  If the zone index is not present, the default
-        zone of the device will be used.
-
-        The canonical format for the zone index is the numerical
-        format";
-   }
-
-   typedef ipv6-address {
-     type string {
-       pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
-             + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
-             + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
-             + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
-             + '(%[\p{N}\p{L}]+)?';
-       pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
-             + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
-             + '(%.+)?';
-     }
-     description
-      "The ipv6-address type represents an IPv6 address in full,
-       mixed, shortened, and shortened-mixed notation.  The IPv6
-       address may include a zone index, separated by a % sign.
-
-       The zone index is used to disambiguate identical address
-       values.  For link-local addresses, the zone index will
-       typically be the interface index number or the name of an
-       interface.  If the zone index is not present, the default
-       zone of the device will be used.
-
-       The canonical format of IPv6 addresses uses the compressed
-       format described in RFC 4291, Section 2.2, item 2 with the
-       following additional rules: the :: substitution must be
-       applied to the longest sequence of all-zero 16-bit chunks
-       in an IPv6 address.  If there is a tie, the first sequence
-       of all-zero 16-bit chunks is replaced by ::.  Single
-       all-zero 16-bit chunks are not compressed.  The canonical
-       format uses lowercase characters and leading zeros are
-       not allowed.  The canonical format for the zone index is
-       the numerical format as described in RFC 4007, Section
-       11.2.";
-     reference
-      "RFC 4291: IP Version 6 Addressing Architecture
-       RFC 4007: IPv6 Scoped Address Architecture
-       RFC 5952: A Recommendation for IPv6 Address Text Representation";
-   }
-
-   typedef ip-prefix {
-     type union {
-       type inet:ipv4-prefix;
-       type inet:ipv6-prefix;
-     }
-     description
-      "The ip-prefix type represents an IP prefix and is IP
-       version neutral.  The format of the textual representations
-       implies the IP version.";
-   }
-
-   typedef ipv4-prefix {
-     type string {
-       pattern
-          '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
-        +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
-        + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
-     }
-     description
-      "The ipv4-prefix type represents an IPv4 address prefix.
-       The prefix length is given by the number following the
-       slash character and must be less than or equal to 32.
-
-       A prefix length value of n corresponds to an IP address
-       mask that has n contiguous 1-bits from the most
-       significant bit (MSB) and all other bits set to 0.
-
-       The canonical format of an IPv4 prefix has all bits of
-       the IPv4 address set to zero that are not part of the
-       IPv4 prefix.";
-   }
-
-   typedef ipv6-prefix {
-     type string {
-       pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
-             + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
-             + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
-             + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
-             + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
-       pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
-             + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
-             + '(/.+)';
-     }
-     description
-      "The ipv6-prefix type represents an IPv6 address prefix.
-       The prefix length is given by the number following the
-       slash character and must be less than or equal 128.
-
-       A prefix length value of n corresponds to an IP address
-       mask that has n contiguous 1-bits from the most
-       significant bit (MSB) and all other bits set to 0.
-
-       The IPv6 address should have all bits that do not belong
-       to the prefix set to zero.
-
-       The canonical format of an IPv6 prefix has all bits of
-       the IPv6 address set to zero that are not part of the
-       IPv6 prefix.  Furthermore, IPv6 address is represented
-       in the compressed format described in RFC 4291, Section
-       2.2, item 2 with the following additional rules: the ::
-       substitution must be applied to the longest sequence of
-       all-zero 16-bit chunks in an IPv6 address.  If there is
-       a tie, the first sequence of all-zero 16-bit chunks is
-       replaced by ::.  Single all-zero 16-bit chunks are not
-       compressed.  The canonical format uses lowercase
-       characters and leading zeros are not allowed.";
-     reference
-      "RFC 4291: IP Version 6 Addressing Architecture";
-   }
-
-   /*** collection of domain name and URI types ***/
-
-   typedef domain-name {
-     type string {
-       pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*'
-            +  '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)'
-            +  '|\.';
-       length "1..253";
-     }
-     description
-      "The domain-name type represents a DNS domain name.  The
-       name SHOULD be fully qualified whenever possible.
-
-       Internet domain names are only loosely specified.  Section
-       3.5 of RFC 1034 recommends a syntax (modified in Section
-       2.1 of RFC 1123).  The pattern above is intended to allow
-       for current practice in domain name use, and some possible
-       future expansion.  It is designed to hold various types of
-       domain names, including names used for A or AAAA records
-       (host names) and other records, such as SRV records.  Note
-       that Internet host names have a stricter syntax (described
-       in RFC 952) than the DNS recommendations in RFCs 1034 and
-       1123, and that systems that want to store host names in
-       schema nodes using the domain-name type are recommended to
-       adhere to this stricter standard to ensure interoperability.
-
-       The encoding of DNS names in the DNS protocol is limited
-       to 255 characters.  Since the encoding consists of labels
-       prefixed by a length bytes and there is a trailing NULL
-       byte, only 253 characters can appear in the textual dotted
-       notation.
-
-       The description clause of schema nodes using the domain-name
-       type MUST describe when and how these names are resolved to
-       IP addresses.  Note that the resolution of a domain-name value
-       may require to query multiple DNS records (e.g., A for IPv4
-       and AAAA for IPv6).  The order of the resolution process and
-       which DNS record takes precedence can either be defined
-       explicitely or it may depend on the configuration of the
-       resolver.
-
-       Domain-name values use the US-ASCII encoding.  Their canonical
-       format uses lowercase US-ASCII characters.  Internationalized
-       domain names MUST be encoded in punycode as described in RFC
-       3492";
-     reference
-      "RFC  952: DoD Internet Host Table Specification
-       RFC 1034: Domain Names - Concepts and Facilities
-       RFC 1123: Requirements for Internet Hosts -- Application
-                 and Support
-       RFC 2782: A DNS RR for specifying the location of services
-                 (DNS SRV)
-       RFC 3492: Punycode: A Bootstring encoding of Unicode for
-                 Internationalized Domain Names in Applications
-                 (IDNA)
-       RFC 5891: Internationalizing Domain Names in Applications
-                 (IDNA): Protocol";
-   }
-
-   typedef host {
-     type union {
-       type inet:ip-address;
-       type inet:domain-name;
-     }
-     description
-      "The host type represents either an IP address or a DNS
-       domain name.";
-   }
-
-   typedef uri {
-     type string;
-     description
-      "The uri type represents a Uniform Resource Identifier
-       (URI) as defined by STD 66.
-
-       Objects using the uri type MUST be in US-ASCII encoding,
-       and MUST be normalized as described by RFC 3986 Sections
-       6.2.1, 6.2.2.1, and 6.2.2.2.  All unnecessary
-       percent-encoding is removed, and all case-insensitive
-       characters are set to lowercase except for hexadecimal
-       digits, which are normalized to uppercase as described in
-       Section 6.2.2.1.
-
-       The purpose of this normalization is to help provide
-       unique URIs.  Note that this normalization is not
-       sufficient to provide uniqueness.  Two URIs that are
-       textually distinct after this normalization may still be
-       equivalent.
-
-       Objects using the uri type may restrict the schemes that
-       they permit.  For example, 'data:' and 'urn:' schemes
-       might not be appropriate.
-
-       A zero-length URI is not a valid URI.  This can be used to
-       express 'URI absent' where required.
-
-       In the value set and its semantics, this type is equivalent
-       to the Uri SMIv2 textual convention defined in RFC 5017.";
-     reference
-      "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
-       RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
-                 Group: Uniform Resource Identifiers (URIs), URLs,
-                 and Uniform Resource Names (URNs): Clarifications
-                 and Recommendations
-       RFC 5017: MIB Textual Conventions for Uniform Resource
-                 Identifiers (URIs)";
-   }
-
- }
index b9117d03ab5b79074fce65e100d238b9c1e9015d..4518e0e58f5ddf7908967a17ce623c5715f70be5 100644 (file)
@@ -3,563 +3,31 @@ module ietf-interfaces {
   namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
   prefix if;
 
-  import ietf-yang-types {
-    prefix yang;
-  }
-  import iana-if-type {
-    prefix ianaift;
-  }
-
-  organization
-    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
-  contact
-    "WG Web:   <http://tools.ietf.org/wg/netmod/>
-     WG List:  <mailto:netmod@ietf.org>
-
-     WG Chair: David Kessens
-               <mailto:david.kessens@nsn.com>
-
-     WG Chair: Juergen Schoenwaelder
-               <mailto:j.schoenwaelder@jacobs-university.de>
-
-     Editor:   Martin Bjorklund
-               <mailto:mbj@tail-f.com>";
-
-  description
-    "This module contains a collection of YANG definitions for
-     managing network interfaces.
-
-     Copyright (c) 2012 IETF Trust and the persons identified as
-     authors of the code.  All rights reserved.
-
-     Redistribution and use in source and binary forms, with or
-     without modification, is permitted pursuant to, and subject
-     to the license terms contained in, the Simplified BSD License
-     set forth in Section 4.c of the IETF Trust's Legal Provisions
-     Relating to IETF Documents
-     (http://trustee.ietf.org/license-info).
-
-     This version of this YANG module is part of RFC XXXX; see
-     the RFC itself for full legal notices.";
-
-  // RFC Ed.: replace XXXX with actual RFC number and remove this
-  // note.
-
-  // RFC Ed.: update the date below with the date of RFC publication
-  // and remove this note.
   revision 2012-11-15 {
-    description
-      "Initial revision.";
-    reference
-      "RFC XXXX: A YANG Data Model for Interface Management";
   }
 
-  /* Typedefs */
-
   typedef interface-ref {
     type leafref {
       path "/if:interfaces/if:interface/if:name";
     }
-    description
-      "This type is used by data models that need to reference
-       interfaces.";
-  }
-
-  /* Features */
-
-  feature arbitrary-names {
-    description
-      "This feature indicates that the server allows interfaces to
-       be named arbitrarily.";
   }
 
-  feature if-mib {
-    description
-      "This feature indicates that the server implements IF-MIB.";
-    reference
-      "RFC 2863: The Interfaces Group MIB";
-  }
-
-  /* Data nodes */
 
   container interfaces {
-    description
-      "Interface parameters.";
 
     list interface {
       key "name";
       unique "type location";
 
-      description
-        "The list of interfaces on the device.";
-
       leaf name {
         type string;
-        description
-          "The name of the interface.
-
-           A device MAY restrict the allowed values for this leaf,
-           possibly depending on the type and location.
-
-           If the device allows arbitrarily named interfaces, the
-           feature 'arbitrary-names' is advertised.
-
-           This leaf MAY be mapped to ifName by an implementation.
-           Such an implementation MAY restrict the allowed values for
-           this leaf so that it matches the restrictions of ifName.
-           If a NETCONF server that implements this restriction is
-           sent a value that doesn't match the restriction, it MUST
-           reply with an rpc-error with the error-tag
-           'invalid-value'.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifName";
-      }
-
-      leaf description {
-        type string;
-        description
-          "A textual description of the interface.
-
-           This leaf MAY be mapped to ifAlias by an implementation.
-           Such an implementation MAY restrict the allowed values for
-           this leaf so that it matches the restrictions of ifAlias.
-           If a NETCONF server that implements this restriction is
-           sent a value that doesn't match the restriction, it MUST
-           reply with an rpc-error with the error-tag
-           'invalid-value'.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifAlias";
-      }
-
-      leaf type {
-        type ianaift:iana-if-type;
-        mandatory true;
-        description
-          "The type of the interface.
-
-           When an interface entry is created, a server MAY
-           initialize the type leaf with a valid value, e.g., if it
-           is possible to derive the type from the name of the
-           interface.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifType";
-      }
-
-      leaf location {
-        type string;
-        description
-          "The device-specific location of the interface of a
-           particular type.  The format of the location string
-           depends on the interface type and the device.
-
-           If the interface's type represents a physical interface,
-           this leaf MUST be set.
-
-           When an interface entry is created, a server MAY
-           initialize the location leaf with a valid value, e.g., if
-           it is possible to derive the location from the name of
-           the interface.";
-      }
-
-      leaf enabled {
-        type boolean;
-        default "true";
-        description
-          "The desired state of the interface.
-
-           This leaf contains the configured, desired state of the
-           interface.  Systems that implement the IF-MIB use the
-           value of this leaf to set IF-MIB.ifAdminStatus to 'up' or
-           'down' after an ifEntry has been initialized, as described
-           in RFC 2863.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifAdminStatus";
-      }
-
-      leaf oper-status {
-        type enumeration {
-          enum up {
-            value 1;
-            description
-              "Ready to pass packets.";
-          }
-          enum down {
-            value 2;
-            description
-              "The interface does not pass any packets.";
-          }
-          enum testing {
-            value 3;
-            description
-              "In some test mode.  No operational packets can
-               be passed.";
-          }
-          enum unknown {
-            value 4;
-            description
-              "Status cannot be determined for some reason.";
-          }
-          enum dormant {
-            value 5;
-            description
-              "Waiting for some external event.";
-          }
-          enum not-present {
-            value 6;
-            description
-              "Some component is missing.";
-          }
-          enum lower-layer-down {
-            value 7;
-            description
-              "Down due to state of lower-layer interface(s).";
-          }
-        }
-        config false;
-        description
-          "The current operational state of the interface.
-
-           If 'enabled' is 'false' then 'oper-status'
-           should be 'down'.  If 'enabled' is changed to 'true'
-           then 'oper-status' should change to 'up' if the interface
-           is ready to transmit and receive network traffic; it
-           should change to 'dormant' if the interface is waiting for
-           external actions (such as a serial line waiting for an
-           incoming connection); it should remain in the 'down' state
-           if and only if there is a fault that prevents it from
-           going to the 'up' state; it should remain in the
-           'not-present' state if the interface has missing
-           (typically, hardware) components.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifOperStatus";
-      }
-
-      leaf last-change {
-        type yang:date-and-time;
-        config false;
-        description
-          "The time the interface entered its current operational
-           state.  If the current state was entered prior to the
-           last re-initialization of the local network management
-           subsystem, then this node is not present.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifLastChange";
-      }
-
-      leaf if-index {
-        if-feature if-mib;
-        type int32 {
-          range "1..2147483647";
-        }
-        config false;
-        description
-          "The ifIndex value for the ifEntry represented by this
-           interface.
-
-           Media-specific modules must specify how the type is
-           mapped to entries in the ifTable.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifIndex";
-      }
-
-      leaf link-up-down-trap-enable {
-        if-feature if-mib;
-        type enumeration {
-          enum enabled {
-            value 1;
-          }
-          enum disabled {
-            value 2;
-          }
-        }
-        description
-          "Indicates whether linkUp/linkDown SNMP notifications
-           should be generated for this interface.
-           If this node is not configured, the value 'enabled' is
-           operationally used by the server for interfaces which do
-           not operate on top of any other interface (i.e., there are
-           no 'lower-layer-if' entries), and 'disabled' otherwise.";
-        reference
-          "RFC 2863: The Interfaces Group MIB -
-                     ifLinkUpDownTrapEnable";
-      }
-
-      leaf phys-address {
-        type yang:phys-address;
-        config false;
-        description
-          "The interface's address at its protocol sub-layer.  For
-          example, for an 802.x interface, this object normally
-          contains a MAC address.  The interface's media-specific
-          modules must define the bit and byte ordering and the
-          format of the value of this object.  For interfaces that do
-          not have such an address (e.g., a serial line), this node
-          is not present.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifPhysAddress";
       }
 
       leaf-list higher-layer-if {
         type interface-ref;
         config false;
-        description
-          "A list of references to interfaces layered on top of this
-           interface.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifStackTable";
-      }
-
-      leaf-list lower-layer-if {
-        type interface-ref;
-        config false;
-        description
-          "A list of references to interfaces layered underneath this
-           interface.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifStackTable";
       }
 
-      leaf speed {
-        type yang:gauge64;
-        units "bits / second";
-        config false;
-        description
-            "An estimate of the interface's current bandwidth in bits
-             per second.  For interfaces which do not vary in
-             bandwidth or for those where no accurate estimation can
-             be made, this node should contain the nominal bandwidth.
-             For interfaces that has no concept of bandwidth, this
-             node is not present.";
-        reference
-          "RFC 2863: The Interfaces Group MIB -
-                     ifSpeed, ifHighSpeed";
-      }
-
-      container statistics {
-        config false;
-        description
-          "A collection of interface-related statistics objects.";
-
-        leaf discontinuity-time {
-          type yang:date-and-time;
-          description
-            "The time on the most recent occasion at which any one or
-             more of this interface's counters suffered a
-             discontinuity.  If no such discontinuities have occurred
-             since the last re-initialization of the local management
-             subsystem, then this node contains the time the local
-             management subsystem re-initialized itself.";
-        }
-
-        leaf in-octets {
-          type yang:counter64;
-          description
-            "The total number of octets received on the interface,
-             including framing characters.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifHCInOctets";
-        }
-        leaf in-unicast-pkts {
-          type yang:counter64;
-          description
-            "The number of packets, delivered by this sub-layer to a
-             higher (sub-)layer, which were not addressed to a
-             multicast or broadcast address at this sub-layer.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts";
-        }
-        leaf in-broadcast-pkts {
-          type yang:counter64;
-          description
-            "The number of packets, delivered by this sub-layer to a
-             higher (sub-)layer, which were addressed to a broadcast
-             address at this sub-layer.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB -
-                       ifHCInBroadcastPkts";
-        }
-        leaf in-multicast-pkts {
-          type yang:counter64;
-          description
-            "The number of packets, delivered by this sub-layer to a
-             higher (sub-)layer, which were addressed to a multicast
-             address at this sub-layer.  For a MAC layer protocol,
-             this includes both Group and Functional addresses.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB -
-                       ifHCInMulticastPkts";
-        }
-        leaf in-discards {
-          type yang:counter32;
-          description
-            "The number of inbound packets which were chosen to be
-             discarded even though no errors had been detected to
-             prevent their being deliverable to a higher-layer
-             protocol.  One possible reason for discarding such a
-             packet could be to free up buffer space.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifInDiscards";
-        }
-        leaf in-errors {
-          type yang:counter32;
-          description
-            "For packet-oriented interfaces, the number of inbound
-             packets that contained errors preventing them from being
-             deliverable to a higher-layer protocol.  For character-
-             oriented or fixed-length interfaces, the number of
-             inbound transmission units that contained errors
-             preventing them from being deliverable to a higher-layer
-             protocol.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifInErrors";
-        }
-        leaf in-unknown-protos {
-          type yang:counter32;
-          description
-            "For packet-oriented interfaces, the number of packets
-             received via the interface which were discarded because
-             of an unknown or unsupported protocol.  For
-             character-oriented or fixed-length interfaces that
-             support protocol multiplexing the number of transmission
-             units received via the interface which were discarded
-             because of an unknown or unsupported protocol.  For any
-             interface that does not support protocol multiplexing,
-             this counter is not present.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos";
-        }
-
-        leaf out-octets {
-          type yang:counter64;
-          description
-            "The total number of octets transmitted out of the
-             interface, including framing characters.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifHCOutOctets";
-        }
-        leaf out-unicast-pkts {
-          type yang:counter64;
-          description
-            "The total number of packets that higher-level protocols
-             requested be transmitted, and which were not addressed
-             to a multicast or broadcast address at this sub-layer,
-             including those that were discarded or not sent.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts";
-        }
-        leaf out-broadcast-pkts {
-          type yang:counter64;
-          description
-            "The total number of packets that higher-level protocols
-             requested be transmitted, and which were addressed to a
-             broadcast address at this sub-layer, including those
-             that were discarded or not sent.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB -
-                       ifHCOutBroadcastPkts";
-        }
-        leaf out-multicast-pkts {
-          type yang:counter64;
-          description
-            "The total number of packets that higher-level protocols
-             requested be transmitted, and which were addressed to a
-             multicast address at this sub-layer, including those
-             that were discarded or not sent.  For a MAC layer
-             protocol, this includes both Group and Functional
-             addresses.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB -
-                       ifHCOutMulticastPkts";
-        }
-        leaf out-discards {
-          type yang:counter32;
-          description
-            "The number of outbound packets which were chosen to be
-             discarded even though no errors had been detected to
-             prevent their being transmitted.  One possible reason
-             for discarding such a packet could be to free up buffer
-             space.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifOutDiscards";
-        }
-        leaf out-errors {
-          type yang:counter32;
-          description
-            "For packet-oriented interfaces, the number of outbound
-             packets that could not be transmitted because of errors.
-             For character-oriented or fixed-length interfaces, the
-             number of outbound transmission units that could not be
-             transmitted because of errors.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifOutErrors";
-        }
-      }
     }
   }
-}
\ No newline at end of file
+}
diff --git a/code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/ietf-yang-types@2010-09-24.yang b/code-generator/binding-generator-impl/src/test/resources/augment-relative-xpath-models/ietf-yang-types@2010-09-24.yang
deleted file mode 100644 (file)
index e9d88ab..0000000
+++ /dev/null
@@ -1,396 +0,0 @@
- module ietf-yang-types {
-
-   namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
-   prefix "yang";
-
-   organization
-    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
-   contact
-    "WG Web:   <http://tools.ietf.org/wg/netmod/>
-     WG List:  <mailto:netmod@ietf.org>
-
-     WG Chair: David Partain
-               <mailto:david.partain@ericsson.com>
-
-     WG Chair: David Kessens
-               <mailto:david.kessens@nsn.com>
-
-     Editor:   Juergen Schoenwaelder
-               <mailto:j.schoenwaelder@jacobs-university.de>";
-
-   description
-    "This module contains a collection of generally useful derived
-     YANG data types.
-
-     Copyright (c) 2010 IETF Trust and the persons identified as
-     authors of the code.  All rights reserved.
-
-     Redistribution and use in source and binary forms, with or without
-     modification, is permitted pursuant to, and subject to the license
-     terms contained in, the Simplified BSD License set forth in Section
-     4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
-     (http://trustee.ietf.org/license-info).
-
-     This version of this YANG module is part of RFC 6021; see
-     the RFC itself for full legal notices.";
-
-   revision 2010-09-24 {
-     description
-      "Initial revision.";
-     reference
-      "RFC 6021: Common YANG Data Types";
-   }
-
-   /*** collection of counter and gauge types ***/
-
-   typedef counter32 {
-     type uint32;
-     description
-      "The counter32 type represents a non-negative integer
-       that monotonically increases until it reaches a
-       maximum value of 2^32-1 (4294967295 decimal), when it
-       wraps around and starts increasing again from zero.
-
-       Counters have no defined 'initial' value, and thus, a
-       single value of a counter has (in general) no information
-       content.  Discontinuities in the monotonically increasing
-       value normally occur at re-initialization of the
-       management system, and at other times as specified in the
-       description of a schema node using this type.  If such
-       other times can occur, for example, the creation of
-       a schema node of type counter32 at times other than
-       re-initialization, then a corresponding schema node
-       should be defined, with an appropriate type, to indicate
-       the last discontinuity.
-
-       The counter32 type should not be used for configuration
-       schema nodes.  A default statement SHOULD NOT be used in
-       combination with the type counter32.
-
-       In the value set and its semantics, this type is equivalent
-       to the Counter32 type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef zero-based-counter32 {
-     type yang:counter32;
-     default "0";
-     description
-      "The zero-based-counter32 type represents a counter32
-       that has the defined 'initial' value zero.
-
-       A schema node of this type will be set to zero (0) on creation
-       and will thereafter increase monotonically until it reaches
-       a maximum value of 2^32-1 (4294967295 decimal), when it
-       wraps around and starts increasing again from zero.
-
-       Provided that an application discovers a new schema node
-       of this type within the minimum time to wrap, it can use the
-       'initial' value as a delta.  It is important for a management
-       station to be aware of this minimum time and the actual time
-       between polls, and to discard data if the actual time is too
-       long or there is no defined minimum time.
-
-       In the value set and its semantics, this type is equivalent
-       to the ZeroBasedCounter32 textual convention of the SMIv2.";
-     reference
-       "RFC 4502: Remote Network Monitoring Management Information
-                  Base Version 2";
-   }
-
-   typedef counter64 {
-     type uint64;
-     description
-      "The counter64 type represents a non-negative integer
-       that monotonically increases until it reaches a
-       maximum value of 2^64-1 (18446744073709551615 decimal),
-       when it wraps around and starts increasing again from zero.
-
-       Counters have no defined 'initial' value, and thus, a
-       single value of a counter has (in general) no information
-       content.  Discontinuities in the monotonically increasing
-       value normally occur at re-initialization of the
-       management system, and at other times as specified in the
-       description of a schema node using this type.  If such
-       other times can occur, for example, the creation of
-       a schema node of type counter64 at times other than
-       re-initialization, then a corresponding schema node
-       should be defined, with an appropriate type, to indicate
-       the last discontinuity.
-
-       The counter64 type should not be used for configuration
-       schema nodes.  A default statement SHOULD NOT be used in
-       combination with the type counter64.
-
-       In the value set and its semantics, this type is equivalent
-       to the Counter64 type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef zero-based-counter64 {
-     type yang:counter64;
-     default "0";
-     description
-      "The zero-based-counter64 type represents a counter64 that
-       has the defined 'initial' value zero.
-
-       A schema node of this type will be set to zero (0) on creation
-       and will thereafter increase monotonically until it reaches
-       a maximum value of 2^64-1 (18446744073709551615 decimal),
-       when it wraps around and starts increasing again from zero.
-
-       Provided that an application discovers a new schema node
-       of this type within the minimum time to wrap, it can use the
-       'initial' value as a delta.  It is important for a management
-       station to be aware of this minimum time and the actual time
-       between polls, and to discard data if the actual time is too
-       long or there is no defined minimum time.
-
-       In the value set and its semantics, this type is equivalent
-       to the ZeroBasedCounter64 textual convention of the SMIv2.";
-     reference
-      "RFC 2856: Textual Conventions for Additional High Capacity
-                 Data Types";
-   }
-
-   typedef gauge32 {
-     type uint32;
-     description
-      "The gauge32 type represents a non-negative integer, which
-       may increase or decrease, but shall never exceed a maximum
-       value, nor fall below a minimum value.  The maximum value
-       cannot be greater than 2^32-1 (4294967295 decimal), and
-       the minimum value cannot be smaller than 0.  The value of
-       a gauge32 has its maximum value whenever the information
-       being modeled is greater than or equal to its maximum
-       value, and has its minimum value whenever the information
-       being modeled is smaller than or equal to its minimum value.
-       If the information being modeled subsequently decreases
-       below (increases above) the maximum (minimum) value, the
-       gauge32 also decreases (increases).
-
-       In the value set and its semantics, this type is equivalent
-       to the Gauge32 type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef gauge64 {
-     type uint64;
-     description
-      "The gauge64 type represents a non-negative integer, which
-       may increase or decrease, but shall never exceed a maximum
-       value, nor fall below a minimum value.  The maximum value
-       cannot be greater than 2^64-1 (18446744073709551615), and
-       the minimum value cannot be smaller than 0.  The value of
-       a gauge64 has its maximum value whenever the information
-       being modeled is greater than or equal to its maximum
-       value, and has its minimum value whenever the information
-       being modeled is smaller than or equal to its minimum value.
-       If the information being modeled subsequently decreases
-       below (increases above) the maximum (minimum) value, the
-       gauge64 also decreases (increases).
-
-       In the value set and its semantics, this type is equivalent
-       to the CounterBasedGauge64 SMIv2 textual convention defined
-       in RFC 2856";
-     reference
-      "RFC 2856: Textual Conventions for Additional High Capacity
-                 Data Types";
-   }
-
-   /*** collection of identifier related types ***/
-
-   typedef object-identifier {
-     type string {
-       pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))'
-             + '(\.(0|([1-9]\d*)))*';
-     }
-     description
-      "The object-identifier type represents administratively
-       assigned names in a registration-hierarchical-name tree.
-
-       Values of this type are denoted as a sequence of numerical
-       non-negative sub-identifier values.  Each sub-identifier
-       value MUST NOT exceed 2^32-1 (4294967295).  Sub-identifiers
-       are separated by single dots and without any intermediate
-       whitespace.
-
-       The ASN.1 standard restricts the value space of the first
-       sub-identifier to 0, 1, or 2.  Furthermore, the value space
-       of the second sub-identifier is restricted to the range
-       0 to 39 if the first sub-identifier is 0 or 1.  Finally,
-       the ASN.1 standard requires that an object identifier
-       has always at least two sub-identifier.  The pattern
-       captures these restrictions.
-
-       Although the number of sub-identifiers is not limited,
-       module designers should realize that there may be
-       implementations that stick with the SMIv2 limit of 128
-       sub-identifiers.
-
-       This type is a superset of the SMIv2 OBJECT IDENTIFIER type
-       since it is not restricted to 128 sub-identifiers.  Hence,
-       this type SHOULD NOT be used to represent the SMIv2 OBJECT
-       IDENTIFIER type, the object-identifier-128 type SHOULD be
-       used instead.";
-     reference
-      "ISO9834-1: Information technology -- Open Systems
-       Interconnection -- Procedures for the operation of OSI
-       Registration Authorities: General procedures and top
-       arcs of the ASN.1 Object Identifier tree";
-   }
-
-
-
-
-   typedef object-identifier-128 {
-     type object-identifier {
-       pattern '\d*(\.\d*){1,127}';
-     }
-     description
-      "This type represents object-identifiers restricted to 128
-       sub-identifiers.
-
-       In the value set and its semantics, this type is equivalent
-       to the OBJECT IDENTIFIER type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   /*** collection of date and time related types ***/
-
-   typedef date-and-time {
-     type string {
-       pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
-             + '(Z|[\+\-]\d{2}:\d{2})';
-     }
-     description
-      "The date-and-time type is a profile of the ISO 8601
-       standard for representation of dates and times using the
-       Gregorian calendar.  The profile is defined by the
-       date-time production in Section 5.6 of RFC 3339.
-
-       The date-and-time type is compatible with the dateTime XML
-       schema type with the following notable exceptions:
-
-       (a) The date-and-time type does not allow negative years.
-
-       (b) The date-and-time time-offset -00:00 indicates an unknown
-           time zone (see RFC 3339) while -00:00 and +00:00 and Z all
-           represent the same time zone in dateTime.
-
-       (c) The canonical format (see below) of data-and-time values
-           differs from the canonical format used by the dateTime XML
-           schema type, which requires all times to be in UTC using the
-           time-offset 'Z'.
-
-       This type is not equivalent to the DateAndTime textual
-       convention of the SMIv2 since RFC 3339 uses a different
-       separator between full-date and full-time and provides
-       higher resolution of time-secfrac.
-
-       The canonical format for date-and-time values with a known time
-       zone uses a numeric time zone offset that is calculated using
-       the device's configured known offset to UTC time.  A change of
-       the device's offset to UTC time will cause date-and-time values
-       to change accordingly.  Such changes might happen periodically
-       in case a server follows automatically daylight saving time
-       (DST) time zone offset changes.  The canonical format for
-       date-and-time values with an unknown time zone (usually referring
-       to the notion of local time) uses the time-offset -00:00.";
-     reference
-      "RFC 3339: Date and Time on the Internet: Timestamps
-       RFC 2579: Textual Conventions for SMIv2
-       XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
-   }
-
-   typedef timeticks {
-     type uint32;
-     description
-      "The timeticks type represents a non-negative integer that
-       represents the time, modulo 2^32 (4294967296 decimal), in
-       hundredths of a second between two epochs.  When a schema
-       node is defined that uses this type, the description of
-       the schema node identifies both of the reference epochs.
-
-       In the value set and its semantics, this type is equivalent
-       to the TimeTicks type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef timestamp {
-     type yang:timeticks;
-     description
-      "The timestamp type represents the value of an associated
-       timeticks schema node at which a specific occurrence happened.
-       The specific occurrence must be defined in the description
-       of any schema node defined using this type.  When the specific
-       occurrence occurred prior to the last time the associated
-       timeticks attribute was zero, then the timestamp value is
-       zero.  Note that this requires all timestamp values to be
-       reset to zero when the value of the associated timeticks
-       attribute reaches 497+ days and wraps around to zero.
-
-       The associated timeticks schema node must be specified
-       in the description of any schema node using this type.
-
-       In the value set and its semantics, this type is equivalent
-       to the TimeStamp textual convention of the SMIv2.";
-     reference
-      "RFC 2579: Textual Conventions for SMIv2";
-   }
-
-   /*** collection of generic address types ***/
-
-   typedef phys-address {
-     type string {
-       pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
-     }
-     description
-      "Represents media- or physical-level addresses represented
-       as a sequence octets, each octet represented by two hexadecimal
-       numbers.  Octets are separated by colons.  The canonical
-       representation uses lowercase characters.
-
-       In the value set and its semantics, this type is equivalent
-       to the PhysAddress textual convention of the SMIv2.";
-     reference
-      "RFC 2579: Textual Conventions for SMIv2";
-   }
-
-   typedef mac-address {
-     type string {
-       pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
-     }
-     description
-      "The mac-address type represents an IEEE 802 MAC address.
-       The canonical representation uses lowercase characters.
-
-       In the value set and its semantics, this type is equivalent
-       to the MacAddress textual convention of the SMIv2.";
-     reference
-      "IEEE 802: IEEE Standard for Local and Metropolitan Area
-                 Networks: Overview and Architecture
-       RFC 2579: Textual Conventions for SMIv2";
-   }
-
-   /*** collection of XML specific types ***/
-
-   typedef xpath1.0 {
-     type string;
-     description
-      "This type represents an XPATH 1.0 expression.
-
-       When a schema node is defined that uses this type, the
-       description of the schema node MUST specify the XPath
-       context in which the XPath expression is evaluated.";
-     reference
-      "XPATH: XML Path Language (XPath) Version 1.0";
-   }
-
- }
\ No newline at end of file
index d80a3e9fdd1cfd14dfe58c4a1631c692bf170a53..249e1f60d3a785119d529e49443fcfd0026effbf 100644 (file)
@@ -3,20 +3,6 @@ module abstract-topology {
     namespace "urn:model:abstract:topology";
     prefix "tp";
 
-    import ietf-inet-types { 
-        prefix "inet"; 
-        revision-date 2010-09-24;
-    }
-
-    organization "OPEN DAYLIGHT";
-    contact "http://www.opendaylight.org/";
-
-    description
-        "This module contains the definitions of elements that creates network 
-    topology i.e. definition of network nodes and links. This module is not designed 
-    to be used solely for network representation. This module SHOULD be used as base 
-    module in defining the network topology.";
-
     revision "2013-02-08" {
         reference "http://www.opendaylight.org/";
     }
@@ -41,7 +27,7 @@ module abstract-topology {
         topology-id for reason that the store could contain many topologies.";
 
         leaf topology-id {
-            type inet:uri;
+            type string;
             description "It is presumed that datastore will contain many topologies. 
             To distinguish between topologies it is vital to have
             UNIQUE topology identifier.";
@@ -52,7 +38,7 @@ module abstract-topology {
                 key "node-id";
 
                 leaf node-id {
-                    type inet:uri;
+                    type string;
                     description "The Topology identifier of network-node.";
                 }
 
@@ -68,7 +54,7 @@ module abstract-topology {
                 key "link-id";
 
                 leaf link-id {
-                    type inet:uri;
+                    type string;
                     description "";
                 }
 
index 00f3149f10a6b5af7323d8ac2a82294d73cc8890..5d5eee706a2f341a2a47f2b82884a578cd99617f 100644 (file)
@@ -3,11 +3,6 @@ module augment-abstract-topology {
     namespace "urn:model:augment:abstract:topology";
     prefix "atp";
 
-    import ietf-inet-types { 
-        prefix "inet";
-        revision-date 2010-09-24;
-    }
-
     import ietf-interfaces {
         prefix "if";
         revision-date 2012-11-15;
diff --git a/code-generator/binding-generator-impl/src/test/resources/augment-test-models/iana-if-type@2012-06-05.yang b/code-generator/binding-generator-impl/src/test/resources/augment-test-models/iana-if-type@2012-06-05.yang
deleted file mode 100644 (file)
index a7fa137..0000000
+++ /dev/null
@@ -1,1516 +0,0 @@
-module iana-if-type {
-  namespace "urn:ietf:params:xml:ns:yang:iana-if-type";
-  prefix ianaift;
-
-  organization "IANA";
-  contact
-    "        Internet Assigned Numbers Authority
-
-     Postal: ICANN
-             4676 Admiralty Way, Suite 330
-             Marina del Rey, CA 90292
-
-     Tel:    +1 310 823 9358
-     E-Mail: iana&iana.org";
-  description
-    "This YANG module defines the iana-if-type typedef, which
-     contains YANG definitions for IANA-registered interface types.
-
-     This YANG module is maintained by IANA, and reflects the
-     'ifType definitions' registry.
-
-     The latest revision of this YANG module can be obtained from
-     the IANA web site.
-
-     Copyright (c) 2011 IETF Trust and the persons identified as
-     authors of the code.  All rights reserved.
-
-     Redistribution and use in source and binary forms, with or
-     without modification, is permitted pursuant to, and subject
-     to the license terms contained in, the Simplified BSD License
-     set forth in Section 4.c of the IETF Trust's Legal Provisions
-     Relating to IETF Documents
-     (http://trustee.ietf.org/license-info).
-
-     This version of this YANG module is part of RFC XXXX; see
-     the RFC itself for full legal notices.";
-  // RFC Ed.: replace XXXX with actual RFC number and remove this
-  // note.
-
-  // RFC Ed.: update the date below with the date of RFC publication
-  // and remove this note.
-  revision 2012-06-05 {
-    description
-      "Initial revision.";
-    reference
-      "RFC XXXX: TITLE";
-  }
-
-  typedef iana-if-type {
-    type enumeration {
-      enum "other" {
-        value 1;
-        description
-          "None of the following";
-      }
-      enum "regular1822" {
-        value 2;
-      }
-      enum "hdh1822" {
-        value 3;
-      }
-      enum "ddnX25" {
-        value 4;
-      }
-      enum "rfc877x25" {
-        value 5;
-        reference
-          "RFC 1382 - SNMP MIB Extension for the X.25 Packet Layer";
-      }
-      enum "ethernetCsmacd" {
-        value 6;
-        description
-          "For all ethernet-like interfaces, regardless of speed,
-           as per RFC3635.";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "iso88023Csmacd" {
-        value 7;
-        status deprecated;
-        description
-          "Deprecated via RFC3635.
-           Use ethernetCsmacd(6) instead.";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "iso88024TokenBus" {
-        value 8;
-      }
-      enum "iso88025TokenRing" {
-        value 9;
-      }
-      enum "iso88026Man" {
-        value 10;
-      }
-      enum "starLan" {
-        value 11;
-        status deprecated;
-        description
-          "Deprecated via RFC3635.
-           Use ethernetCsmacd(6) instead.";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "proteon10Mbit" {
-        value 12;
-      }
-      enum "proteon80Mbit" {
-        value 13;
-      }
-      enum "hyperchannel" {
-        value 14;
-      }
-      enum "fddi" {
-        value 15;
-        reference
-          "RFC 1512 - FDDI Management Information Base";
-      }
-      enum "lapb" {
-        value 16;
-        reference
-          "RFC 1381 - SNMP MIB Extension for X.25 LAPB";
-      }
-      enum "sdlc" {
-        value 17;
-      }
-      enum "ds1" {
-        value 18;
-        description
-          "DS1-MIB";
-        reference
-          "RFC 4805 - Definitions of Managed Objects for the
-                      DS1, J1, E1, DS2, and E2 Interface Types";
-      }
-      enum "e1" {
-        value 19;
-        status obsolete;
-        description
-          "Obsolete see DS1-MIB";
-        reference
-          "RFC 4805 - Definitions of Managed Objects for the
-                      DS1, J1, E1, DS2, and E2 Interface Types";
-      }
-      enum "basicISDN" {
-        value 20;
-        description
-          "see also RFC2127";
-      }
-      enum "primaryISDN" {
-        value 21;
-      }
-      enum "propPointToPointSerial" {
-        value 22;
-        description
-          "proprietary serial";
-      }
-      enum "ppp" {
-        value 23;
-      }
-      enum "softwareLoopback" {
-        value 24;
-      }
-      enum "eon" {
-        value 25;
-        description
-          "CLNP over IP";
-      }
-      enum "ethernet3Mbit" {
-        value 26;
-      }
-      enum "nsip" {
-        value 27;
-        description
-          "XNS over IP";
-      }
-      enum "slip" {
-        value 28;
-        description
-          "generic SLIP";
-      }
-      enum "ultra" {
-        value 29;
-        description
-          "ULTRA technologies";
-      }
-      enum "ds3" {
-        value 30;
-        description
-          "DS3-MIB";
-        reference
-          "RFC 3896 - Definitions of Managed Objects for the
-                      DS3/E3 Interface Type";
-      }
-      enum "sip" {
-        value 31;
-        description
-          "SMDS, coffee";
-        reference
-          "RFC 1694 - Definitions of Managed Objects for SMDS
-                      Interfaces using SMIv2";
-      }
-      enum "frameRelay" {
-        value 32;
-        description
-          "DTE only.";
-        reference
-          "RFC 2115 - Management Information Base for Frame Relay
-                      DTEs Using SMIv2";
-      }
-      enum "rs232" {
-        value 33;
-        reference
-          "RFC 1659 - Definitions of Managed Objects for RS-232-like
-                      Hardware Devices using SMIv2";
-      }
-      enum "para" {
-        value 34;
-        description
-          "parallel-port";
-        reference
-          "RFC 1660 - Definitions of Managed Objects for
-                      Parallel-printer-like Hardware Devices using
-                      SMIv2";
-      }
-      enum "arcnet" {
-        value 35;
-        description
-          "arcnet";
-      }
-      enum "arcnetPlus" {
-        value 36;
-        description
-          "arcnet plus";
-      }
-      enum "atm" {
-        value 37;
-        description
-          "ATM cells";
-      }
-      enum "miox25" {
-        value 38;
-        reference
-          "RFC 1461 - SNMP MIB extension for Multiprotocol
-                      Interconnect over X.25";
-      }
-      enum "sonet" {
-        value 39;
-        description
-          "SONET or SDH";
-      }
-      enum "x25ple" {
-        value 40;
-        reference
-          "RFC 2127 - ISDN Management Information Base using SMIv2";
-      }
-      enum "iso88022llc" {
-        value 41;
-      }
-      enum "localTalk" {
-        value 42;
-      }
-      enum "smdsDxi" {
-        value 43;
-      }
-      enum "frameRelayService" {
-        value 44;
-        description
-          "FRNETSERV-MIB";
-        reference
-          "RFC 2954 - Definitions of Managed Objects for Frame
-                      Relay Service";
-      }
-      enum "v35" {
-        value 45;
-      }
-      enum "hssi" {
-        value 46;
-      }
-      enum "hippi" {
-        value 47;
-      }
-      enum "modem" {
-        value 48;
-        description
-          "Generic modem";
-      }
-      enum "aal5" {
-        value 49;
-        description
-          "AAL5 over ATM";
-      }
-      enum "sonetPath" {
-        value 50;
-      }
-      enum "sonetVT" {
-        value 51;
-      }
-      enum "smdsIcip" {
-        value 52;
-        description
-          "SMDS InterCarrier Interface";
-      }
-      enum "propVirtual" {
-        value 53;
-        description
-          "proprietary virtual/internal";
-        reference
-          "RFC 2863 - The Interfaces Group MIB";
-      }
-      enum "propMultiplexor" {
-        value 54;
-        description
-          "proprietary multiplexing";
-        reference
-          "RFC 2863 - The Interfaces Group MIB";
-      }
-      enum "ieee80212" {
-        value 55;
-        description
-          "100BaseVG";
-      }
-      enum "fibreChannel" {
-        value 56;
-        description
-          "Fibre Channel";
-      }
-      enum "hippiInterface" {
-        value 57;
-        description
-          "HIPPI interfaces";
-      }
-      enum "frameRelayInterconnect" {
-        value 58;
-        status obsolete;
-        description
-          "Obsolete use either
-           frameRelay(32) or frameRelayService(44).";
-      }
-      enum "aflane8023" {
-        value 59;
-        description
-          "ATM Emulated LAN for 802.3";
-      }
-      enum "aflane8025" {
-        value 60;
-        description
-          "ATM Emulated LAN for 802.5";
-      }
-      enum "cctEmul" {
-        value 61;
-        description
-         "ATM Emulated circuit";
-      }
-      enum "fastEther" {
-        value 62;
-        status deprecated;
-        description
-          "Obsoleted via RFC3635.
-          ethernetCsmacd(6) should be used instead";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "isdn" {
-        value 63;
-        description
-          "ISDN and X.25";
-        reference
-          "RFC 1356 - Multiprotocol Interconnect on X.25 and ISDN
-                      in the Packet Mode";
-      }
-      enum "v11" {
-        value 64;
-        description
-         "CCITT V.11/X.21";
-      }
-      enum "v36" {
-        value 65;
-        description
-          "CCITT V.36";
-      }
-      enum "g703at64k" {
-        value 66;
-        description
-          "CCITT G703 at 64Kbps";
-      }
-      enum "g703at2mb" {
-        value 67;
-        status obsolete;
-        description
-          "Obsolete see DS1-MIB";
-      }
-      enum "qllc" {
-        value 68;
-        description
-          "SNA QLLC";
-      }
-      enum "fastEtherFX" {
-        value 69;
-        status deprecated;
-        description
-          "Obsoleted via RFC3635
-          ethernetCsmacd(6) should be used instead";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "channel" {
-        value 70;
-        description
-          "channel";
-      }
-      enum "ieee80211" {
-        value 71;
-        description
-          "radio spread spectrum";
-      }
-      enum "ibm370parChan" {
-        value 72;
-        description
-          "IBM System 360/370 OEMI Channel";
-      }
-      enum "escon" {
-        value 73;
-        description
-          "IBM Enterprise Systems Connection";
-      }
-      enum "dlsw" {
-        value 74;
-        description
-          "Data Link Switching";
-      }
-      enum "isdns" {
-        value 75;
-        description
-          "ISDN S/T interface";
-      }
-      enum "isdnu" {
-        value 76;
-        description
-          "ISDN U interface";
-      }
-      enum "lapd" {
-        value 77;
-        description
-          "Link Access Protocol D";
-      }
-      enum "ipSwitch" {
-        value 78;
-        description
-          "IP Switching Objects";
-      }
-      enum "rsrb" {
-        value 79;
-        description
-          "Remote Source Route Bridging";
-      }
-      enum "atmLogical" {
-        value 80;
-        description
-          "ATM Logical Port";
-        reference
-          "RFC 3606 - Definitions of Supplemental Managed Objects
-                      for ATM Interface";
-      }
-      enum "ds0" {
-        value 81;
-        description
-          "Digital Signal Level 0";
-        reference
-          "RFC 2494 - Definitions of Managed Objects for the DS0
-                      and DS0 Bundle Interface Type";
-      }
-      enum "ds0Bundle" {
-        value 82;
-        description
-          "group of ds0s on the same ds1";
-        reference
-          "RFC 2494 - Definitions of Managed Objects for the DS0
-                      and DS0 Bundle Interface Type";
-      }
-      enum "bsc" {
-        value 83;
-        description
-          "Bisynchronous Protocol";
-      }
-      enum "async" {
-        value 84;
-        description
-          "Asynchronous Protocol";
-      }
-      enum "cnr" {
-        value 85;
-        description
-          "Combat Net Radio";
-      }
-      enum "iso88025Dtr" {
-        value 86;
-        description
-          "ISO 802.5r DTR";
-      }
-      enum "eplrs" {
-        value 87;
-        description
-          "Ext Pos Loc Report Sys";
-      }
-      enum "arap" {
-        value 88;
-        description
-          "Appletalk Remote Access Protocol";
-      }
-      enum "propCnls" {
-        value 89;
-        description
-          "Proprietary Connectionless Protocol";
-      }
-      enum "hostPad" {
-        value 90;
-        description
-          "CCITT-ITU X.29 PAD Protocol";
-      }
-      enum "termPad" {
-        value 91;
-        description
-          "CCITT-ITU X.3 PAD Facility";
-      }
-      enum "frameRelayMPI" {
-        value 92;
-        description
-          "Multiproto Interconnect over FR";
-      }
-      enum "x213" {
-        value 93;
-        description
-          "CCITT-ITU X213";
-      }
-      enum "adsl" {
-        value 94;
-        description
-          "Asymmetric Digital Subscriber Loop";
-      }
-      enum "radsl" {
-        value 95;
-        description
-          "Rate-Adapt. Digital Subscriber Loop";
-      }
-      enum "sdsl" {
-        value 96;
-        description
-          "Symmetric Digital Subscriber Loop";
-      }
-      enum "vdsl" {
-        value 97;
-        description
-          "Very H-Speed Digital Subscrib. Loop";
-      }
-      enum "iso88025CRFPInt" {
-        value 98;
-        description
-          "ISO 802.5 CRFP";
-      }
-      enum "myrinet" {
-        value 99;
-        description
-          "Myricom Myrinet";
-      }
-      enum "voiceEM" {
-        value 100;
-        description
-          "voice recEive and transMit";
-      }
-      enum "voiceFXO" {
-        value 101;
-        description
-          "voice Foreign Exchange Office";
-      }
-      enum "voiceFXS" {
-        value 102;
-        description
-          "voice Foreign Exchange Station";
-      }
-      enum "voiceEncap" {
-        value 103;
-        description
-          "voice encapsulation";
-      }
-      enum "voiceOverIp" {
-        value 104;
-        description
-          "voice over IP encapsulation";
-      }
-      enum "atmDxi" {
-        value 105;
-        description
-          "ATM DXI";
-      }
-      enum "atmFuni" {
-        value 106;
-        description
-          "ATM FUNI";
-      }
-      enum "atmIma" {
-        value 107;
-        description
-          "ATM IMA";
-      }
-      enum "pppMultilinkBundle" {
-        value 108;
-        description
-          "PPP Multilink Bundle";
-      }
-      enum "ipOverCdlc" {
-        value 109;
-        description
-          "IBM ipOverCdlc";
-      }
-      enum "ipOverClaw" {
-        value 110;
-        description
-          "IBM Common Link Access to Workstn";
-      }
-      enum "stackToStack" {
-        value 111;
-        description
-          "IBM stackToStack";
-      }
-      enum "virtualIpAddress" {
-        value 112;
-        description
-          "IBM VIPA";
-      }
-      enum "mpc" {
-        value 113;
-        description
-          "IBM multi-protocol channel support";
-      }
-      enum "ipOverAtm" {
-        value 114;
-        description
-          "IBM ipOverAtm";
-        reference
-          "RFC 2320 - Definitions of Managed Objects for Classical IP
-                      and ARP Over ATM Using SMIv2 (IPOA-MIB)";
-      }
-      enum "iso88025Fiber" {
-        value 115;
-        description
-          "ISO 802.5j Fiber Token Ring";
-      }
-      enum "tdlc" {
-        value 116;
-        description
-          "IBM twinaxial data link control";
-      }
-      enum "gigabitEthernet" {
-        value 117;
-        status deprecated;
-        description
-          "Obsoleted via RFC3635
-           ethernetCsmacd(6) should be used instead";
-        reference
-          "RFC 3635 - Definitions of Managed Objects for the
-                      Ethernet-like Interface Types.";
-      }
-      enum "hdlc" {
-        value 118;
-        description
-          "HDLC";
-      }
-      enum "lapf" {
-        value 119;
-        description
-          "LAP F";
-      }
-      enum "v37" {
-        value 120;
-        description
-          "V.37";
-      }
-      enum "x25mlp" {
-        value 121;
-        description
-          "Multi-Link Protocol";
-      }
-      enum "x25huntGroup" {
-        value 122;
-        description
-          "X25 Hunt Group";
-      }
-      enum "transpHdlc" {
-        value 123;
-        description
-          "Transp HDLC";
-      }
-      enum "interleave" {
-        value 124;
-        description
-          "Interleave channel";
-      }
-      enum "fast" {
-        value 125;
-        description
-          "Fast channel";
-      }
-      enum "ip" {
-        value 126;
-        description
-          "IP (for APPN HPR in IP networks)";
-      }
-      enum "docsCableMaclayer" {
-        value 127;
-        description
-          "CATV Mac Layer";
-      }
-      enum "docsCableDownstream" {
-        value 128;
-        description
-          "CATV Downstream interface";
-      }
-      enum "docsCableUpstream" {
-        value 129;
-        description
-          "CATV Upstream interface";
-      }
-      enum "a12MppSwitch" {
-        value 130;
-        description
-          "Avalon Parallel Processor";
-      }
-      enum "tunnel" {
-        value 131;
-        description
-          "Encapsulation interface";
-      }
-      enum "coffee" {
-        value 132;
-        description
-          "coffee pot";
-        reference
-          "RFC 2325 - Coffee MIB";
-      }
-      enum "ces" {
-        value 133;
-        description
-          "Circuit Emulation Service";
-      }
-      enum "atmSubInterface" {
-        value 134;
-        description
-          "ATM Sub Interface";
-      }
-      enum "l2vlan" {
-        value 135;
-        description
-          "Layer 2 Virtual LAN using 802.1Q";
-      }
-      enum "l3ipvlan" {
-        value 136;
-        description
-          "Layer 3 Virtual LAN using IP";
-      }
-      enum "l3ipxvlan" {
-        value 137;
-        description
-          "Layer 3 Virtual LAN using IPX";
-      }
-      enum "digitalPowerline" {
-        value 138;
-        description
-          "IP over Power Lines";
-      }
-      enum "mediaMailOverIp" {
-        value 139;
-        description
-          "Multimedia Mail over IP";
-      }
-      enum "dtm" {
-        value 140;
-        description
-          "Dynamic syncronous Transfer Mode";
-      }
-      enum "dcn" {
-        value 141;
-        description
-          "Data Communications Network";
-      }
-      enum "ipForward" {
-        value 142;
-        description
-          "IP Forwarding Interface";
-      }
-      enum "msdsl" {
-        value 143;
-        description
-          "Multi-rate Symmetric DSL";
-      }
-      enum "ieee1394" {
-        value 144;
-        description
-          "IEEE1394 High Performance Serial Bus";
-      }
-      enum "if-gsn" {
-        value 145;
-        description
-          "HIPPI-6400";
-      }
-      enum "dvbRccMacLayer" {
-        value 146;
-        description
-          "DVB-RCC MAC Layer";
-      }
-      enum "dvbRccDownstream" {
-        value 147;
-        description
-          "DVB-RCC Downstream Channel";
-      }
-      enum "dvbRccUpstream" {
-        value 148;
-        description
-          "DVB-RCC Upstream Channel";
-      }
-      enum "atmVirtual" {
-        value 149;
-        description
-          "ATM Virtual Interface";
-      }
-      enum "mplsTunnel" {
-        value 150;
-        description
-          "MPLS Tunnel Virtual Interface";
-      }
-      enum "srp" {
-        value 151;
-        description
-          "Spatial Reuse Protocol       ";
-      }
-      enum "voiceOverAtm" {
-        value 152;
-        description
-          "Voice Over ATM";
-      }
-      enum "voiceOverFrameRelay" {
-        value 153;
-        description
-          "Voice Over Frame Relay";
-      }
-      enum "idsl" {
-        value 154;
-        description
-          "Digital Subscriber Loop over ISDN";
-      }
-      enum "compositeLink" {
-        value 155;
-        description
-          "Avici Composite Link Interface";
-      }
-      enum "ss7SigLink" {
-        value 156;
-        description
-          "SS7 Signaling Link";
-      }
-      enum "propWirelessP2P" {
-        value 157;
-        description
-          "Prop. P2P wireless interface";
-      }
-      enum "frForward" {
-        value 158;
-        description
-          "Frame Forward Interface";
-      }
-      enum "rfc1483" {
-        value 159;
-        description
-          "Multiprotocol over ATM AAL5";
-        reference
-          "RFC 1483 - Multiprotocol Encapsulation over ATM
-                      Adaptation Layer 5";
-      }
-      enum "usb" {
-        value 160;
-        description
-          "USB Interface";
-      }
-      enum "ieee8023adLag" {
-        value 161;
-        description
-          "IEEE 802.3ad Link Aggregate";
-      }
-      enum "bgppolicyaccounting" {
-        value 162;
-        description
-          "BGP Policy Accounting";
-      }
-      enum "frf16MfrBundle" {
-        value 163;
-        description
-          "FRF .16 Multilink Frame Relay";
-      }
-      enum "h323Gatekeeper" {
-        value 164;
-        description
-          "H323 Gatekeeper";
-      }
-      enum "h323Proxy" {
-        value 165;
-        description
-          "H323 Voice and Video Proxy";
-      }
-      enum "mpls" {
-        value 166;
-        description
-          "MPLS";
-      }
-      enum "mfSigLink" {
-        value 167;
-        description
-          "Multi-frequency signaling link";
-      }
-      enum "hdsl2" {
-        value 168;
-        description
-          "High Bit-Rate DSL - 2nd generation";
-      }
-      enum "shdsl" {
-        value 169;
-        description
-          "Multirate HDSL2";
-      }
-      enum "ds1FDL" {
-        value 170;
-        description
-          "Facility Data Link 4Kbps on a DS1";
-      }
-      enum "pos" {
-        value 171;
-        description
-          "Packet over SONET/SDH Interface";
-      }
-      enum "dvbAsiIn" {
-        value 172;
-        description
-          "DVB-ASI Input";
-      }
-      enum "dvbAsiOut" {
-        value 173;
-        description
-          "DVB-ASI Output";
-      }
-      enum "plc" {
-        value 174;
-        description
-          "Power Line Communtications";
-      }
-      enum "nfas" {
-        value 175;
-        description
-          "Non Facility Associated Signaling";
-      }
-      enum "tr008" {
-        value 176;
-        description
-          "TR008";
-      }
-      enum "gr303RDT" {
-        value 177;
-        description
-          "Remote Digital Terminal";
-      }
-      enum "gr303IDT" {
-        value 178;
-        description
-          "Integrated Digital Terminal";
-      }
-      enum "isup" {
-        value 179;
-        description
-          "ISUP";
-      }
-      enum "propDocsWirelessMaclayer" {
-        value 180;
-        description
-          "Cisco proprietary Maclayer";
-      }
-      enum "propDocsWirelessDownstream" {
-        value 181;
-        description
-          "Cisco proprietary Downstream";
-      }
-      enum "propDocsWirelessUpstream" {
-        value 182;
-        description
-          "Cisco proprietary Upstream";
-      }
-      enum "hiperlan2" {
-        value 183;
-        description
-          "HIPERLAN Type 2 Radio Interface";
-      }
-      enum "propBWAp2Mp" {
-        value 184;
-        description
-          "PropBroadbandWirelessAccesspt2multipt use of this value
-           for IEEE 802.16 WMAN interfaces as per IEEE Std 802.16f
-           is deprecated and ieee80216WMAN(237) should be used
-           instead.";
-      }
-      enum "sonetOverheadChannel" {
-        value 185;
-        description
-          "SONET Overhead Channel";
-      }
-      enum "digitalWrapperOverheadChannel" {
-        value 186;
-        description
-          "Digital Wrapper";
-      }
-      enum "aal2" {
-        value 187;
-        description
-          "ATM adaptation layer 2";
-      }
-      enum "radioMAC" {
-        value 188;
-        description
-          "MAC layer over radio links";
-      }
-      enum "atmRadio" {
-        value 189;
-        description
-          "ATM over radio links";
-      }
-      enum "imt" {
-        value 190;
-        description
-          "Inter Machine Trunks";
-      }
-      enum "mvl" {
-        value 191;
-        description
-          "Multiple Virtual Lines DSL";
-      }
-      enum "reachDSL" {
-        value 192;
-        description
-          "Long Reach DSL";
-      }
-      enum "frDlciEndPt" {
-        value 193;
-        description
-          "Frame Relay DLCI End Point";
-      }
-      enum "atmVciEndPt" {
-        value 194;
-        description
-          "ATM VCI End Point";
-      }
-      enum "opticalChannel" {
-        value 195;
-        description
-          "Optical Channel";
-      }
-      enum "opticalTransport" {
-        value 196;
-        description
-          "Optical Transport";
-      }
-      enum "propAtm" {
-        value 197;
-        description
-          "Proprietary ATM";
-      }
-      enum "voiceOverCable" {
-        value 198;
-        description
-          "Voice Over Cable Interface";
-      }
-      enum "infiniband" {
-        value 199;
-        description
-          "Infiniband";
-      }
-      enum "teLink" {
-        value 200;
-        description
-          "TE Link";
-      }
-      enum "q2931" {
-        value 201;
-        description
-          "Q.2931";
-      }
-      enum "virtualTg" {
-        value 202;
-        description
-          "Virtual Trunk Group";
-      }
-      enum "sipTg" {
-        value 203;
-        description
-          "SIP Trunk Group";
-      }
-      enum "sipSig" {
-        value 204;
-        description
-          "SIP Signaling";
-      }
-      enum "docsCableUpstreamChannel" {
-        value 205;
-        description
-          "CATV Upstream Channel";
-      }
-      enum "econet" {
-        value 206;
-        description
-          "Acorn Econet";
-      }
-      enum "pon155" {
-        value 207;
-        description
-          "FSAN 155Mb Symetrical PON interface";
-      }
-      enum "pon622" {
-        value 208;
-        description
-          "FSAN622Mb Symetrical PON interface";
-      }
-      enum "bridge" {
-        value 209;
-        description
-          "Transparent bridge interface";
-      }
-      enum "linegroup" {
-        value 210;
-        description
-          "Interface common to multiple lines";
-      }
-      enum "voiceEMFGD" {
-        value 211;
-        description
-          "voice E&M Feature Group D";
-      }
-      enum "voiceFGDEANA" {
-        value 212;
-        description
-          "voice FGD Exchange Access North American";
-      }
-      enum "voiceDID" {
-        value 213;
-        description
-          "voice Direct Inward Dialing";
-      }
-      enum "mpegTransport" {
-        value 214;
-        description
-          "MPEG transport interface";
-      }
-      enum "sixToFour" {
-        value 215;
-        status deprecated;
-        description
-          "6to4 interface (DEPRECATED)";
-        reference
-          "RFC 4087 - IP Tunnel MIB";
-      }
-      enum "gtp" {
-        value 216;
-        description
-          "GTP (GPRS Tunneling Protocol)";
-      }
-      enum "pdnEtherLoop1" {
-        value 217;
-        description
-          "Paradyne EtherLoop 1";
-      }
-      enum "pdnEtherLoop2" {
-        value 218;
-        description
-          "Paradyne EtherLoop 2";
-      }
-      enum "opticalChannelGroup" {
-        value 219;
-        description
-          "Optical Channel Group";
-      }
-      enum "homepna" {
-        value 220;
-        description
-          "HomePNA ITU-T G.989";
-      }
-      enum "gfp" {
-        value 221;
-        description
-          "Generic Framing Procedure (GFP)";
-      }
-      enum "ciscoISLvlan" {
-        value 222;
-        description
-          "Layer 2 Virtual LAN using Cisco ISL";
-      }
-      enum "actelisMetaLOOP" {
-        value 223;
-        description
-          "Acteleis proprietary MetaLOOP High Speed Link";
-      }
-      enum "fcipLink" {
-        value 224;
-        description
-          "FCIP Link";
-      }
-      enum "rpr" {
-        value 225;
-        description
-          "Resilient Packet Ring Interface Type";
-      }
-      enum "qam" {
-        value 226;
-        description
-          "RF Qam Interface";
-      }
-      enum "lmp" {
-        value 227;
-        description
-          "Link Management Protocol";
-        reference
-          "RFC 4327 - Link Management Protocol (LMP) Management
-                      Information Base (MIB)";
-      }
-      enum "cblVectaStar" {
-        value 228;
-        description
-          "Cambridge Broadband Networks Limited VectaStar";
-      }
-      enum "docsCableMCmtsDownstream" {
-        value 229;
-        description
-          "CATV Modular CMTS Downstream Interface";
-      }
-      enum "adsl2" {
-        value 230;
-        status deprecated;
-        description
-          "Asymmetric Digital Subscriber Loop Version 2
-           (DEPRECATED/OBSOLETED - please use adsl2plus(238)
-           instead)";
-        reference
-          "RFC 4706 - Definitions of Managed Objects for Asymmetric
-                      Digital Subscriber Line 2 (ADSL2)";
-      }
-      enum "macSecControlledIF" {
-        value 231;
-        description
-          "MACSecControlled";
-      }
-      enum "macSecUncontrolledIF" {
-        value 232;
-        description
-          "MACSecUncontrolled";
-      }
-      enum "aviciOpticalEther" {
-        value 233;
-        description
-         "Avici Optical Ethernet Aggregate";
-      }
-      enum "atmbond" {
-        value 234;
-        description
-          "atmbond";
-      }
-      enum "voiceFGDOS" {
-        value 235;
-        description
-          "voice FGD Operator Services";
-      }
-      enum "mocaVersion1" {
-        value 236;
-        description
-          "MultiMedia over Coax Alliance (MoCA) Interface
-           as documented in information provided privately to IANA";
-      }
-      enum "ieee80216WMAN" {
-        value 237;
-        description
-          "IEEE 802.16 WMAN interface";
-      }
-      enum "adsl2plus" {
-        value 238;
-        description
-          "Asymmetric Digital Subscriber Loop Version 2,
-           Version 2 Plus and all variants";
-      }
-      enum "dvbRcsMacLayer" {
-        value 239;
-        description
-          "DVB-RCS MAC Layer";
-        reference
-          "RFC 5728 - The SatLabs Group DVB-RCS MIB";
-      }
-      enum "dvbTdm" {
-        value 240;
-        description
-          "DVB Satellite TDM";
-        reference
-          "RFC 5728 - The SatLabs Group DVB-RCS MIB";
-      }
-      enum "dvbRcsTdma" {
-        value 241;
-        description
-          "DVB-RCS TDMA";
-        reference
-          "RFC 5728 - The SatLabs Group DVB-RCS MIB";
-      }
-      enum "x86Laps" {
-        value 242;
-        description
-          "LAPS based on ITU-T X.86/Y.1323";
-      }
-      enum "wwanPP" {
-        value 243;
-        description
-          "3GPP WWAN";
-      }
-      enum "wwanPP2" {
-        value 244;
-        description
-          "3GPP2 WWAN";
-      }
-      enum "voiceEBS" {
-        value 245;
-        description
-          "voice P-phone EBS physical interface";
-      }
-      enum "ifPwType" {
-        value 246;
-        description
-          "Pseudowire interface type";
-        reference
-          "RFC 5601 - Pseudowire (PW) Management Information Base";
-      }
-      enum "ilan" {
-        value 247;
-        description
-          "Internal LAN on a bridge per IEEE 802.1ap";
-      }
-      enum "pip" {
-        value 248;
-        description
-          "Provider Instance Port on a bridge per IEEE 802.1ah PBB";
-      }
-      enum "aluELP" {
-        value 249;
-        description
-          "Alcatel-Lucent Ethernet Link Protection";
-      }
-      enum "gpon" {
-        value 250;
-        description
-          "Gigabit-capable passive optical networks (G-PON) as per
-           ITU-T G.948";
-      }
-      enum "vdsl2" {
-        value 251;
-        description
-          "Very high speed digital subscriber line Version 2
-           (as per ITU-T Recommendation G.993.2)";
-        reference
-          "RFC 5650 - Definitions of Managed Objects for Very High
-                      Speed Digital Subscriber Line 2 (VDSL2)";
-      }
-      enum "capwapDot11Profile" {
-        value 252;
-        description
-          "WLAN Profile Interface";
-        reference
-          "RFC 5834 - Control and Provisioning of Wireless Access
-                      Points (CAPWAP) Protocol Binding MIB for
-                      IEEE 802.11";
-      }
-      enum "capwapDot11Bss" {
-        value 253;
-        description
-          "WLAN BSS Interface";
-        reference
-          "RFC 5834 - Control and Provisioning of Wireless Access
-                      Points (CAPWAP) Protocol Binding MIB for
-                      IEEE 802.11";
-      }
-      enum "capwapWtpVirtualRadio" {
-        value 254;
-        description
-          "WTP Virtual Radio Interface";
-        reference
-          "RFC 5833 - Control and Provisioning of Wireless Access
-                      Points (CAPWAP) Protocol Base MIB";
-      }
-      enum "bits" {
-        value 255;
-        description
-          "bitsport";
-      }
-      enum "docsCableUpstreamRfPort" {
-        value 256;
-        description
-          "DOCSIS CATV Upstream RF Port";
-      }
-      enum "cableDownstreamRfPort" {
-        value 257;
-        description
-          "CATV downstream RF port";
-      }
-      enum "vmwareVirtualNic" {
-        value 258;
-        description
-          "VMware Virtual Network Interface";
-      }
-      enum "ieee802154" {
-        value 259;
-        description
-          "IEEE 802.15.4 WPAN interface";
-        reference
-          "IEEE 802.15.4-2006";
-      }
-      enum "otnOdu" {
-        value 260;
-        description
-          "OTN Optical Data Unit";
-      }
-      enum "otnOtu" {
-        value 261;
-        description
-          "OTN Optical channel Transport Unit";
-      }
-      enum "ifVfiType" {
-        value 262;
-        description
-          "VPLS Forwarding Instance Interface Type";
-      }
-      enum "g9981" {
-        value 263;
-        description
-          "G.998.1 bonded interface";
-      }
-      enum "g9982" {
-        value 264;
-        description
-          "G.998.2 bonded interface";
-      }
-      enum "g9983" {
-        value 265;
-        description
-          "G.998.3 bonded interface";
-      }
-      enum "aluEpon" {
-        value 266;
-        description
-          "Ethernet Passive Optical Networks (E-PON)";
-      }
-      enum "aluEponOnu" {
-        value 267;
-        description
-          "EPON Optical Network Unit";
-      }
-      enum "aluEponPhysicalUni" {
-        value 268;
-        description
-          "EPON physical User to Network interface";
-      }
-      enum "aluEponLogicalLink" {
-        value 269;
-        description
-          "The emulation of a point-to-point link over the EPON
-           layer";
-      }
-      enum "aluGponOnu" {
-        value 270;
-        description
-          "GPON Optical Network Unit";
-        reference
-          "ITU-T G.984.2";
-      }
-      enum "aluGponPhysicalUni" {
-        value 271;
-        description
-          "GPON physical User to Network interface";
-        reference
-          "ITU-T G.984.2";
-      }
-      enum "vmwareNicTeam" {
-        value 272;
-        description
-          "VMware NIC Team";
-      }
-    }
-    description
-      "This data type is used as the syntax of the 'type'
-       leaf in the 'interface' list in the YANG module
-       ietf-interface.
-
-       The definition of this typedef with the
-       addition of newly assigned values is published
-       periodically by the IANA, in either the Assigned
-       Numbers RFC, or some derivative of it specific to
-       Internet Network Management number assignments.  (The
-       latest arrangements can be obtained by contacting the
-       IANA.)
-
-       Requests for new values should be made to IANA via
-       email (iana&iana.org).";
-    reference
-      "ifType definitions registry.
-       <http://www.iana.org/assignments/smi-numbers>";
-  }
-}
\ No newline at end of file
diff --git a/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-inet-types@2010-09-24.yang b/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-inet-types@2010-09-24.yang
deleted file mode 100644 (file)
index 6a6c748..0000000
+++ /dev/null
@@ -1,418 +0,0 @@
- module ietf-inet-types {
-
-   namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types";
-   prefix "inet";
-
-   organization
-    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
-   contact
-    "WG Web:   <http://tools.ietf.org/wg/netmod/>
-     WG List:  <mailto:netmod@ietf.org>
-
-     WG Chair: David Partain
-               <mailto:david.partain@ericsson.com>
-
-     WG Chair: David Kessens
-               <mailto:david.kessens@nsn.com>
-
-     Editor:   Juergen Schoenwaelder
-               <mailto:j.schoenwaelder@jacobs-university.de>";
-
-   description
-    "This module contains a collection of generally useful derived
-     YANG data types for Internet addresses and related things.
-
-     Copyright (c) 2010 IETF Trust and the persons identified as
-     authors of the code.  All rights reserved.
-
-     Redistribution and use in source and binary forms, with or without
-     modification, is permitted pursuant to, and subject to the license
-     terms contained in, the Simplified BSD License set forth in Section
-     4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
-     (http://trustee.ietf.org/license-info).
-
-     This version of this YANG module is part of RFC 6021; see
-     the RFC itself for full legal notices.";
-
-   revision 2010-09-24 {
-     description
-      "Initial revision.";
-     reference
-      "RFC 6021: Common YANG Data Types";
-   }
-
-   /*** collection of protocol field related types ***/
-
-   typedef ip-version {
-     type enumeration {
-       enum unknown {
-         value "0";
-         description
-          "An unknown or unspecified version of the Internet protocol.";
-       }
-       enum ipv4 {
-         value "1";
-         description
-          "The IPv4 protocol as defined in RFC 791.";
-       }
-       enum ipv6 {
-         value "2";
-         description
-          "The IPv6 protocol as defined in RFC 2460.";
-       }
-     }
-     description
-      "This value represents the version of the IP protocol.
-
-       In the value set and its semantics, this type is equivalent
-       to the InetVersion textual convention of the SMIv2.";
-     reference
-      "RFC  791: Internet Protocol
-       RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
-       RFC 4001: Textual Conventions for Internet Network Addresses";
-   }
-
-   typedef dscp {
-     type uint8 {
-       range "0..63";
-     }
-     description
-      "The dscp type represents a Differentiated Services Code-Point
-       that may be used for marking packets in a traffic stream.
-
-       In the value set and its semantics, this type is equivalent
-       to the Dscp textual convention of the SMIv2.";
-     reference
-      "RFC 3289: Management Information Base for the Differentiated
-                 Services Architecture
-       RFC 2474: Definition of the Differentiated Services Field
-                 (DS Field) in the IPv4 and IPv6 Headers
-       RFC 2780: IANA Allocation Guidelines For Values In
-                 the Internet Protocol and Related Headers";
-   }
-
-   typedef ipv6-flow-label {
-     type uint32 {
-       range "0..1048575";
-     }
-     description
-      "The flow-label type represents flow identifier or Flow Label
-       in an IPv6 packet header that may be used to discriminate
-       traffic flows.
-
-       In the value set and its semantics, this type is equivalent
-       to the IPv6FlowLabel textual convention of the SMIv2.";
-     reference
-      "RFC 3595: Textual Conventions for IPv6 Flow Label
-       RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
-   }
-
-   typedef port-number {
-     type uint16 {
-       range "0..65535";
-     }
-     description
-      "The port-number type represents a 16-bit port number of an
-       Internet transport layer protocol such as UDP, TCP, DCCP, or
-       SCTP.  Port numbers are assigned by IANA.  A current list of
-       all assignments is available from <http://www.iana.org/>.
-
-       Note that the port number value zero is reserved by IANA.  In
-       situations where the value zero does not make sense, it can
-       be excluded by subtyping the port-number type.
-
-       In the value set and its semantics, this type is equivalent
-       to the InetPortNumber textual convention of the SMIv2.";
-     reference
-      "RFC  768: User Datagram Protocol
-       RFC  793: Transmission Control Protocol
-       RFC 4960: Stream Control Transmission Protocol
-       RFC 4340: Datagram Congestion Control Protocol (DCCP)
-       RFC 4001: Textual Conventions for Internet Network Addresses";
-   }
-
-   /*** collection of autonomous system related types ***/
-
-   typedef as-number {
-     type uint32;
-     description
-      "The as-number type represents autonomous system numbers
-       which identify an Autonomous System (AS).  An AS is a set
-       of routers under a single technical administration, using
-       an interior gateway protocol and common metrics to route
-       packets within the AS, and using an exterior gateway
-       protocol to route packets to other ASs'.  IANA maintains
-       the AS number space and has delegated large parts to the
-       regional registries.
-
-       Autonomous system numbers were originally limited to 16
-       bits.  BGP extensions have enlarged the autonomous system
-       number space to 32 bits.  This type therefore uses an uint32
-       base type without a range restriction in order to support
-       a larger autonomous system number space.
-
-       In the value set and its semantics, this type is equivalent
-       to the InetAutonomousSystemNumber textual convention of
-       the SMIv2.";
-     reference
-      "RFC 1930: Guidelines for creation, selection, and registration
-                 of an Autonomous System (AS)
-       RFC 4271: A Border Gateway Protocol 4 (BGP-4)
-       RFC 4893: BGP Support for Four-octet AS Number Space
-       RFC 4001: Textual Conventions for Internet Network Addresses";
-   }
-
-   /*** collection of IP address and hostname related types ***/
-
-   typedef ip-address {
-     type union {
-       type inet:ipv4-address;
-       type inet:ipv6-address;
-     }
-     description
-      "The ip-address type represents an IP address and is IP
-       version neutral.  The format of the textual representations
-       implies the IP version.";
-   }
-
-   typedef ipv4-address {
-     type string {
-       pattern
-         '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
-       +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
-       + '(%[\p{N}\p{L}]+)?';
-     }
-     description
-       "The ipv4-address type represents an IPv4 address in
-        dotted-quad notation.  The IPv4 address may include a zone
-        index, separated by a % sign.
-
-        The zone index is used to disambiguate identical address
-        values.  For link-local addresses, the zone index will
-        typically be the interface index number or the name of an
-        interface.  If the zone index is not present, the default
-        zone of the device will be used.
-
-        The canonical format for the zone index is the numerical
-        format";
-   }
-
-   typedef ipv6-address {
-     type string {
-       pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
-             + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
-             + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
-             + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
-             + '(%[\p{N}\p{L}]+)?';
-       pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
-             + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
-             + '(%.+)?';
-     }
-     description
-      "The ipv6-address type represents an IPv6 address in full,
-       mixed, shortened, and shortened-mixed notation.  The IPv6
-       address may include a zone index, separated by a % sign.
-
-       The zone index is used to disambiguate identical address
-       values.  For link-local addresses, the zone index will
-       typically be the interface index number or the name of an
-       interface.  If the zone index is not present, the default
-       zone of the device will be used.
-
-       The canonical format of IPv6 addresses uses the compressed
-       format described in RFC 4291, Section 2.2, item 2 with the
-       following additional rules: the :: substitution must be
-       applied to the longest sequence of all-zero 16-bit chunks
-       in an IPv6 address.  If there is a tie, the first sequence
-       of all-zero 16-bit chunks is replaced by ::.  Single
-       all-zero 16-bit chunks are not compressed.  The canonical
-       format uses lowercase characters and leading zeros are
-       not allowed.  The canonical format for the zone index is
-       the numerical format as described in RFC 4007, Section
-       11.2.";
-     reference
-      "RFC 4291: IP Version 6 Addressing Architecture
-       RFC 4007: IPv6 Scoped Address Architecture
-       RFC 5952: A Recommendation for IPv6 Address Text Representation";
-   }
-
-   typedef ip-prefix {
-     type union {
-       type inet:ipv4-prefix;
-       type inet:ipv6-prefix;
-     }
-     description
-      "The ip-prefix type represents an IP prefix and is IP
-       version neutral.  The format of the textual representations
-       implies the IP version.";
-   }
-
-   typedef ipv4-prefix {
-     type string {
-       pattern
-          '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
-        +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
-        + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
-     }
-     description
-      "The ipv4-prefix type represents an IPv4 address prefix.
-       The prefix length is given by the number following the
-       slash character and must be less than or equal to 32.
-
-       A prefix length value of n corresponds to an IP address
-       mask that has n contiguous 1-bits from the most
-       significant bit (MSB) and all other bits set to 0.
-
-       The canonical format of an IPv4 prefix has all bits of
-       the IPv4 address set to zero that are not part of the
-       IPv4 prefix.";
-   }
-
-   typedef ipv6-prefix {
-     type string {
-       pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
-             + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
-             + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
-             + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
-             + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
-       pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
-             + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
-             + '(/.+)';
-     }
-     description
-      "The ipv6-prefix type represents an IPv6 address prefix.
-       The prefix length is given by the number following the
-       slash character and must be less than or equal 128.
-
-       A prefix length value of n corresponds to an IP address
-       mask that has n contiguous 1-bits from the most
-       significant bit (MSB) and all other bits set to 0.
-
-       The IPv6 address should have all bits that do not belong
-       to the prefix set to zero.
-
-       The canonical format of an IPv6 prefix has all bits of
-       the IPv6 address set to zero that are not part of the
-       IPv6 prefix.  Furthermore, IPv6 address is represented
-       in the compressed format described in RFC 4291, Section
-       2.2, item 2 with the following additional rules: the ::
-       substitution must be applied to the longest sequence of
-       all-zero 16-bit chunks in an IPv6 address.  If there is
-       a tie, the first sequence of all-zero 16-bit chunks is
-       replaced by ::.  Single all-zero 16-bit chunks are not
-       compressed.  The canonical format uses lowercase
-       characters and leading zeros are not allowed.";
-     reference
-      "RFC 4291: IP Version 6 Addressing Architecture";
-   }
-
-   /*** collection of domain name and URI types ***/
-
-   typedef domain-name {
-     type string {
-       pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*'
-            +  '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)'
-            +  '|\.';
-       length "1..253";
-     }
-     description
-      "The domain-name type represents a DNS domain name.  The
-       name SHOULD be fully qualified whenever possible.
-
-       Internet domain names are only loosely specified.  Section
-       3.5 of RFC 1034 recommends a syntax (modified in Section
-       2.1 of RFC 1123).  The pattern above is intended to allow
-       for current practice in domain name use, and some possible
-       future expansion.  It is designed to hold various types of
-       domain names, including names used for A or AAAA records
-       (host names) and other records, such as SRV records.  Note
-       that Internet host names have a stricter syntax (described
-       in RFC 952) than the DNS recommendations in RFCs 1034 and
-       1123, and that systems that want to store host names in
-       schema nodes using the domain-name type are recommended to
-       adhere to this stricter standard to ensure interoperability.
-
-       The encoding of DNS names in the DNS protocol is limited
-       to 255 characters.  Since the encoding consists of labels
-       prefixed by a length bytes and there is a trailing NULL
-       byte, only 253 characters can appear in the textual dotted
-       notation.
-
-       The description clause of schema nodes using the domain-name
-       type MUST describe when and how these names are resolved to
-       IP addresses.  Note that the resolution of a domain-name value
-       may require to query multiple DNS records (e.g., A for IPv4
-       and AAAA for IPv6).  The order of the resolution process and
-       which DNS record takes precedence can either be defined
-       explicitely or it may depend on the configuration of the
-       resolver.
-
-       Domain-name values use the US-ASCII encoding.  Their canonical
-       format uses lowercase US-ASCII characters.  Internationalized
-       domain names MUST be encoded in punycode as described in RFC
-       3492";
-     reference
-      "RFC  952: DoD Internet Host Table Specification
-       RFC 1034: Domain Names - Concepts and Facilities
-       RFC 1123: Requirements for Internet Hosts -- Application
-                 and Support
-       RFC 2782: A DNS RR for specifying the location of services
-                 (DNS SRV)
-       RFC 3492: Punycode: A Bootstring encoding of Unicode for
-                 Internationalized Domain Names in Applications
-                 (IDNA)
-       RFC 5891: Internationalizing Domain Names in Applications
-                 (IDNA): Protocol";
-   }
-
-   typedef host {
-     type union {
-       type inet:ip-address;
-       type inet:domain-name;
-     }
-     description
-      "The host type represents either an IP address or a DNS
-       domain name.";
-   }
-
-   typedef uri {
-     type string;
-     description
-      "The uri type represents a Uniform Resource Identifier
-       (URI) as defined by STD 66.
-
-       Objects using the uri type MUST be in US-ASCII encoding,
-       and MUST be normalized as described by RFC 3986 Sections
-       6.2.1, 6.2.2.1, and 6.2.2.2.  All unnecessary
-       percent-encoding is removed, and all case-insensitive
-       characters are set to lowercase except for hexadecimal
-       digits, which are normalized to uppercase as described in
-       Section 6.2.2.1.
-
-       The purpose of this normalization is to help provide
-       unique URIs.  Note that this normalization is not
-       sufficient to provide uniqueness.  Two URIs that are
-       textually distinct after this normalization may still be
-       equivalent.
-
-       Objects using the uri type may restrict the schemes that
-       they permit.  For example, 'data:' and 'urn:' schemes
-       might not be appropriate.
-
-       A zero-length URI is not a valid URI.  This can be used to
-       express 'URI absent' where required.
-
-       In the value set and its semantics, this type is equivalent
-       to the Uri SMIv2 textual convention defined in RFC 5017.";
-     reference
-      "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
-       RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
-                 Group: Uniform Resource Identifiers (URIs), URLs,
-                 and Uniform Resource Names (URNs): Clarifications
-                 and Recommendations
-       RFC 5017: MIB Textual Conventions for Uniform Resource
-                 Identifiers (URIs)";
-   }
-
- }
\ No newline at end of file
index b9117d03ab5b79074fce65e100d238b9c1e9015d..4518e0e58f5ddf7908967a17ce623c5715f70be5 100644 (file)
@@ -3,563 +3,31 @@ module ietf-interfaces {
   namespace "urn:ietf:params:xml:ns:yang:ietf-interfaces";
   prefix if;
 
-  import ietf-yang-types {
-    prefix yang;
-  }
-  import iana-if-type {
-    prefix ianaift;
-  }
-
-  organization
-    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
-  contact
-    "WG Web:   <http://tools.ietf.org/wg/netmod/>
-     WG List:  <mailto:netmod@ietf.org>
-
-     WG Chair: David Kessens
-               <mailto:david.kessens@nsn.com>
-
-     WG Chair: Juergen Schoenwaelder
-               <mailto:j.schoenwaelder@jacobs-university.de>
-
-     Editor:   Martin Bjorklund
-               <mailto:mbj@tail-f.com>";
-
-  description
-    "This module contains a collection of YANG definitions for
-     managing network interfaces.
-
-     Copyright (c) 2012 IETF Trust and the persons identified as
-     authors of the code.  All rights reserved.
-
-     Redistribution and use in source and binary forms, with or
-     without modification, is permitted pursuant to, and subject
-     to the license terms contained in, the Simplified BSD License
-     set forth in Section 4.c of the IETF Trust's Legal Provisions
-     Relating to IETF Documents
-     (http://trustee.ietf.org/license-info).
-
-     This version of this YANG module is part of RFC XXXX; see
-     the RFC itself for full legal notices.";
-
-  // RFC Ed.: replace XXXX with actual RFC number and remove this
-  // note.
-
-  // RFC Ed.: update the date below with the date of RFC publication
-  // and remove this note.
   revision 2012-11-15 {
-    description
-      "Initial revision.";
-    reference
-      "RFC XXXX: A YANG Data Model for Interface Management";
   }
 
-  /* Typedefs */
-
   typedef interface-ref {
     type leafref {
       path "/if:interfaces/if:interface/if:name";
     }
-    description
-      "This type is used by data models that need to reference
-       interfaces.";
-  }
-
-  /* Features */
-
-  feature arbitrary-names {
-    description
-      "This feature indicates that the server allows interfaces to
-       be named arbitrarily.";
   }
 
-  feature if-mib {
-    description
-      "This feature indicates that the server implements IF-MIB.";
-    reference
-      "RFC 2863: The Interfaces Group MIB";
-  }
-
-  /* Data nodes */
 
   container interfaces {
-    description
-      "Interface parameters.";
 
     list interface {
       key "name";
       unique "type location";
 
-      description
-        "The list of interfaces on the device.";
-
       leaf name {
         type string;
-        description
-          "The name of the interface.
-
-           A device MAY restrict the allowed values for this leaf,
-           possibly depending on the type and location.
-
-           If the device allows arbitrarily named interfaces, the
-           feature 'arbitrary-names' is advertised.
-
-           This leaf MAY be mapped to ifName by an implementation.
-           Such an implementation MAY restrict the allowed values for
-           this leaf so that it matches the restrictions of ifName.
-           If a NETCONF server that implements this restriction is
-           sent a value that doesn't match the restriction, it MUST
-           reply with an rpc-error with the error-tag
-           'invalid-value'.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifName";
-      }
-
-      leaf description {
-        type string;
-        description
-          "A textual description of the interface.
-
-           This leaf MAY be mapped to ifAlias by an implementation.
-           Such an implementation MAY restrict the allowed values for
-           this leaf so that it matches the restrictions of ifAlias.
-           If a NETCONF server that implements this restriction is
-           sent a value that doesn't match the restriction, it MUST
-           reply with an rpc-error with the error-tag
-           'invalid-value'.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifAlias";
-      }
-
-      leaf type {
-        type ianaift:iana-if-type;
-        mandatory true;
-        description
-          "The type of the interface.
-
-           When an interface entry is created, a server MAY
-           initialize the type leaf with a valid value, e.g., if it
-           is possible to derive the type from the name of the
-           interface.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifType";
-      }
-
-      leaf location {
-        type string;
-        description
-          "The device-specific location of the interface of a
-           particular type.  The format of the location string
-           depends on the interface type and the device.
-
-           If the interface's type represents a physical interface,
-           this leaf MUST be set.
-
-           When an interface entry is created, a server MAY
-           initialize the location leaf with a valid value, e.g., if
-           it is possible to derive the location from the name of
-           the interface.";
-      }
-
-      leaf enabled {
-        type boolean;
-        default "true";
-        description
-          "The desired state of the interface.
-
-           This leaf contains the configured, desired state of the
-           interface.  Systems that implement the IF-MIB use the
-           value of this leaf to set IF-MIB.ifAdminStatus to 'up' or
-           'down' after an ifEntry has been initialized, as described
-           in RFC 2863.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifAdminStatus";
-      }
-
-      leaf oper-status {
-        type enumeration {
-          enum up {
-            value 1;
-            description
-              "Ready to pass packets.";
-          }
-          enum down {
-            value 2;
-            description
-              "The interface does not pass any packets.";
-          }
-          enum testing {
-            value 3;
-            description
-              "In some test mode.  No operational packets can
-               be passed.";
-          }
-          enum unknown {
-            value 4;
-            description
-              "Status cannot be determined for some reason.";
-          }
-          enum dormant {
-            value 5;
-            description
-              "Waiting for some external event.";
-          }
-          enum not-present {
-            value 6;
-            description
-              "Some component is missing.";
-          }
-          enum lower-layer-down {
-            value 7;
-            description
-              "Down due to state of lower-layer interface(s).";
-          }
-        }
-        config false;
-        description
-          "The current operational state of the interface.
-
-           If 'enabled' is 'false' then 'oper-status'
-           should be 'down'.  If 'enabled' is changed to 'true'
-           then 'oper-status' should change to 'up' if the interface
-           is ready to transmit and receive network traffic; it
-           should change to 'dormant' if the interface is waiting for
-           external actions (such as a serial line waiting for an
-           incoming connection); it should remain in the 'down' state
-           if and only if there is a fault that prevents it from
-           going to the 'up' state; it should remain in the
-           'not-present' state if the interface has missing
-           (typically, hardware) components.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifOperStatus";
-      }
-
-      leaf last-change {
-        type yang:date-and-time;
-        config false;
-        description
-          "The time the interface entered its current operational
-           state.  If the current state was entered prior to the
-           last re-initialization of the local network management
-           subsystem, then this node is not present.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifLastChange";
-      }
-
-      leaf if-index {
-        if-feature if-mib;
-        type int32 {
-          range "1..2147483647";
-        }
-        config false;
-        description
-          "The ifIndex value for the ifEntry represented by this
-           interface.
-
-           Media-specific modules must specify how the type is
-           mapped to entries in the ifTable.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifIndex";
-      }
-
-      leaf link-up-down-trap-enable {
-        if-feature if-mib;
-        type enumeration {
-          enum enabled {
-            value 1;
-          }
-          enum disabled {
-            value 2;
-          }
-        }
-        description
-          "Indicates whether linkUp/linkDown SNMP notifications
-           should be generated for this interface.
-           If this node is not configured, the value 'enabled' is
-           operationally used by the server for interfaces which do
-           not operate on top of any other interface (i.e., there are
-           no 'lower-layer-if' entries), and 'disabled' otherwise.";
-        reference
-          "RFC 2863: The Interfaces Group MIB -
-                     ifLinkUpDownTrapEnable";
-      }
-
-      leaf phys-address {
-        type yang:phys-address;
-        config false;
-        description
-          "The interface's address at its protocol sub-layer.  For
-          example, for an 802.x interface, this object normally
-          contains a MAC address.  The interface's media-specific
-          modules must define the bit and byte ordering and the
-          format of the value of this object.  For interfaces that do
-          not have such an address (e.g., a serial line), this node
-          is not present.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifPhysAddress";
       }
 
       leaf-list higher-layer-if {
         type interface-ref;
         config false;
-        description
-          "A list of references to interfaces layered on top of this
-           interface.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifStackTable";
-      }
-
-      leaf-list lower-layer-if {
-        type interface-ref;
-        config false;
-        description
-          "A list of references to interfaces layered underneath this
-           interface.";
-        reference
-          "RFC 2863: The Interfaces Group MIB - ifStackTable";
       }
 
-      leaf speed {
-        type yang:gauge64;
-        units "bits / second";
-        config false;
-        description
-            "An estimate of the interface's current bandwidth in bits
-             per second.  For interfaces which do not vary in
-             bandwidth or for those where no accurate estimation can
-             be made, this node should contain the nominal bandwidth.
-             For interfaces that has no concept of bandwidth, this
-             node is not present.";
-        reference
-          "RFC 2863: The Interfaces Group MIB -
-                     ifSpeed, ifHighSpeed";
-      }
-
-      container statistics {
-        config false;
-        description
-          "A collection of interface-related statistics objects.";
-
-        leaf discontinuity-time {
-          type yang:date-and-time;
-          description
-            "The time on the most recent occasion at which any one or
-             more of this interface's counters suffered a
-             discontinuity.  If no such discontinuities have occurred
-             since the last re-initialization of the local management
-             subsystem, then this node contains the time the local
-             management subsystem re-initialized itself.";
-        }
-
-        leaf in-octets {
-          type yang:counter64;
-          description
-            "The total number of octets received on the interface,
-             including framing characters.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifHCInOctets";
-        }
-        leaf in-unicast-pkts {
-          type yang:counter64;
-          description
-            "The number of packets, delivered by this sub-layer to a
-             higher (sub-)layer, which were not addressed to a
-             multicast or broadcast address at this sub-layer.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifHCInUcastPkts";
-        }
-        leaf in-broadcast-pkts {
-          type yang:counter64;
-          description
-            "The number of packets, delivered by this sub-layer to a
-             higher (sub-)layer, which were addressed to a broadcast
-             address at this sub-layer.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB -
-                       ifHCInBroadcastPkts";
-        }
-        leaf in-multicast-pkts {
-          type yang:counter64;
-          description
-            "The number of packets, delivered by this sub-layer to a
-             higher (sub-)layer, which were addressed to a multicast
-             address at this sub-layer.  For a MAC layer protocol,
-             this includes both Group and Functional addresses.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB -
-                       ifHCInMulticastPkts";
-        }
-        leaf in-discards {
-          type yang:counter32;
-          description
-            "The number of inbound packets which were chosen to be
-             discarded even though no errors had been detected to
-             prevent their being deliverable to a higher-layer
-             protocol.  One possible reason for discarding such a
-             packet could be to free up buffer space.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifInDiscards";
-        }
-        leaf in-errors {
-          type yang:counter32;
-          description
-            "For packet-oriented interfaces, the number of inbound
-             packets that contained errors preventing them from being
-             deliverable to a higher-layer protocol.  For character-
-             oriented or fixed-length interfaces, the number of
-             inbound transmission units that contained errors
-             preventing them from being deliverable to a higher-layer
-             protocol.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifInErrors";
-        }
-        leaf in-unknown-protos {
-          type yang:counter32;
-          description
-            "For packet-oriented interfaces, the number of packets
-             received via the interface which were discarded because
-             of an unknown or unsupported protocol.  For
-             character-oriented or fixed-length interfaces that
-             support protocol multiplexing the number of transmission
-             units received via the interface which were discarded
-             because of an unknown or unsupported protocol.  For any
-             interface that does not support protocol multiplexing,
-             this counter is not present.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifInUnknownProtos";
-        }
-
-        leaf out-octets {
-          type yang:counter64;
-          description
-            "The total number of octets transmitted out of the
-             interface, including framing characters.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifHCOutOctets";
-        }
-        leaf out-unicast-pkts {
-          type yang:counter64;
-          description
-            "The total number of packets that higher-level protocols
-             requested be transmitted, and which were not addressed
-             to a multicast or broadcast address at this sub-layer,
-             including those that were discarded or not sent.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifHCOutUcastPkts";
-        }
-        leaf out-broadcast-pkts {
-          type yang:counter64;
-          description
-            "The total number of packets that higher-level protocols
-             requested be transmitted, and which were addressed to a
-             broadcast address at this sub-layer, including those
-             that were discarded or not sent.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB -
-                       ifHCOutBroadcastPkts";
-        }
-        leaf out-multicast-pkts {
-          type yang:counter64;
-          description
-            "The total number of packets that higher-level protocols
-             requested be transmitted, and which were addressed to a
-             multicast address at this sub-layer, including those
-             that were discarded or not sent.  For a MAC layer
-             protocol, this includes both Group and Functional
-             addresses.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB -
-                       ifHCOutMulticastPkts";
-        }
-        leaf out-discards {
-          type yang:counter32;
-          description
-            "The number of outbound packets which were chosen to be
-             discarded even though no errors had been detected to
-             prevent their being transmitted.  One possible reason
-             for discarding such a packet could be to free up buffer
-             space.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifOutDiscards";
-        }
-        leaf out-errors {
-          type yang:counter32;
-          description
-            "For packet-oriented interfaces, the number of outbound
-             packets that could not be transmitted because of errors.
-             For character-oriented or fixed-length interfaces, the
-             number of outbound transmission units that could not be
-             transmitted because of errors.
-
-             Discontinuities in the value of this counter can occur
-             at re-initialization of the management system, and at
-             other times as indicated by the value of
-             'discontinuity-time'.";
-          reference
-            "RFC 2863: The Interfaces Group MIB - ifOutErrors";
-        }
-      }
     }
   }
-}
\ No newline at end of file
+}
diff --git a/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-yang-types@2010-09-24.yang b/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-yang-types@2010-09-24.yang
deleted file mode 100644 (file)
index e9d88ab..0000000
+++ /dev/null
@@ -1,396 +0,0 @@
- module ietf-yang-types {
-
-   namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
-   prefix "yang";
-
-   organization
-    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
-   contact
-    "WG Web:   <http://tools.ietf.org/wg/netmod/>
-     WG List:  <mailto:netmod@ietf.org>
-
-     WG Chair: David Partain
-               <mailto:david.partain@ericsson.com>
-
-     WG Chair: David Kessens
-               <mailto:david.kessens@nsn.com>
-
-     Editor:   Juergen Schoenwaelder
-               <mailto:j.schoenwaelder@jacobs-university.de>";
-
-   description
-    "This module contains a collection of generally useful derived
-     YANG data types.
-
-     Copyright (c) 2010 IETF Trust and the persons identified as
-     authors of the code.  All rights reserved.
-
-     Redistribution and use in source and binary forms, with or without
-     modification, is permitted pursuant to, and subject to the license
-     terms contained in, the Simplified BSD License set forth in Section
-     4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
-     (http://trustee.ietf.org/license-info).
-
-     This version of this YANG module is part of RFC 6021; see
-     the RFC itself for full legal notices.";
-
-   revision 2010-09-24 {
-     description
-      "Initial revision.";
-     reference
-      "RFC 6021: Common YANG Data Types";
-   }
-
-   /*** collection of counter and gauge types ***/
-
-   typedef counter32 {
-     type uint32;
-     description
-      "The counter32 type represents a non-negative integer
-       that monotonically increases until it reaches a
-       maximum value of 2^32-1 (4294967295 decimal), when it
-       wraps around and starts increasing again from zero.
-
-       Counters have no defined 'initial' value, and thus, a
-       single value of a counter has (in general) no information
-       content.  Discontinuities in the monotonically increasing
-       value normally occur at re-initialization of the
-       management system, and at other times as specified in the
-       description of a schema node using this type.  If such
-       other times can occur, for example, the creation of
-       a schema node of type counter32 at times other than
-       re-initialization, then a corresponding schema node
-       should be defined, with an appropriate type, to indicate
-       the last discontinuity.
-
-       The counter32 type should not be used for configuration
-       schema nodes.  A default statement SHOULD NOT be used in
-       combination with the type counter32.
-
-       In the value set and its semantics, this type is equivalent
-       to the Counter32 type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef zero-based-counter32 {
-     type yang:counter32;
-     default "0";
-     description
-      "The zero-based-counter32 type represents a counter32
-       that has the defined 'initial' value zero.
-
-       A schema node of this type will be set to zero (0) on creation
-       and will thereafter increase monotonically until it reaches
-       a maximum value of 2^32-1 (4294967295 decimal), when it
-       wraps around and starts increasing again from zero.
-
-       Provided that an application discovers a new schema node
-       of this type within the minimum time to wrap, it can use the
-       'initial' value as a delta.  It is important for a management
-       station to be aware of this minimum time and the actual time
-       between polls, and to discard data if the actual time is too
-       long or there is no defined minimum time.
-
-       In the value set and its semantics, this type is equivalent
-       to the ZeroBasedCounter32 textual convention of the SMIv2.";
-     reference
-       "RFC 4502: Remote Network Monitoring Management Information
-                  Base Version 2";
-   }
-
-   typedef counter64 {
-     type uint64;
-     description
-      "The counter64 type represents a non-negative integer
-       that monotonically increases until it reaches a
-       maximum value of 2^64-1 (18446744073709551615 decimal),
-       when it wraps around and starts increasing again from zero.
-
-       Counters have no defined 'initial' value, and thus, a
-       single value of a counter has (in general) no information
-       content.  Discontinuities in the monotonically increasing
-       value normally occur at re-initialization of the
-       management system, and at other times as specified in the
-       description of a schema node using this type.  If such
-       other times can occur, for example, the creation of
-       a schema node of type counter64 at times other than
-       re-initialization, then a corresponding schema node
-       should be defined, with an appropriate type, to indicate
-       the last discontinuity.
-
-       The counter64 type should not be used for configuration
-       schema nodes.  A default statement SHOULD NOT be used in
-       combination with the type counter64.
-
-       In the value set and its semantics, this type is equivalent
-       to the Counter64 type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef zero-based-counter64 {
-     type yang:counter64;
-     default "0";
-     description
-      "The zero-based-counter64 type represents a counter64 that
-       has the defined 'initial' value zero.
-
-       A schema node of this type will be set to zero (0) on creation
-       and will thereafter increase monotonically until it reaches
-       a maximum value of 2^64-1 (18446744073709551615 decimal),
-       when it wraps around and starts increasing again from zero.
-
-       Provided that an application discovers a new schema node
-       of this type within the minimum time to wrap, it can use the
-       'initial' value as a delta.  It is important for a management
-       station to be aware of this minimum time and the actual time
-       between polls, and to discard data if the actual time is too
-       long or there is no defined minimum time.
-
-       In the value set and its semantics, this type is equivalent
-       to the ZeroBasedCounter64 textual convention of the SMIv2.";
-     reference
-      "RFC 2856: Textual Conventions for Additional High Capacity
-                 Data Types";
-   }
-
-   typedef gauge32 {
-     type uint32;
-     description
-      "The gauge32 type represents a non-negative integer, which
-       may increase or decrease, but shall never exceed a maximum
-       value, nor fall below a minimum value.  The maximum value
-       cannot be greater than 2^32-1 (4294967295 decimal), and
-       the minimum value cannot be smaller than 0.  The value of
-       a gauge32 has its maximum value whenever the information
-       being modeled is greater than or equal to its maximum
-       value, and has its minimum value whenever the information
-       being modeled is smaller than or equal to its minimum value.
-       If the information being modeled subsequently decreases
-       below (increases above) the maximum (minimum) value, the
-       gauge32 also decreases (increases).
-
-       In the value set and its semantics, this type is equivalent
-       to the Gauge32 type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef gauge64 {
-     type uint64;
-     description
-      "The gauge64 type represents a non-negative integer, which
-       may increase or decrease, but shall never exceed a maximum
-       value, nor fall below a minimum value.  The maximum value
-       cannot be greater than 2^64-1 (18446744073709551615), and
-       the minimum value cannot be smaller than 0.  The value of
-       a gauge64 has its maximum value whenever the information
-       being modeled is greater than or equal to its maximum
-       value, and has its minimum value whenever the information
-       being modeled is smaller than or equal to its minimum value.
-       If the information being modeled subsequently decreases
-       below (increases above) the maximum (minimum) value, the
-       gauge64 also decreases (increases).
-
-       In the value set and its semantics, this type is equivalent
-       to the CounterBasedGauge64 SMIv2 textual convention defined
-       in RFC 2856";
-     reference
-      "RFC 2856: Textual Conventions for Additional High Capacity
-                 Data Types";
-   }
-
-   /*** collection of identifier related types ***/
-
-   typedef object-identifier {
-     type string {
-       pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))'
-             + '(\.(0|([1-9]\d*)))*';
-     }
-     description
-      "The object-identifier type represents administratively
-       assigned names in a registration-hierarchical-name tree.
-
-       Values of this type are denoted as a sequence of numerical
-       non-negative sub-identifier values.  Each sub-identifier
-       value MUST NOT exceed 2^32-1 (4294967295).  Sub-identifiers
-       are separated by single dots and without any intermediate
-       whitespace.
-
-       The ASN.1 standard restricts the value space of the first
-       sub-identifier to 0, 1, or 2.  Furthermore, the value space
-       of the second sub-identifier is restricted to the range
-       0 to 39 if the first sub-identifier is 0 or 1.  Finally,
-       the ASN.1 standard requires that an object identifier
-       has always at least two sub-identifier.  The pattern
-       captures these restrictions.
-
-       Although the number of sub-identifiers is not limited,
-       module designers should realize that there may be
-       implementations that stick with the SMIv2 limit of 128
-       sub-identifiers.
-
-       This type is a superset of the SMIv2 OBJECT IDENTIFIER type
-       since it is not restricted to 128 sub-identifiers.  Hence,
-       this type SHOULD NOT be used to represent the SMIv2 OBJECT
-       IDENTIFIER type, the object-identifier-128 type SHOULD be
-       used instead.";
-     reference
-      "ISO9834-1: Information technology -- Open Systems
-       Interconnection -- Procedures for the operation of OSI
-       Registration Authorities: General procedures and top
-       arcs of the ASN.1 Object Identifier tree";
-   }
-
-
-
-
-   typedef object-identifier-128 {
-     type object-identifier {
-       pattern '\d*(\.\d*){1,127}';
-     }
-     description
-      "This type represents object-identifiers restricted to 128
-       sub-identifiers.
-
-       In the value set and its semantics, this type is equivalent
-       to the OBJECT IDENTIFIER type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   /*** collection of date and time related types ***/
-
-   typedef date-and-time {
-     type string {
-       pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
-             + '(Z|[\+\-]\d{2}:\d{2})';
-     }
-     description
-      "The date-and-time type is a profile of the ISO 8601
-       standard for representation of dates and times using the
-       Gregorian calendar.  The profile is defined by the
-       date-time production in Section 5.6 of RFC 3339.
-
-       The date-and-time type is compatible with the dateTime XML
-       schema type with the following notable exceptions:
-
-       (a) The date-and-time type does not allow negative years.
-
-       (b) The date-and-time time-offset -00:00 indicates an unknown
-           time zone (see RFC 3339) while -00:00 and +00:00 and Z all
-           represent the same time zone in dateTime.
-
-       (c) The canonical format (see below) of data-and-time values
-           differs from the canonical format used by the dateTime XML
-           schema type, which requires all times to be in UTC using the
-           time-offset 'Z'.
-
-       This type is not equivalent to the DateAndTime textual
-       convention of the SMIv2 since RFC 3339 uses a different
-       separator between full-date and full-time and provides
-       higher resolution of time-secfrac.
-
-       The canonical format for date-and-time values with a known time
-       zone uses a numeric time zone offset that is calculated using
-       the device's configured known offset to UTC time.  A change of
-       the device's offset to UTC time will cause date-and-time values
-       to change accordingly.  Such changes might happen periodically
-       in case a server follows automatically daylight saving time
-       (DST) time zone offset changes.  The canonical format for
-       date-and-time values with an unknown time zone (usually referring
-       to the notion of local time) uses the time-offset -00:00.";
-     reference
-      "RFC 3339: Date and Time on the Internet: Timestamps
-       RFC 2579: Textual Conventions for SMIv2
-       XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
-   }
-
-   typedef timeticks {
-     type uint32;
-     description
-      "The timeticks type represents a non-negative integer that
-       represents the time, modulo 2^32 (4294967296 decimal), in
-       hundredths of a second between two epochs.  When a schema
-       node is defined that uses this type, the description of
-       the schema node identifies both of the reference epochs.
-
-       In the value set and its semantics, this type is equivalent
-       to the TimeTicks type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef timestamp {
-     type yang:timeticks;
-     description
-      "The timestamp type represents the value of an associated
-       timeticks schema node at which a specific occurrence happened.
-       The specific occurrence must be defined in the description
-       of any schema node defined using this type.  When the specific
-       occurrence occurred prior to the last time the associated
-       timeticks attribute was zero, then the timestamp value is
-       zero.  Note that this requires all timestamp values to be
-       reset to zero when the value of the associated timeticks
-       attribute reaches 497+ days and wraps around to zero.
-
-       The associated timeticks schema node must be specified
-       in the description of any schema node using this type.
-
-       In the value set and its semantics, this type is equivalent
-       to the TimeStamp textual convention of the SMIv2.";
-     reference
-      "RFC 2579: Textual Conventions for SMIv2";
-   }
-
-   /*** collection of generic address types ***/
-
-   typedef phys-address {
-     type string {
-       pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
-     }
-     description
-      "Represents media- or physical-level addresses represented
-       as a sequence octets, each octet represented by two hexadecimal
-       numbers.  Octets are separated by colons.  The canonical
-       representation uses lowercase characters.
-
-       In the value set and its semantics, this type is equivalent
-       to the PhysAddress textual convention of the SMIv2.";
-     reference
-      "RFC 2579: Textual Conventions for SMIv2";
-   }
-
-   typedef mac-address {
-     type string {
-       pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
-     }
-     description
-      "The mac-address type represents an IEEE 802 MAC address.
-       The canonical representation uses lowercase characters.
-
-       In the value set and its semantics, this type is equivalent
-       to the MacAddress textual convention of the SMIv2.";
-     reference
-      "IEEE 802: IEEE Standard for Local and Metropolitan Area
-                 Networks: Overview and Architecture
-       RFC 2579: Textual Conventions for SMIv2";
-   }
-
-   /*** collection of XML specific types ***/
-
-   typedef xpath1.0 {
-     type string;
-     description
-      "This type represents an XPATH 1.0 expression.
-
-       When a schema node is defined that uses this type, the
-       description of the schema node MUST specify the XPath
-       context in which the XPath expression is evaluated.";
-     reference
-      "XPATH: XML Path Language (XPath) Version 1.0";
-   }
-
- }
\ No newline at end of file
index 2362783edd21b3680161389e3ef529ebabdf8bbf..230b329c59698b7349d4fc3ca43e127ca587c5d3 100644 (file)
@@ -3,17 +3,7 @@ module choice-monitoring {
   namespace "urn:ietf:params:xml:ns:yang:choice-monitoring";
   prefix "ncm";
 
-  import ietf-yang-types { prefix yang; }
-  import ietf-inet-types { prefix inet; }
-
-  organization "OPEN DAYLIGHT";
-  contact "http://www.opendaylight.org/";
-
-  description
-    "Test model for testing of resolving choice, case nodes and generation types from them.";
-
   revision 2013-07-01 {
-
   }
 
   typedef tls-fingerprint-type {
@@ -52,13 +42,13 @@ module choice-monitoring {
                 }
 
                 leaf locked-time {
-                  type yang:date-and-time;
+                  type string;
                   mandatory true;
                 }
 
                 container capabilities {
                   leaf-list capability {
-                      type inet:uri;
+                      type string;
                   }
                 }
               }
@@ -72,7 +62,7 @@ module choice-monitoring {
                     type uint32;
                   }
                   leaf-list select {
-                    type yang:xpath1.0;
+                    type string;
                     min-elements 1;
                   }
                   leaf-list locked-node {
diff --git a/code-generator/binding-generator-impl/src/test/resources/choice-case-type-test-models/ietf-inet-types@2010-09-24.yang b/code-generator/binding-generator-impl/src/test/resources/choice-case-type-test-models/ietf-inet-types@2010-09-24.yang
deleted file mode 100644 (file)
index de20feb..0000000
+++ /dev/null
@@ -1,418 +0,0 @@
- module ietf-inet-types {
-
-   namespace "urn:ietf:params:xml:ns:yang:ietf-inet-types";
-   prefix "inet";
-
-   organization
-    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
-   contact
-    "WG Web:   <http://tools.ietf.org/wg/netmod/>
-     WG List:  <mailto:netmod@ietf.org>
-
-     WG Chair: David Partain
-               <mailto:david.partain@ericsson.com>
-
-     WG Chair: David Kessens
-               <mailto:david.kessens@nsn.com>
-
-     Editor:   Juergen Schoenwaelder
-               <mailto:j.schoenwaelder@jacobs-university.de>";
-
-   description
-    "This module contains a collection of generally useful derived
-     YANG data types for Internet addresses and related things.
-
-     Copyright (c) 2010 IETF Trust and the persons identified as
-     authors of the code.  All rights reserved.
-
-     Redistribution and use in source and binary forms, with or without
-     modification, is permitted pursuant to, and subject to the license
-     terms contained in, the Simplified BSD License set forth in Section
-     4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
-     (http://trustee.ietf.org/license-info).
-
-     This version of this YANG module is part of RFC 6021; see
-     the RFC itself for full legal notices.";
-
-   revision 2010-09-24 {
-     description
-      "Initial revision.";
-     reference
-      "RFC 6021: Common YANG Data Types";
-   }
-
-   /*** collection of protocol field related types ***/
-
-   typedef ip-version {
-     type enumeration {
-       enum unknown {
-         value "0";
-         description
-          "An unknown or unspecified version of the Internet protocol.";
-       }
-       enum ipv4 {
-         value "1";
-         description
-          "The IPv4 protocol as defined in RFC 791.";
-       }
-       enum ipv6 {
-         value "2";
-         description
-          "The IPv6 protocol as defined in RFC 2460.";
-       }
-     }
-     description
-      "This value represents the version of the IP protocol.
-
-       In the value set and its semantics, this type is equivalent
-       to the InetVersion textual convention of the SMIv2.";
-     reference
-      "RFC  791: Internet Protocol
-       RFC 2460: Internet Protocol, Version 6 (IPv6) Specification
-       RFC 4001: Textual Conventions for Internet Network Addresses";
-   }
-
-   typedef dscp {
-     type uint8 {
-       range "0..63";
-     }
-     description
-      "The dscp type represents a Differentiated Services Code-Point
-       that may be used for marking packets in a traffic stream.
-
-       In the value set and its semantics, this type is equivalent
-       to the Dscp textual convention of the SMIv2.";
-     reference
-      "RFC 3289: Management Information Base for the Differentiated
-                 Services Architecture
-       RFC 2474: Definition of the Differentiated Services Field
-                 (DS Field) in the IPv4 and IPv6 Headers
-       RFC 2780: IANA Allocation Guidelines For Values In
-                 the Internet Protocol and Related Headers";
-   }
-
-   typedef ipv6-flow-label {
-     type uint32 {
-       range "0..1048575";
-     }
-     description
-      "The flow-label type represents flow identifier or Flow Label
-       in an IPv6 packet header that may be used to discriminate
-       traffic flows.
-
-       In the value set and its semantics, this type is equivalent
-       to the IPv6FlowLabel textual convention of the SMIv2.";
-     reference
-      "RFC 3595: Textual Conventions for IPv6 Flow Label
-       RFC 2460: Internet Protocol, Version 6 (IPv6) Specification";
-   }
-
-   typedef port-number {
-     type uint16 {
-       range "0..65535";
-     }
-     description
-      "The port-number type represents a 16-bit port number of an
-       Internet transport layer protocol such as UDP, TCP, DCCP, or
-       SCTP.  Port numbers are assigned by IANA.  A current list of
-       all assignments is available from <http://www.iana.org/>.
-
-       Note that the port number value zero is reserved by IANA.  In
-       situations where the value zero does not make sense, it can
-       be excluded by subtyping the port-number type.
-
-       In the value set and its semantics, this type is equivalent
-       to the InetPortNumber textual convention of the SMIv2.";
-     reference
-      "RFC  768: User Datagram Protocol
-       RFC  793: Transmission Control Protocol
-       RFC 4960: Stream Control Transmission Protocol
-       RFC 4340: Datagram Congestion Control Protocol (DCCP)
-       RFC 4001: Textual Conventions for Internet Network Addresses";
-   }
-
-   /*** collection of autonomous system related types ***/
-
-   typedef as-number {
-     type uint32;
-     description
-      "The as-number type represents autonomous system numbers
-       which identify an Autonomous System (AS).  An AS is a set
-       of routers under a single technical administration, using
-       an interior gateway protocol and common metrics to route
-       packets within the AS, and using an exterior gateway
-       protocol to route packets to other ASs'.  IANA maintains
-       the AS number space and has delegated large parts to the
-       regional registries.
-
-       Autonomous system numbers were originally limited to 16
-       bits.  BGP extensions have enlarged the autonomous system
-       number space to 32 bits.  This type therefore uses an uint32
-       base type without a range restriction in order to support
-       a larger autonomous system number space.
-
-       In the value set and its semantics, this type is equivalent
-       to the InetAutonomousSystemNumber textual convention of
-       the SMIv2.";
-     reference
-      "RFC 1930: Guidelines for creation, selection, and registration
-                 of an Autonomous System (AS)
-       RFC 4271: A Border Gateway Protocol 4 (BGP-4)
-       RFC 4893: BGP Support for Four-octet AS Number Space
-       RFC 4001: Textual Conventions for Internet Network Addresses";
-   }
-
-   /*** collection of IP address and hostname related types ***/
-
-   typedef ip-address {
-     type union {
-       type inet:ipv4-address;
-       type inet:ipv6-address;
-     }
-     description
-      "The ip-address type represents an IP address and is IP
-       version neutral.  The format of the textual representations
-       implies the IP version.";
-   }
-
-   typedef ipv4-address {
-     type string {
-       pattern
-         '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
-       +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
-       + '(%[\p{N}\p{L}]+)?';
-     }
-     description
-       "The ipv4-address type represents an IPv4 address in
-        dotted-quad notation.  The IPv4 address may include a zone
-        index, separated by a % sign.
-
-        The zone index is used to disambiguate identical address
-        values.  For link-local addresses, the zone index will
-        typically be the interface index number or the name of an
-        interface.  If the zone index is not present, the default
-        zone of the device will be used.
-
-        The canonical format for the zone index is the numerical
-        format";
-   }
-
-   typedef ipv6-address {
-     type string {
-       pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
-             + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
-             + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
-             + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
-             + '(%[\p{N}\p{L}]+)?';
-       pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
-             + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
-             + '(%.+)?';
-     }
-     description
-      "The ipv6-address type represents an IPv6 address in full,
-       mixed, shortened, and shortened-mixed notation.  The IPv6
-       address may include a zone index, separated by a % sign.
-
-       The zone index is used to disambiguate identical address
-       values.  For link-local addresses, the zone index will
-       typically be the interface index number or the name of an
-       interface.  If the zone index is not present, the default
-       zone of the device will be used.
-
-       The canonical format of IPv6 addresses uses the compressed
-       format described in RFC 4291, Section 2.2, item 2 with the
-       following additional rules: the :: substitution must be
-       applied to the longest sequence of all-zero 16-bit chunks
-       in an IPv6 address.  If there is a tie, the first sequence
-       of all-zero 16-bit chunks is replaced by ::.  Single
-       all-zero 16-bit chunks are not compressed.  The canonical
-       format uses lowercase characters and leading zeros are
-       not allowed.  The canonical format for the zone index is
-       the numerical format as described in RFC 4007, Section
-       11.2.";
-     reference
-      "RFC 4291: IP Version 6 Addressing Architecture
-       RFC 4007: IPv6 Scoped Address Architecture
-       RFC 5952: A Recommendation for IPv6 Address Text Representation";
-   }
-
-   typedef ip-prefix {
-     type union {
-       type inet:ipv4-prefix;
-       type inet:ipv6-prefix;
-     }
-     description
-      "The ip-prefix type represents an IP prefix and is IP
-       version neutral.  The format of the textual representations
-       implies the IP version.";
-   }
-
-   typedef ipv4-prefix {
-     type string {
-       pattern
-          '(([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])\.){3}'
-        +  '([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'
-        + '/(([0-9])|([1-2][0-9])|(3[0-2]))';
-     }
-     description
-      "The ipv4-prefix type represents an IPv4 address prefix.
-       The prefix length is given by the number following the
-       slash character and must be less than or equal to 32.
-
-       A prefix length value of n corresponds to an IP address
-       mask that has n contiguous 1-bits from the most
-       significant bit (MSB) and all other bits set to 0.
-
-       The canonical format of an IPv4 prefix has all bits of
-       the IPv4 address set to zero that are not part of the
-       IPv4 prefix.";
-   }
-
-   typedef ipv6-prefix {
-     type string {
-       pattern '((:|[0-9a-fA-F]{0,4}):)([0-9a-fA-F]{0,4}:){0,5}'
-             + '((([0-9a-fA-F]{0,4}:)?(:|[0-9a-fA-F]{0,4}))|'
-             + '(((25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])\.){3}'
-             + '(25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])))'
-             + '(/(([0-9])|([0-9]{2})|(1[0-1][0-9])|(12[0-8])))';
-       pattern '(([^:]+:){6}(([^:]+:[^:]+)|(.*\..*)))|'
-             + '((([^:]+:)*[^:]+)?::(([^:]+:)*[^:]+)?)'
-             + '(/.+)';
-     }
-     description
-      "The ipv6-prefix type represents an IPv6 address prefix.
-       The prefix length is given by the number following the
-       slash character and must be less than or equal 128.
-
-       A prefix length value of n corresponds to an IP address
-       mask that has n contiguous 1-bits from the most
-       significant bit (MSB) and all other bits set to 0.
-
-       The IPv6 address should have all bits that do not belong
-       to the prefix set to zero.
-
-       The canonical format of an IPv6 prefix has all bits of
-       the IPv6 address set to zero that are not part of the
-       IPv6 prefix.  Furthermore, IPv6 address is represented
-       in the compressed format described in RFC 4291, Section
-       2.2, item 2 with the following additional rules: the ::
-       substitution must be applied to the longest sequence of
-       all-zero 16-bit chunks in an IPv6 address.  If there is
-       a tie, the first sequence of all-zero 16-bit chunks is
-       replaced by ::.  Single all-zero 16-bit chunks are not
-       compressed.  The canonical format uses lowercase
-       characters and leading zeros are not allowed.";
-     reference
-      "RFC 4291: IP Version 6 Addressing Architecture";
-   }
-
-   /*** collection of domain name and URI types ***/
-
-   typedef domain-name {
-     type string {
-       pattern '((([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.)*'
-            +  '([a-zA-Z0-9_]([a-zA-Z0-9\-_]){0,61})?[a-zA-Z0-9]\.?)'
-            +  '|\.';
-       length "1..253";
-     }
-     description
-      "The domain-name type represents a DNS domain name.  The
-       name SHOULD be fully qualified whenever possible.
-
-       Internet domain names are only loosely specified.  Section
-       3.5 of RFC 1034 recommends a syntax (modified in Section
-       2.1 of RFC 1123).  The pattern above is intended to allow
-       for current practice in domain name use, and some possible
-       future expansion.  It is designed to hold various types of
-       domain names, including names used for A or AAAA records
-       (host names) and other records, such as SRV records.  Note
-       that Internet host names have a stricter syntax (described
-       in RFC 952) than the DNS recommendations in RFCs 1034 and
-       1123, and that systems that want to store host names in
-       schema nodes using the domain-name type are recommended to
-       adhere to this stricter standard to ensure interoperability.
-
-       The encoding of DNS names in the DNS protocol is limited
-       to 255 characters.  Since the encoding consists of labels
-       prefixed by a length bytes and there is a trailing NULL
-       byte, only 253 characters can appear in the textual dotted
-       notation.
-
-       The description clause of schema nodes using the domain-name
-       type MUST describe when and how these names are resolved to
-       IP addresses.  Note that the resolution of a domain-name value
-       may require to query multiple DNS records (e.g., A for IPv4
-       and AAAA for IPv6).  The order of the resolution process and
-       which DNS record takes precedence can either be defined
-       explicitely or it may depend on the configuration of the
-       resolver.
-
-       Domain-name values use the US-ASCII encoding.  Their canonical
-       format uses lowercase US-ASCII characters.  Internationalized
-       domain names MUST be encoded in punycode as described in RFC
-       3492";
-     reference
-      "RFC  952: DoD Internet Host Table Specification
-       RFC 1034: Domain Names - Concepts and Facilities
-       RFC 1123: Requirements for Internet Hosts -- Application
-                 and Support
-       RFC 2782: A DNS RR for specifying the location of services
-                 (DNS SRV)
-       RFC 3492: Punycode: A Bootstring encoding of Unicode for
-                 Internationalized Domain Names in Applications
-                 (IDNA)
-       RFC 5891: Internationalizing Domain Names in Applications
-                 (IDNA): Protocol";
-   }
-
-   typedef host {
-     type union {
-       type inet:ip-address;
-       type inet:domain-name;
-     }
-     description
-      "The host type represents either an IP address or a DNS
-       domain name.";
-   }
-
-   typedef uri {
-     type string;
-     description
-      "The uri type represents a Uniform Resource Identifier
-       (URI) as defined by STD 66.
-
-       Objects using the uri type MUST be in US-ASCII encoding,
-       and MUST be normalized as described by RFC 3986 Sections
-       6.2.1, 6.2.2.1, and 6.2.2.2.  All unnecessary
-       percent-encoding is removed, and all case-insensitive
-       characters are set to lowercase except for hexadecimal
-       digits, which are normalized to uppercase as described in
-       Section 6.2.2.1.
-
-       The purpose of this normalization is to help provide
-       unique URIs.  Note that this normalization is not
-       sufficient to provide uniqueness.  Two URIs that are
-       textually distinct after this normalization may still be
-       equivalent.
-
-       Objects using the uri type may restrict the schemes that
-       they permit.  For example, 'data:' and 'urn:' schemes
-       might not be appropriate.
-
-       A zero-length URI is not a valid URI.  This can be used to
-       express 'URI absent' where required.
-
-       In the value set and its semantics, this type is equivalent
-       to the Uri SMIv2 textual convention defined in RFC 5017.";
-     reference
-      "RFC 3986: Uniform Resource Identifier (URI): Generic Syntax
-       RFC 3305: Report from the Joint W3C/IETF URI Planning Interest
-                 Group: Uniform Resource Identifiers (URIs), URLs,
-                 and Uniform Resource Names (URNs): Clarifications
-                 and Recommendations
-       RFC 5017: MIB Textual Conventions for Uniform Resource
-                 Identifiers (URIs)";
-   }
-
- }
diff --git a/code-generator/binding-generator-impl/src/test/resources/choice-case-type-test-models/ietf-yang-types@2010-09-24.yang b/code-generator/binding-generator-impl/src/test/resources/choice-case-type-test-models/ietf-yang-types@2010-09-24.yang
deleted file mode 100644 (file)
index e9d88ab..0000000
+++ /dev/null
@@ -1,396 +0,0 @@
- module ietf-yang-types {
-
-   namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
-   prefix "yang";
-
-   organization
-    "IETF NETMOD (NETCONF Data Modeling Language) Working Group";
-
-   contact
-    "WG Web:   <http://tools.ietf.org/wg/netmod/>
-     WG List:  <mailto:netmod@ietf.org>
-
-     WG Chair: David Partain
-               <mailto:david.partain@ericsson.com>
-
-     WG Chair: David Kessens
-               <mailto:david.kessens@nsn.com>
-
-     Editor:   Juergen Schoenwaelder
-               <mailto:j.schoenwaelder@jacobs-university.de>";
-
-   description
-    "This module contains a collection of generally useful derived
-     YANG data types.
-
-     Copyright (c) 2010 IETF Trust and the persons identified as
-     authors of the code.  All rights reserved.
-
-     Redistribution and use in source and binary forms, with or without
-     modification, is permitted pursuant to, and subject to the license
-     terms contained in, the Simplified BSD License set forth in Section
-     4.c of the IETF Trust's Legal Provisions Relating to IETF Documents
-     (http://trustee.ietf.org/license-info).
-
-     This version of this YANG module is part of RFC 6021; see
-     the RFC itself for full legal notices.";
-
-   revision 2010-09-24 {
-     description
-      "Initial revision.";
-     reference
-      "RFC 6021: Common YANG Data Types";
-   }
-
-   /*** collection of counter and gauge types ***/
-
-   typedef counter32 {
-     type uint32;
-     description
-      "The counter32 type represents a non-negative integer
-       that monotonically increases until it reaches a
-       maximum value of 2^32-1 (4294967295 decimal), when it
-       wraps around and starts increasing again from zero.
-
-       Counters have no defined 'initial' value, and thus, a
-       single value of a counter has (in general) no information
-       content.  Discontinuities in the monotonically increasing
-       value normally occur at re-initialization of the
-       management system, and at other times as specified in the
-       description of a schema node using this type.  If such
-       other times can occur, for example, the creation of
-       a schema node of type counter32 at times other than
-       re-initialization, then a corresponding schema node
-       should be defined, with an appropriate type, to indicate
-       the last discontinuity.
-
-       The counter32 type should not be used for configuration
-       schema nodes.  A default statement SHOULD NOT be used in
-       combination with the type counter32.
-
-       In the value set and its semantics, this type is equivalent
-       to the Counter32 type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef zero-based-counter32 {
-     type yang:counter32;
-     default "0";
-     description
-      "The zero-based-counter32 type represents a counter32
-       that has the defined 'initial' value zero.
-
-       A schema node of this type will be set to zero (0) on creation
-       and will thereafter increase monotonically until it reaches
-       a maximum value of 2^32-1 (4294967295 decimal), when it
-       wraps around and starts increasing again from zero.
-
-       Provided that an application discovers a new schema node
-       of this type within the minimum time to wrap, it can use the
-       'initial' value as a delta.  It is important for a management
-       station to be aware of this minimum time and the actual time
-       between polls, and to discard data if the actual time is too
-       long or there is no defined minimum time.
-
-       In the value set and its semantics, this type is equivalent
-       to the ZeroBasedCounter32 textual convention of the SMIv2.";
-     reference
-       "RFC 4502: Remote Network Monitoring Management Information
-                  Base Version 2";
-   }
-
-   typedef counter64 {
-     type uint64;
-     description
-      "The counter64 type represents a non-negative integer
-       that monotonically increases until it reaches a
-       maximum value of 2^64-1 (18446744073709551615 decimal),
-       when it wraps around and starts increasing again from zero.
-
-       Counters have no defined 'initial' value, and thus, a
-       single value of a counter has (in general) no information
-       content.  Discontinuities in the monotonically increasing
-       value normally occur at re-initialization of the
-       management system, and at other times as specified in the
-       description of a schema node using this type.  If such
-       other times can occur, for example, the creation of
-       a schema node of type counter64 at times other than
-       re-initialization, then a corresponding schema node
-       should be defined, with an appropriate type, to indicate
-       the last discontinuity.
-
-       The counter64 type should not be used for configuration
-       schema nodes.  A default statement SHOULD NOT be used in
-       combination with the type counter64.
-
-       In the value set and its semantics, this type is equivalent
-       to the Counter64 type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef zero-based-counter64 {
-     type yang:counter64;
-     default "0";
-     description
-      "The zero-based-counter64 type represents a counter64 that
-       has the defined 'initial' value zero.
-
-       A schema node of this type will be set to zero (0) on creation
-       and will thereafter increase monotonically until it reaches
-       a maximum value of 2^64-1 (18446744073709551615 decimal),
-       when it wraps around and starts increasing again from zero.
-
-       Provided that an application discovers a new schema node
-       of this type within the minimum time to wrap, it can use the
-       'initial' value as a delta.  It is important for a management
-       station to be aware of this minimum time and the actual time
-       between polls, and to discard data if the actual time is too
-       long or there is no defined minimum time.
-
-       In the value set and its semantics, this type is equivalent
-       to the ZeroBasedCounter64 textual convention of the SMIv2.";
-     reference
-      "RFC 2856: Textual Conventions for Additional High Capacity
-                 Data Types";
-   }
-
-   typedef gauge32 {
-     type uint32;
-     description
-      "The gauge32 type represents a non-negative integer, which
-       may increase or decrease, but shall never exceed a maximum
-       value, nor fall below a minimum value.  The maximum value
-       cannot be greater than 2^32-1 (4294967295 decimal), and
-       the minimum value cannot be smaller than 0.  The value of
-       a gauge32 has its maximum value whenever the information
-       being modeled is greater than or equal to its maximum
-       value, and has its minimum value whenever the information
-       being modeled is smaller than or equal to its minimum value.
-       If the information being modeled subsequently decreases
-       below (increases above) the maximum (minimum) value, the
-       gauge32 also decreases (increases).
-
-       In the value set and its semantics, this type is equivalent
-       to the Gauge32 type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef gauge64 {
-     type uint64;
-     description
-      "The gauge64 type represents a non-negative integer, which
-       may increase or decrease, but shall never exceed a maximum
-       value, nor fall below a minimum value.  The maximum value
-       cannot be greater than 2^64-1 (18446744073709551615), and
-       the minimum value cannot be smaller than 0.  The value of
-       a gauge64 has its maximum value whenever the information
-       being modeled is greater than or equal to its maximum
-       value, and has its minimum value whenever the information
-       being modeled is smaller than or equal to its minimum value.
-       If the information being modeled subsequently decreases
-       below (increases above) the maximum (minimum) value, the
-       gauge64 also decreases (increases).
-
-       In the value set and its semantics, this type is equivalent
-       to the CounterBasedGauge64 SMIv2 textual convention defined
-       in RFC 2856";
-     reference
-      "RFC 2856: Textual Conventions for Additional High Capacity
-                 Data Types";
-   }
-
-   /*** collection of identifier related types ***/
-
-   typedef object-identifier {
-     type string {
-       pattern '(([0-1](\.[1-3]?[0-9]))|(2\.(0|([1-9]\d*))))'
-             + '(\.(0|([1-9]\d*)))*';
-     }
-     description
-      "The object-identifier type represents administratively
-       assigned names in a registration-hierarchical-name tree.
-
-       Values of this type are denoted as a sequence of numerical
-       non-negative sub-identifier values.  Each sub-identifier
-       value MUST NOT exceed 2^32-1 (4294967295).  Sub-identifiers
-       are separated by single dots and without any intermediate
-       whitespace.
-
-       The ASN.1 standard restricts the value space of the first
-       sub-identifier to 0, 1, or 2.  Furthermore, the value space
-       of the second sub-identifier is restricted to the range
-       0 to 39 if the first sub-identifier is 0 or 1.  Finally,
-       the ASN.1 standard requires that an object identifier
-       has always at least two sub-identifier.  The pattern
-       captures these restrictions.
-
-       Although the number of sub-identifiers is not limited,
-       module designers should realize that there may be
-       implementations that stick with the SMIv2 limit of 128
-       sub-identifiers.
-
-       This type is a superset of the SMIv2 OBJECT IDENTIFIER type
-       since it is not restricted to 128 sub-identifiers.  Hence,
-       this type SHOULD NOT be used to represent the SMIv2 OBJECT
-       IDENTIFIER type, the object-identifier-128 type SHOULD be
-       used instead.";
-     reference
-      "ISO9834-1: Information technology -- Open Systems
-       Interconnection -- Procedures for the operation of OSI
-       Registration Authorities: General procedures and top
-       arcs of the ASN.1 Object Identifier tree";
-   }
-
-
-
-
-   typedef object-identifier-128 {
-     type object-identifier {
-       pattern '\d*(\.\d*){1,127}';
-     }
-     description
-      "This type represents object-identifiers restricted to 128
-       sub-identifiers.
-
-       In the value set and its semantics, this type is equivalent
-       to the OBJECT IDENTIFIER type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   /*** collection of date and time related types ***/
-
-   typedef date-and-time {
-     type string {
-       pattern '\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?'
-             + '(Z|[\+\-]\d{2}:\d{2})';
-     }
-     description
-      "The date-and-time type is a profile of the ISO 8601
-       standard for representation of dates and times using the
-       Gregorian calendar.  The profile is defined by the
-       date-time production in Section 5.6 of RFC 3339.
-
-       The date-and-time type is compatible with the dateTime XML
-       schema type with the following notable exceptions:
-
-       (a) The date-and-time type does not allow negative years.
-
-       (b) The date-and-time time-offset -00:00 indicates an unknown
-           time zone (see RFC 3339) while -00:00 and +00:00 and Z all
-           represent the same time zone in dateTime.
-
-       (c) The canonical format (see below) of data-and-time values
-           differs from the canonical format used by the dateTime XML
-           schema type, which requires all times to be in UTC using the
-           time-offset 'Z'.
-
-       This type is not equivalent to the DateAndTime textual
-       convention of the SMIv2 since RFC 3339 uses a different
-       separator between full-date and full-time and provides
-       higher resolution of time-secfrac.
-
-       The canonical format for date-and-time values with a known time
-       zone uses a numeric time zone offset that is calculated using
-       the device's configured known offset to UTC time.  A change of
-       the device's offset to UTC time will cause date-and-time values
-       to change accordingly.  Such changes might happen periodically
-       in case a server follows automatically daylight saving time
-       (DST) time zone offset changes.  The canonical format for
-       date-and-time values with an unknown time zone (usually referring
-       to the notion of local time) uses the time-offset -00:00.";
-     reference
-      "RFC 3339: Date and Time on the Internet: Timestamps
-       RFC 2579: Textual Conventions for SMIv2
-       XSD-TYPES: XML Schema Part 2: Datatypes Second Edition";
-   }
-
-   typedef timeticks {
-     type uint32;
-     description
-      "The timeticks type represents a non-negative integer that
-       represents the time, modulo 2^32 (4294967296 decimal), in
-       hundredths of a second between two epochs.  When a schema
-       node is defined that uses this type, the description of
-       the schema node identifies both of the reference epochs.
-
-       In the value set and its semantics, this type is equivalent
-       to the TimeTicks type of the SMIv2.";
-     reference
-      "RFC 2578: Structure of Management Information Version 2 (SMIv2)";
-   }
-
-   typedef timestamp {
-     type yang:timeticks;
-     description
-      "The timestamp type represents the value of an associated
-       timeticks schema node at which a specific occurrence happened.
-       The specific occurrence must be defined in the description
-       of any schema node defined using this type.  When the specific
-       occurrence occurred prior to the last time the associated
-       timeticks attribute was zero, then the timestamp value is
-       zero.  Note that this requires all timestamp values to be
-       reset to zero when the value of the associated timeticks
-       attribute reaches 497+ days and wraps around to zero.
-
-       The associated timeticks schema node must be specified
-       in the description of any schema node using this type.
-
-       In the value set and its semantics, this type is equivalent
-       to the TimeStamp textual convention of the SMIv2.";
-     reference
-      "RFC 2579: Textual Conventions for SMIv2";
-   }
-
-   /*** collection of generic address types ***/
-
-   typedef phys-address {
-     type string {
-       pattern '([0-9a-fA-F]{2}(:[0-9a-fA-F]{2})*)?';
-     }
-     description
-      "Represents media- or physical-level addresses represented
-       as a sequence octets, each octet represented by two hexadecimal
-       numbers.  Octets are separated by colons.  The canonical
-       representation uses lowercase characters.
-
-       In the value set and its semantics, this type is equivalent
-       to the PhysAddress textual convention of the SMIv2.";
-     reference
-      "RFC 2579: Textual Conventions for SMIv2";
-   }
-
-   typedef mac-address {
-     type string {
-       pattern '[0-9a-fA-F]{2}(:[0-9a-fA-F]{2}){5}';
-     }
-     description
-      "The mac-address type represents an IEEE 802 MAC address.
-       The canonical representation uses lowercase characters.
-
-       In the value set and its semantics, this type is equivalent
-       to the MacAddress textual convention of the SMIv2.";
-     reference
-      "IEEE 802: IEEE Standard for Local and Metropolitan Area
-                 Networks: Overview and Architecture
-       RFC 2579: Textual Conventions for SMIv2";
-   }
-
-   /*** collection of XML specific types ***/
-
-   typedef xpath1.0 {
-     type string;
-     description
-      "This type represents an XPATH 1.0 expression.
-
-       When a schema node is defined that uses this type, the
-       description of the schema node MUST specify the XPath
-       context in which the XPath expression is evaluated.";
-     reference
-      "XPATH: XML Path Language (XPath) Version 1.0";
-   }
-
- }
\ No newline at end of file
index b420ed80d1289148fe2f3fb2df1acbc26a109d42..20a19a713bf879243edcf4c93b7b3403b0f1c2a4 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.yangtools.binding.generator.util;
 
+import com.google.common.base.Splitter;
+import com.google.common.collect.Iterables;
 import java.io.ByteArrayOutputStream;
 import java.io.DataOutputStream;
 import java.io.IOException;
@@ -16,10 +18,10 @@ import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.Iterator;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-
 import org.opendaylight.yangtools.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
 import org.opendaylight.yangtools.sal.binding.model.api.AccessModifier;
 import org.opendaylight.yangtools.sal.binding.model.api.Restrictions;
@@ -40,8 +42,6 @@ import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 import org.opendaylight.yangtools.yang.model.api.type.UnsignedIntegerTypeDefinition;
 import org.opendaylight.yangtools.yang.model.util.ExtendedType;
 
-import com.google.common.base.Splitter;
-
 /**
  * Contains the methods for converting strings to valid JAVA language strings
  * (package names, class names, attribute names).
@@ -215,16 +215,18 @@ public final class BindingGeneratorUtil {
 
         final StringBuilder builder = new StringBuilder();
         builder.append(basePackageName);
-        final List<QName> pathToNode = schemaPath.getPath();
+        final Iterable<QName> iterable = schemaPath.getPathFromRoot();
+        final Iterator<QName> iterator = iterable.iterator();
+        int size = Iterables.size(iterable);
         final int traversalSteps;
         if (isUsesAugment) {
-            traversalSteps = (pathToNode.size());
+            traversalSteps = size;
         } else {
-            traversalSteps = (pathToNode.size() - 1);
+            traversalSteps = size - 1;
         }
         for (int i = 0; i < traversalSteps; ++i) {
             builder.append('.');
-            String nodeLocalName = pathToNode.get(i).getLocalName();
+            String nodeLocalName = iterator.next().getLocalName();
 
             nodeLocalName = nodeLocalName.replace(':', '.');
             nodeLocalName = nodeLocalName.replace('-', '.');
@@ -351,21 +353,25 @@ public final class BindingGeneratorUtil {
      *             if the length of the returning string has length 0
      */
     private static String replaceWithCamelCase(final String text, final char removalChar) {
+        int toBeRemovedPos = text.indexOf(removalChar);
+        if (toBeRemovedPos == -1) {
+            return text;
+        }
+
         StringBuilder sb = new StringBuilder(text);
         String toBeRemoved = String.valueOf(removalChar);
-
-        int toBeRemovedPos = sb.indexOf(toBeRemoved);
-        while (toBeRemovedPos != -1) {
+        do {
             sb.replace(toBeRemovedPos, toBeRemovedPos + 1, "");
             // check if 'toBeRemoved' character is not the only character in
             // 'text'
             if (sb.length() == 0) {
                 throw new IllegalArgumentException("The resulting string can not be empty");
             }
-            String replacement = String.valueOf(sb.charAt(toBeRemovedPos)).toUpperCase();
-            sb.setCharAt(toBeRemovedPos, replacement.charAt(0));
+            char replacement = Character.toUpperCase(sb.charAt(toBeRemovedPos));
+            sb.setCharAt(toBeRemovedPos, replacement);
             toBeRemovedPos = sb.indexOf(toBeRemoved);
-        }
+        } while (toBeRemovedPos != -1);
+
         return sb.toString();
     }
 
index 9a572b35db59b94b200648b19d15e1053c96c9e7..ba26baf8d124167ed057276e92b4744fbfac178d 100644 (file)
@@ -13,17 +13,17 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertNull;
 
 import java.io.File;
+import java.io.IOException;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Set;
-
 import org.junit.Test;
 import org.opendaylight.yangtools.yang.binding.BindingMapping;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
-import org.opendaylight.yangtools.yang.model.parser.api.YangModelParser;
+import org.opendaylight.yangtools.yang.model.parser.api.YangContextParser;
 import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;
 import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleBuilder;
 import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
@@ -54,10 +54,10 @@ public class BindingGeneratorUtilTest {
      * - without revision </ul>
      */
     @Test
-    public void testBindingGeneratorUtilMethods() {
+    public void testBindingGeneratorUtilMethods() throws IOException {
         List<File> testModels = loadTestResources("/module.yang");
-        final YangModelParser parser = new YangParserImpl();
-        final Set<Module> modules = parser.parseYangModels(testModels);
+        final YangContextParser parser = new YangParserImpl();
+        final Set<Module> modules = parser.parseFiles(testModels).getModules();
         String packageName = "";
         Module module = null;
         for (Module m : modules) {
index d2684df9e29b84ea3f17103165c5c15c55d1965d..fc9535e0d2bd84386d3fd8545be3511bb22b6f06 100644 (file)
@@ -225,7 +225,7 @@ abstract class BaseTemplate {
                 }
             }
             if (!isValidLength) {
-                throw new IllegalArgumentException(String.format("Invalid length: {}, expected: {}.", Â«paramName», lengthConstraints));
+                throw new IllegalArgumentException(String.format("Invalid length: %s, expected: %s.", Â«paramName», lengthConstraints));
             }
         }
     '''
index 5f19a4e8f64b1de6b402e9b9869969121bc59ce7..b9f73bb3b2b14ecbe1f9559a841744de024c42f4 100644 (file)
@@ -9,8 +9,25 @@ package org.opendaylight.yangtools.sal.java.api.generator.test;
 
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
-import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.*;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.BASE_PKG;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.COMPILER_OUTPUT_PATH;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.FS;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.GENERATOR_OUTPUT_PATH;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.NS_BAR;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.NS_BAZ;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.NS_FOO;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.NS_TEST;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertContainsConstructor;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertContainsField;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertContainsMethod;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertContainsRestrictionCheck;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertFilesCount;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.assertImplementsIfc;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.cleanUp;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.getSourceFiles;
+import static org.opendaylight.yangtools.sal.java.api.generator.test.CompilationTestUtils.testCompilation;
 
+import com.google.common.collect.Range;
 import java.io.File;
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
@@ -25,7 +42,6 @@ import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
-
 import org.junit.Test;
 import org.opendaylight.yangtools.sal.binding.model.api.Type;
 import org.opendaylight.yangtools.sal.java.api.generator.GeneratorJavaFile;
@@ -33,8 +49,6 @@ import org.opendaylight.yangtools.yang.binding.annotations.RoutingContext;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
 
-import com.google.common.collect.Range;
-
 /**
  * Test correct code generation.
  *
@@ -409,7 +423,7 @@ public class CompilationTest extends BaseCompilationTest {
         List<Range<Integer>> lengthConstraints = new ArrayList<>();
         lengthConstraints.add(Range.closed(1, 10));
         Object arg = new byte[] {};
-        String expectedMsg = String.format("Invalid length: {}, expected: {}.", arg, lengthConstraints);
+        String expectedMsg = String.format("Invalid length: %s, expected: %s.", arg, lengthConstraints);
         assertContainsRestrictionCheck(builderObj, m, expectedMsg, arg);
 
         m = assertContainsMethod(builderClass, builderClass, "setIdDecimal64", BigDecimal.class);
@@ -489,7 +503,7 @@ public class CompilationTest extends BaseCompilationTest {
     }
 
     @Test
-    public void bug586Test() throws Exception {
+    public void testBug586() throws Exception {
         final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "bug586");
         assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
         final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "bug586");
@@ -503,6 +517,26 @@ public class CompilationTest extends BaseCompilationTest {
         cleanUp(sourcesOutputDir, compiledOutputDir);
     }
 
+    /**
+     * Test handling nested uses-augmentations.
+     *
+     * @throws Exception
+     */
+    @Test
+    public void testBug1172() throws Exception {
+        final File sourcesOutputDir = new File(GENERATOR_OUTPUT_PATH + FS + "bug1172");
+        assertTrue("Failed to create test file '" + sourcesOutputDir + "'", sourcesOutputDir.mkdir());
+        final File compiledOutputDir = new File(COMPILER_OUTPUT_PATH + FS + "bug1172");
+        assertTrue("Failed to create test file '" + compiledOutputDir + "'", compiledOutputDir.mkdir());
+
+        generateTestSources("/compilation/bug1172", sourcesOutputDir);
+
+        // Test if sources are compilable
+        testCompilation(sourcesOutputDir, compiledOutputDir);
+
+        cleanUp(sourcesOutputDir, compiledOutputDir);
+    }
+
     private void generateTestSources(String resourceDirPath, File sourcesOutputDir) throws Exception {
         final List<File> sourceFiles = getSourceFiles(resourceDirPath);
         final Set<Module> modulesToBuild = parser.parseYangModels(sourceFiles);
index 29e00c2725e3503bed7c1138935a3010fcb39617..887c92cfa159959cdb1d2683101e21a07a3557c3 100644 (file)
@@ -178,7 +178,7 @@ public class TypedefCompilationTest extends BaseCompilationTest {
         List<Range<Integer>> lengthConstraints = new ArrayList<>();
         lengthConstraints.add(Range.closed(5, 11));
         arg = "abcd";
-        expectedMsg = String.format("Invalid length: {}, expected: {}.", arg, lengthConstraints);
+        expectedMsg = String.format("Invalid length: %s, expected: %s.", arg, lengthConstraints);
         assertContainsRestrictionCheck(expectedConstructor, expectedMsg, arg);
         obj = expectedConstructor.newInstance("hello world");
         assertEquals(obj, defInst.invoke(null, "hello world"));
@@ -197,7 +197,7 @@ public class TypedefCompilationTest extends BaseCompilationTest {
         lengthConstraints.clear();
         lengthConstraints.add(Range.closed(6, 10));
         arg = "abcde";
-        String.format("Invalid length: {}, expected: {}.", arg, lengthConstraints);
+        expectedMsg = String.format("Invalid length: %s, expected: %s.", arg, lengthConstraints);
         assertContainsRestrictionCheck(expectedConstructor, expectedMsg, arg);
         obj = expectedConstructor.newInstance("helloWorld");
         assertEquals(obj, defInst.invoke(null, "helloWorld"));
diff --git a/code-generator/binding-java-api-generator/src/test/resources/compilation/bug1172/nested-uses-augment.yang b/code-generator/binding-java-api-generator/src/test/resources/compilation/bug1172/nested-uses-augment.yang
new file mode 100644 (file)
index 0000000..7377e94
--- /dev/null
@@ -0,0 +1,40 @@
+module nested-uses-augment {
+    yang-version 1;
+    namespace "odl:test:nua";
+    prefix "nua";
+
+    revision "2014-07-11" {
+    }
+
+    grouping machine-types {
+        container types {
+            choice machine-type {
+            }
+        }
+    }
+
+    grouping machine-ext {
+        uses machine-types {
+            augment "types/machine-type" {
+                case type-a {
+                    leaf id {
+                        type string;
+                    }
+                }
+            }
+        }
+    }
+
+    grouping machine-ext2 {
+        uses machine-ext {
+            augment "types/machine-type" {
+                case type-b {
+                    leaf name {
+                        type string;
+                    }
+                }
+            }
+        }
+    }
+
+}
index c9bcc282e04b2036b1436019b10d69ea95ec4828..86b40c027efada8b0e20fe16e2f421f1e31d65e8 100644 (file)
@@ -7,13 +7,13 @@
  */
 package org.opendaylight.yangtools.sal.binding.yang.types;
 
+import com.google.common.base.Optional;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-
 import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
 import org.opendaylight.yangtools.binding.generator.util.Types;
 import org.opendaylight.yangtools.sal.binding.generator.spi.TypeProvider;
@@ -228,7 +228,8 @@ public final class BaseYangTypes {
 
             @Override
             public List<RangeConstraint> getRangeConstraints() {
-                return Collections.singletonList(BaseConstraints.rangeConstraint(min, max, null, null));
+                return Collections.singletonList(BaseConstraints.newRangeConstraint(min, max,
+                        Optional.<String> absent(), Optional.<String> absent()));
             }
 
             @Override
index fe685e2478144f47ae92fd1af01b10b540b05f88..5ee5279eed90aae2e9e11079ab03f7be13a1e231 100644 (file)
@@ -14,13 +14,25 @@ import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findD
 import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath;
 import static org.opendaylight.yangtools.yang.model.util.SchemaContextUtil.findParentModule;
 
+import com.google.common.base.Preconditions;
+import com.google.common.collect.Sets;
+import com.google.common.io.BaseEncoding;
 import java.math.BigDecimal;
 import java.math.BigInteger;
 import java.net.URI;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
-
 import org.apache.commons.lang3.StringEscapeUtils;
 import org.opendaylight.yangtools.binding.generator.util.BindingGeneratorUtil;
 import org.opendaylight.yangtools.binding.generator.util.TypeConstants;
@@ -51,15 +63,34 @@ 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.*;
+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.BitsTypeDefinition.Bit;
-import org.opendaylight.yangtools.yang.model.util.*;
+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.IdentityrefTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.InstanceIdentifierTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.LeafrefTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.StringTypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.UnionTypeDefinition;
+import org.opendaylight.yangtools.yang.model.util.DataNodeIterator;
+import org.opendaylight.yangtools.yang.model.util.EnumerationType;
+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.StringType;
+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.UnionType;
 import org.opendaylight.yangtools.yang.parser.util.ModuleDependencySort;
 
-import com.google.common.base.Preconditions;
-import com.google.common.collect.Sets;
-import com.google.common.io.BaseEncoding;
-
 public final class TypeProviderImpl implements TypeProvider {
     /**
      * Contains the schema data red from YANG files.
@@ -1279,9 +1310,10 @@ public final class TypeProviderImpl implements TypeProvider {
         } else if (base instanceof BitsTypeDefinition) {
             String parentName;
             String className;
-            SchemaPath nodePath = node.getPath();
             Module parent = getParentModule(node);
-            if (nodePath.getPath().size() == 1) {
+            Iterator<QName> path = node.getPath().getPathFromRoot().iterator();
+            path.next();
+            if (!(path.hasNext())) {
                 parentName = BindingMapping.getClassName((parent).getName()) + "Data";
                 String basePackageName = BindingGeneratorUtil.moduleNamespaceToPackageName(parent);
                 className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName());
@@ -1404,7 +1436,7 @@ public final class TypeProviderImpl implements TypeProvider {
     }
 
     private Module getParentModule(SchemaNode node) {
-        QName qname = node.getPath().getPath().get(0);
+        QName qname = node.getPath().getPathFromRoot().iterator().next();
         URI namespace = qname.getNamespace();
         Date revision = qname.getRevision();
         return schemaContext.findModuleByNamespaceAndRevision(namespace, revision);
@@ -1472,9 +1504,9 @@ public final class TypeProviderImpl implements TypeProvider {
             String basePackageName = BindingGeneratorUtil.moduleNamespaceToPackageName(module);
             className = basePackageName + "." + BindingMapping.getClassName(typeQName);
         } else {
-            SchemaPath nodePath = node.getPath();
-            if (nodePath.getPath().size() == 1) {
-                QName first = nodePath.getPath().get(0);
+            Iterator<QName> path = node.getPath().getPathFromRoot().iterator();
+            QName first = path.next();
+            if (!(path.hasNext())) {
                 URI namespace = first.getNamespace();
                 Date revision = first.getRevision();
                 Module parent = schemaContext.findModuleByNamespaceAndRevision(namespace, revision);
@@ -1482,7 +1514,6 @@ public final class TypeProviderImpl implements TypeProvider {
                 String basePackageName = BindingGeneratorUtil.moduleNamespaceToPackageName(parent);
                 className = basePackageName + "." + parentName + "." + BindingMapping.getClassName(node.getQName());
             } else {
-                QName first = node.getPath().getPath().get(0);
                 URI namespace = first.getNamespace();
                 Date revision = first.getRevision();
                 Module parentModule = schemaContext.findModuleByNamespaceAndRevision(namespace, revision);
diff --git a/common/feature/pom.xml b/common/feature/pom.xml
deleted file mode 100644 (file)
index 84fb555..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-<project>
-
-    <modelVersion>4.0.0</modelVersion>
-
-    <parent>
-        <groupId>org.opendaylight.yangtools</groupId>
-        <artifactId>yangtools-parent</artifactId>
-        <version>0.6.2-SNAPSHOT</version>
-        <relativePath>/../../common/parent/pom.xml</relativePath>
-    </parent>
-
-    <artifactId>features-file</artifactId>
-    <packaging>pom</packaging>
-
-    <properties>
-        <features.file>features.xml</features.file>
-    </properties>
-
-    <build>
-        <resources>
-            <resource>
-                <directory>src/main/resources</directory>
-                <filtering>true</filtering>
-            </resource>
-        </resources>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-resources-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>filter</id>
-                        <phase>generate-resources</phase>
-                        <goals>
-                            <goal>resources</goal>
-                        </goals>
-                    </execution>
-                </executions>
-            </plugin>
-            <plugin>
-                <groupId>org.codehaus.mojo</groupId>
-                <artifactId>build-helper-maven-plugin</artifactId>
-                <executions>
-                    <execution>
-                        <id>attach-artifacts</id>
-                        <phase>package</phase>
-                        <goals>
-                            <goal>attach-artifact</goal>
-                        </goals>
-                        <configuration>
-                            <artifacts>
-                                <artifact>
-                                    <file>${project.build.directory}/classes/${features.file}</file>
-                                    <type>xml</type>
-                                    <classifier>features</classifier>
-                                </artifact>
-                            </artifacts>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-</project>
-
diff --git a/common/features/pom.xml b/common/features/pom.xml
new file mode 100644 (file)
index 0000000..e8ad432
--- /dev/null
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2014 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
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+   xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+   <modelVersion>4.0.0</modelVersion>
+   <parent>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yangtools-parent</artifactId>
+      <version>0.6.2-SNAPSHOT</version>
+      <relativePath>../parent/pom.xml</relativePath>
+   </parent>
+   <artifactId>features-yangtools</artifactId>
+   <packaging>pom</packaging>
+   <properties>
+      <features.file>features.xml</features.file>
+   </properties>
+   <build>
+      <resources>
+         <resource>
+            <directory>src/main/resources</directory>
+            <filtering>true</filtering>
+         </resource>
+      </resources>
+      <plugins>
+         <plugin>
+            <groupId>org.apache.karaf.tooling</groupId>
+            <artifactId>karaf-maven-plugin</artifactId>
+            <version>${karaf.version}</version>
+            <extensions>true</extensions>
+            <executions>
+               <execution>
+                  <id>features-create-kar</id>
+                  <goals>
+                     <goal>features-create-kar</goal>
+                  </goals>
+                  <configuration>
+                     <featuresFile>${project.build.directory}/classes/${features.file}</featuresFile>
+                  </configuration>
+               </execution>
+            </executions>
+        <!-- There is no useful configuration for the kar mojo. The features-generate-descriptor mojo configuration may be useful -->
+         </plugin>
+         <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-resources-plugin</artifactId>
+            <executions>
+               <execution>
+                  <id>filter</id>
+                  <phase>generate-resources</phase>
+                  <goals>
+                     <goal>resources</goal>
+                  </goals>
+               </execution>
+            </executions>
+         </plugin>
+         <plugin>
+            <groupId>org.codehaus.mojo</groupId>
+            <artifactId>build-helper-maven-plugin</artifactId>
+            <executions>
+               <execution>
+                  <id>attach-artifacts</id>
+                  <phase>package</phase>
+                  <goals>
+                     <goal>attach-artifact</goal>
+                  </goals>
+                  <configuration>
+                     <artifacts>
+                        <artifact>
+                           <file>${project.build.directory}/classes/${features.file}</file>
+                           <type>xml</type>
+                           <classifier>features</classifier>
+                        </artifact>
+                     </artifacts>
+                  </configuration>
+               </execution>
+            </executions>
+         </plugin>
+      </plugins>
+   </build>
+</project>
similarity index 66%
rename from common/feature/src/main/resources/features.xml
rename to common/features/src/main/resources/features.xml
index a6b851e0acf92b278fde8a825aebfa6874f4a0ba..968990aaa916dfb49232d522e8fbb80fce5e8e09 100644 (file)
@@ -1,30 +1,40 @@
 <?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2014 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
+-->
 <features>
 
     <feature name='yangtools-all' version='${project.version}'>
         <feature version='${project.version}'>yangtools-models</feature>
         <feature version='${project.version}'>yangtools-binding</feature>
+        <feature version='${project.version}'>yangtools-common</feature>
         <feature version='${project.version}'>yangtools-concepts</feature>
         <feature version='${project.version}'>yangtools-binding-generator</feature>
     </feature>
 
     <feature name='yangtools-models' version='${project.version}'>
-        <bundle>mvn:org.opendaylight.yangtools.model/ietf-inet-types/2010.09.24.4-SNAPSHOT</bundle>
-        <bundle>mvn:org.opendaylight.yangtools.model/ietf-yang-types/2010.09.24.4-SNAPSHOT</bundle>
-        <bundle>mvn:org.opendaylight.yangtools.model/yang-ext/2013.09.07.4-SNAPSHOT</bundle>
-        <bundle>mvn:org.opendaylight.yangtools.model/opendaylight-l2-types/2013.08.27.4-SNAPSHOT</bundle>
-        <bundle>mvn:org.opendaylight.yangtools.model/ietf-topology/2013.10.21.2-SNAPSHOT</bundle>
-        <bundle>mvn:org.opendaylight.yangtools.model/opendaylight-l2-types/2013.08.27.4-SNAPSHOT</bundle>
-    </feature>
+        <bundle>mvn:org.opendaylight.yangtools.model/ietf-inet-types/${ietf.inet.types.version}</bundle>
+        <bundle>mvn:org.opendaylight.yangtools.model/ietf-yang-types/${ietf.yang.types.version}</bundle>
+        <bundle>mvn:org.opendaylight.yangtools.model/yang-ext/${yang.ext.version}</bundle>
+        <bundle>mvn:org.opendaylight.yangtools.model/opendaylight-l2-types/${opendaylight.l2.types.version}</bundle>
+        <bundle>mvn:org.opendaylight.yangtools.model/ietf-topology/${ietf.topology.version}</bundle>
+       </feature>
 
     <feature name='yangtools-binding' version='${project.version}'>
         <feature version='${project.version}'>yangtools-concepts</feature>
-        <bundle>mvn:org.opendaylight.yangtools.thirdparty/antlr4-runtime-osgi-nohead/4.0</bundle>
-        <bundle>mvn:commons-io/commons-io/2.4</bundle>
+        <bundle>mvn:org.opendaylight.yangtools.thirdparty/antlr4-runtime-osgi-nohead/${antlr4.version}</bundle>
+        <bundle>mvn:commons-io/commons-io/${commons.io.version}</bundle>
         <bundle>mvn:org.opendaylight.yangtools/yang-binding/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.yangtools/yang-data-api/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.yangtools/yang-data-impl/${project.version}</bundle>
+        <bundle>mvn:org.opendaylight.yangtools/yang-data-json/${project.version}</bundle>
+        <bundle>mvn:org.opendaylight.yangtools/yang-data-operations/${project.version}</bundle>
+        <bundle>mvn:org.opendaylight.yangtools/yang-data-util/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.yangtools/yang-model-api/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.yangtools/yang-model-util/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.yangtools/yang-parser-impl/${project.version}</bundle>
         <bundle>wrap:mvn:org.eclipse.xtend/org.eclipse.xtend.lib/${xtend.version}</bundle>
         <bundle>wrap:mvn:org.eclipse.xtext/org.eclipse.xtext.xbase.lib/${xtend.version}</bundle>
     </feature>
-
+    <feature name="yangtools-common" version='${project.version}'>
+        <bundle>mvn:org.opendaylight.yangtools/util/${project.version}</bundle>
+        <bundle>mvn:org.opendaylight.yangtools/object-cache-api/${project.version}</bundle>
+        <bundle>mvn:org.opendaylight.yangtools/object-cache-guava/${project.version}</bundle>
+        <bundle>mvn:org.opendaylight.yangtools/object-cache-noop/${project.version}</bundle>
+    </feature>
     <feature name='yangtools-binding-generator' version='${project.version}'>
         <feature version='${project.version}'>yangtools-binding</feature>
         <bundle>mvn:org.javassist/javassist/${javassist.version}</bundle>
-        <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang.version}</bundle>
+        <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
         <bundle>mvn:org.opendaylight.yangtools/binding-generator-api/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.yangtools/binding-generator-impl/${project.version}</bundle>
         <bundle>mvn:org.opendaylight.yangtools/binding-generator-spi/${project.version}</bundle>
index a9311344737bb7012596224e63ba8f16a53b11c8..5d0c9fdad96e3de7967b8f7c9759e96aef680988 100644 (file)
     </prerequisites>
 
     <properties>
-        <junit.version>4.10</junit.version>
+        <antlr4.version>4.0</antlr4.version>
+        <commons.io.version>2.4</commons.io.version>
+        <ctrie.version>0.2.0</ctrie.version>
         <exam.version>3.0.0</exam.version>
         <groovy.version>2.1.6</groovy.version>
-        <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
-        <ctrie.version>0.2.0</ctrie.version>
         <ietf.topology.version>2013.10.21.2-SNAPSHOT</ietf.topology.version>
         <ietf.inet.types.version>2010.09.24.4-SNAPSHOT</ietf.inet.types.version>
         <ietf.yang.types.version>2010.09.24.4-SNAPSHOT</ietf.yang.types.version>
-        <ietf.restconf.version>2013.09.04.1-SNAPSHOT</ietf.restconf.version>
+        <ietf.restconf.version>2013.10.19.1-SNAPSHOT</ietf.restconf.version>
+        <junit.version>4.10</junit.version>
+        <karaf.version>3.0.1</karaf.version>
+        <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
+        <opendaylight.l2.types.version>2013.08.27.4-SNAPSHOT</opendaylight.l2.types.version>
+        <yang.ext.version>2013.09.07.4-SNAPSHOT</yang.ext.version>
         <maven.javadoc.version>2.9.1</maven.javadoc.version>
     </properties>
 
                 <version>0.6.2-SNAPSHOT</version>
                 <scope>test</scope>
             </dependency>
+            <dependency>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>bug1196-test-model</artifactId>
+                <version>0.6.2-SNAPSHOT</version>
+                <scope>test</scope>
+            </dependency>
 
             <dependency>
                 <groupId>org.opendaylight.yangtools</groupId>
index 32c77ea97648bcb176c151bf29c715e950651979..540e43a0578f141229974d73bc1014661fe200bf 100644 (file)
@@ -19,7 +19,7 @@
     <modules>
         <module>checkstyle-logging</module>
         <module>concepts</module>
-        <module>feature</module>
+        <module>features</module>
         <module>mockito-configuration</module>
         <module>object-cache-api</module>
         <module>object-cache-guava</module>
diff --git a/integration-test/bug1196-test-model/pom.xml b/integration-test/bug1196-test-model/pom.xml
new file mode 100644 (file)
index 0000000..8059b5c
--- /dev/null
@@ -0,0 +1,86 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!-- 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 -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+
+    <parent>
+        <groupId>org.opendaylight.yangtools</groupId>
+        <artifactId>yangtools-parent</artifactId>
+        <version>0.6.2-SNAPSHOT</version>
+        <relativePath>/../../common/parent/pom.xml</relativePath>
+    </parent>
+
+    <modelVersion>4.0.0</modelVersion>
+    <artifactId>bug1196-test-model</artifactId>
+    <name>${project.artifactId}</name>
+    <description>${project.artifactId}</description>
+
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+            </plugin>
+            <plugin>
+                <groupId>org.opendaylight.yangtools</groupId>
+                <artifactId>yang-maven-plugin</artifactId>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools</groupId>
+                        <artifactId>yang-binding</artifactId>
+                        <version>0.6.2-SNAPSHOT</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools</groupId>
+                        <artifactId>yang-common</artifactId>
+                        <version>0.6.2-SNAPSHOT</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools.model</groupId>
+                        <artifactId>yang-ext</artifactId>
+                        <version>2013.09.07.4-SNAPSHOT</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.opendaylight.yangtools.model</groupId>
+                        <artifactId>ietf-inet-types</artifactId>
+                        <version>2010.09.24.4-SNAPSHOT</version>
+                    </dependency>
+                </dependencies>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Bundle-Name>org.opendaylight.yangtools.model.${project.artifactId}</Bundle-Name>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-binding</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>yang-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.model</groupId>
+            <artifactId>yang-ext</artifactId>
+            <version>2013.09.07.4-SNAPSHOT</version>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools.model</groupId>
+            <artifactId>ietf-inet-types</artifactId>
+        </dependency>
+    </dependencies>
+
+</project>
diff --git a/integration-test/bug1196-test-model/src/main/yang/network-topology-pcep.yang b/integration-test/bug1196-test-model/src/main/yang/network-topology-pcep.yang
new file mode 100644 (file)
index 0000000..29d202d
--- /dev/null
@@ -0,0 +1,32 @@
+module network-topology-pcep {
+    // vi: set et smarttab sw=4 tabstop=4:
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:topology:pcep";
+    prefix "pn";
+
+    import network-topology { prefix nt; revision-date 2013-10-21; }
+
+    revision "2013-10-24" {
+    }
+
+
+    grouping pcep-client-attributes {
+        container path-computation-client {
+            config false;
+            list reported-lsp {
+                leaf name {
+                    type string;
+                }
+                key name;
+            }
+        }
+    }
+
+    augment "/nt:network-topology/nt:topology/nt:node" {
+        when "../../nt:topology-types/topology-pcep";
+
+        uses pcep-client-attributes;
+    }
+
+}
+
diff --git a/integration-test/bug1196-test-model/src/main/yang/network-topology-unix.yang b/integration-test/bug1196-test-model/src/main/yang/network-topology-unix.yang
new file mode 100644 (file)
index 0000000..d061f47
--- /dev/null
@@ -0,0 +1,25 @@
+module network-topology-unix {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:network:topology-unix";
+    prefix "unix";
+
+    import network-topology { prefix nt; revision-date 2013-10-21; }
+    import network-topology-pcep { prefix topo; revision-date 2013-10-24; }
+    import odl-pcep-ietf-stateful07 { prefix stateful; revision-date 2013-12-22; }
+
+    revision "2013-12-22" {
+    }
+
+
+    augment "/nt:network-topology/nt:topology/nt:node/topo:path-computation-client/topo:reported-lsp/stateful:lsp/stateful:tlvs/stateful:vs-tlv/stateful:vendor-payload" {
+        case unix {
+            container unix-sub-tlvs {
+                leaf unix-value {
+                    type uint8;
+                }
+            }
+        }
+    }
+
+}
+
diff --git a/integration-test/bug1196-test-model/src/main/yang/network-topology@2013-10-21.yang b/integration-test/bug1196-test-model/src/main/yang/network-topology@2013-10-21.yang
new file mode 100644 (file)
index 0000000..630b780
--- /dev/null
@@ -0,0 +1,23 @@
+module network-topology  {
+    yang-version 1;
+    namespace "urn:TBD:params:xml:ns:yang:network-topology";
+    prefix "nt";
+
+
+    revision 2013-10-21 {
+    }
+
+
+
+    container network-topology {
+        list topology {
+            key "topology-id";
+            leaf topology-id {
+                type string;
+            }
+            list node {
+            }
+        }
+    }
+}
+
diff --git a/integration-test/bug1196-test-model/src/main/yang/odl-pcep-ietf-stateful07.yang b/integration-test/bug1196-test-model/src/main/yang/odl-pcep-ietf-stateful07.yang
new file mode 100644 (file)
index 0000000..525040c
--- /dev/null
@@ -0,0 +1,38 @@
+module odl-pcep-ietf-stateful07 {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:pcep:ietf:stateful";
+    prefix "stateful";
+
+    import network-topology { prefix nt; revision-date 2013-10-21; }
+    import network-topology-pcep { prefix topo; revision-date 2013-10-24; }
+    import pcep-types { prefix pcep; revision-date 2013-10-05; }
+    import yang-ext { prefix ext; revision-date 2013-07-09; }
+
+    revision "2013-12-22" {
+    }
+
+
+    grouping lsp-object {
+        container lsp {
+            container "tlvs" {
+                uses pcep:vs-tlv;
+            }
+        }
+    }
+
+    augment "/nt:network-topology/nt:topology/nt:node/topo:path-computation-client/topo:reported-lsp" {
+        uses lsp-object;
+    }
+
+    augment "/nt:network-topology/nt:topology/nt:node/topo:path-computation-client/topo:reported-lsp/stateful:lsp/stateful:tlvs/stateful:vs-tlv/stateful:vendor-payload" {
+        case linux {
+            container linux-sub-tlvs {
+                leaf linux-value {
+                    type uint8;
+                }
+            }
+        }
+    }
+
+}
+
diff --git a/integration-test/bug1196-test-model/src/main/yang/pcep-types.yang b/integration-test/bug1196-test-model/src/main/yang/pcep-types.yang
new file mode 100644 (file)
index 0000000..a05c2ea
--- /dev/null
@@ -0,0 +1,19 @@
+module pcep-types {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:pcep:types";
+    prefix "pcep-t";
+
+    revision "2013-10-05" {
+    }
+
+
+    grouping vs-tlv {
+        description "Vendor-specific TLV.";
+        container vs-tlv {
+                choice vendor-payload {
+                }
+        }
+    }
+
+}
+
index 2b9a20c90874456f7ca3e49190bdf48111e8dde7..77dd63be37a71195f7b98db72df02558cb2b7187 100644 (file)
@@ -15,6 +15,7 @@
 
     <modules>
         <module>bug527-test-model</module>
+        <module>bug1196-test-model</module>
         <module>bundle-test</module>
         <module>test-models</module>
         <module>regression-test-model</module>
index 50229c823f0f3003173b233b2ebc31f52228fdc5..1f0606307d83ce3a95a6a61baa18fbc1a539d017 100644 (file)
@@ -25,7 +25,7 @@
         <ietf.topology.version>2013.10.21.2-SNAPSHOT</ietf.topology.version>
         <ietf.inet.types.version>2010.09.24.4-SNAPSHOT</ietf.inet.types.version>
         <ietf.yang.types.version>2010.09.24.4-SNAPSHOT</ietf.yang.types.version>
-        <ietf.restconf.version>2013.09.04.1-SNAPSHOT</ietf.restconf.version>
+        <ietf.restconf.version>2013.10.19.1-SNAPSHOT</ietf.restconf.version>
     </properties>
 
     <modules>
index 99c08eb51511cbf3c24d57d81a6a35a8fe84e499..b21db8414775da7966276cfcb9e568375fb75dc0 100644 (file)
             <version>0.6.2-SNAPSHOT</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.opendaylight.yangtools</groupId>
+            <artifactId>bug1196-test-model</artifactId>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 </project>
diff --git a/restconf/restconf-util/src/test/java/org/opendaylight/yangtools/restconf/utils/Bug1196Test.java b/restconf/restconf-util/src/test/java/org/opendaylight/yangtools/restconf/utils/Bug1196Test.java
new file mode 100644 (file)
index 0000000..ac5d868
--- /dev/null
@@ -0,0 +1,128 @@
+/*
+ * Copyright (c) 2014 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.restconf.utils;
+
+import static junit.framework.Assert.assertNotNull;
+import static org.junit.Assert.assertEquals;
+
+import java.io.InputStream;
+import java.util.AbstractMap.SimpleEntry;
+import java.util.Map.Entry;
+
+import javassist.ClassPool;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.unix.rev131222.network.topology.topology.node.path.computation.client.reported.lsp.lsp.tlvs.vs.tlv.vendor.payload.unix.UnixSubTlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.ReportedLsp1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.Lsp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.Tlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.network.topology.topology.node.path.computation.client.reported.lsp.lsp.tlvs.vs.tlv.vendor.payload.linux.LinuxSubTlvs;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.vs.tlv.VsTlv;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.Node1;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.PathComputationClient;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev131024.pcep.client.attributes.path.computation.client.ReportedLsp;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.sal.binding.generator.impl.ModuleInfoBackedContext;
+import org.opendaylight.yangtools.sal.binding.generator.impl.RuntimeGeneratedMappingServiceImpl;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.util.BindingReflections;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.CompositeNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+
+public class Bug1196Test {
+
+    private static final InstanceIdentifier<PathComputationClient> PATH_TO_CLIENT = InstanceIdentifier.builder(NetworkTopology.class)
+            .child(Topology.class)
+            .child(Node.class)
+            .augmentation(Node1.class)
+            .child(PathComputationClient.class)
+            .build();
+    private RuntimeGeneratedMappingServiceImpl mappingService;
+
+    @Before
+    public void setup() {
+        this.mappingService = new RuntimeGeneratedMappingServiceImpl(new ClassPool());
+
+        final ModuleInfoBackedContext moduleInfo = ModuleInfoBackedContext.create();
+        moduleInfo.addModuleInfos(BindingReflections.loadModuleInfos());
+        this.mappingService.onGlobalContextUpdated(moduleInfo.tryToCreateSchemaContext().get());
+    }
+
+    @Test
+    public void testXmlDataToDataObjectLinuxCase() {
+        final InstanceIdentifier<Topology> instanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
+                .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).toInstance();
+        final InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug1196-linux.xml");
+        final DataSchemaNode dataSchema = RestconfUtils.toRestconfIdentifier(instanceIdentifier, this.mappingService,
+                this.mappingService.getSchemaContext()).getValue();
+        Topology topology = (Topology) RestconfUtils.dataObjectFromInputStream(instanceIdentifier, is,
+                this.mappingService.getSchemaContext(), this.mappingService, dataSchema);
+        assertNotNull(topology);
+        assertNotNull(topology.getNode());
+        assertEquals(1, topology.getNode().size());
+        Node node = topology.getNode().get(0);
+        Node1 node1 = node.getAugmentation(Node1.class);
+        assertNotNull(node1);
+        final PathComputationClient pcc = node1.getPathComputationClient();
+        final Lsp lsp = pcc.getReportedLsp().get(0).getAugmentation(ReportedLsp1.class).getLsp();
+        org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.Tlvs tlvs = lsp.getTlvs();
+        assertNotNull(tlvs);
+        VsTlv vsTlv = tlvs.getVsTlv();
+        assertNotNull(vsTlv.getVendorPayload());
+
+        Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> domPcc = mappingService.toDataDom(new SimpleEntry<InstanceIdentifier<?>,DataObject>(PATH_TO_CLIENT,pcc));
+        CompositeNode domPccValue = domPcc.getValue();
+        assertNotNull(domPccValue);
+        CompositeNode domPccTlvs = getFirstReportedLspVsTlvs(domPccValue);
+        assertNotNull(domPccTlvs);
+        assertNotNull(domPccTlvs.getFirstCompositeByName(LinuxSubTlvs.QNAME));
+
+    }
+
+    private CompositeNode getFirstReportedLspVsTlvs(final CompositeNode domPccValue) {
+        return domPccValue.getFirstCompositeByName(ReportedLsp.QNAME).getFirstCompositeByName(Lsp.QNAME).getFirstCompositeByName(Tlvs.QNAME).getFirstCompositeByName(QName.create(Tlvs.QNAME,VsTlv.QNAME.getLocalName()));
+    }
+
+    @Test
+    public void testXmlDataToDataObjectUnixCase() {
+        final InstanceIdentifier<Topology> instanceIdentifier = InstanceIdentifier.builder(NetworkTopology.class)
+                .child(Topology.class, new TopologyKey(new TopologyId("example-pcep-topology"))).toInstance();
+        final InputStream is = this.getClass().getClassLoader().getResourceAsStream("topology-bug1196-unix.xml");
+        final DataSchemaNode dataSchema = RestconfUtils.toRestconfIdentifier(instanceIdentifier, this.mappingService,
+                this.mappingService.getSchemaContext()).getValue();
+        Topology topology = (Topology) RestconfUtils.dataObjectFromInputStream(instanceIdentifier, is,
+                this.mappingService.getSchemaContext(), this.mappingService, dataSchema);
+        assertNotNull(topology);
+        assertNotNull(topology.getNode());
+        assertEquals(1, topology.getNode().size());
+        Node node = topology.getNode().get(0);
+        Node1 node1 = node.getAugmentation(Node1.class);
+        assertNotNull(node1);
+        final PathComputationClient pcc = node1.getPathComputationClient();
+        final Lsp lsp = pcc.getReportedLsp().get(0).getAugmentation(ReportedLsp1.class).getLsp();
+        org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.lsp.object.lsp.Tlvs tlvs = lsp.getTlvs();
+        assertNotNull(tlvs);
+        VsTlv vsTlv = tlvs.getVsTlv();
+        assertNotNull(vsTlv.getVendorPayload());
+
+        Entry<org.opendaylight.yangtools.yang.data.api.InstanceIdentifier, CompositeNode> domPcc = mappingService.toDataDom(new SimpleEntry<InstanceIdentifier<?>,DataObject>(PATH_TO_CLIENT,pcc));
+        CompositeNode domPccValue = domPcc.getValue();
+        assertNotNull(domPccValue);
+        CompositeNode domPccTlvs = getFirstReportedLspVsTlvs(domPccValue);
+        assertNotNull(domPccTlvs);
+        assertNotNull(domPccTlvs.getFirstCompositeByName(UnixSubTlvs.QNAME));
+    }
+
+}
diff --git a/restconf/restconf-util/src/test/resources/topology-bug1196-linux.xml b/restconf/restconf-util/src/test/resources/topology-bug1196-linux.xml
new file mode 100644 (file)
index 0000000..517e840
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- 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 -->
+<topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
+    <server-provided>true</server-provided>
+    <topology-id>example-pcep-topology</topology-id>
+    <topology-types/>
+    <node>
+     <path-computation-client xmlns="urn:opendaylight:params:xml:ns:yang:topology:pcep">
+      <state-sync>synchronized</state-sync>
+       <stateful-tlv>
+        <stateful>
+         <lsp-update-capability>true</lsp-update-capability>
+         <include-db-version>false</include-db-version>
+         <initiation>true</initiation>
+        </stateful>
+       </stateful-tlv>
+       <reported-lsp>
+        <name>update-tunel</name>
+        <path>
+          <bandwidth>
+           <bandwidth>AAAAAA==</bandwidth>
+           <ignore>false</ignore>
+           <processing-rule>false</processing-rule>
+          </bandwidth>
+          <ero>
+            <ignore>false</ignore>
+            <processing-rule>false</processing-rule>
+            <subobject>
+             <loose>false</loose>
+             <ip-prefix>
+              <ip-prefix>195.20.160.40/32</ip-prefix>
+             </ip-prefix>
+          </subobject>
+          <subobject>
+           <loose>false</loose>
+           <ip-prefix>
+            <ip-prefix>201.20.160.43/32</ip-prefix>
+           </ip-prefix>
+          </subobject>
+         </ero>
+         <lspa>
+          <exclude-any>0</exclude-any>
+          <hold-priority>7</hold-priority>
+          <ignore>false</ignore>
+          <include-all>0</include-all>
+          <include-any>0</include-any>
+          <local-protection-desired>false</local-protection-desired>
+          <processing-rule>false</processing-rule>
+          <setup-priority>7</setup-priority>
+         </lspa>
+        </path>
+        <lsp xmlns="urn:opendaylight:params:xml:ns:yang:pcep:ietf:stateful">
+         <tlvs>
+          <symbolic-path-name>
+           <path-name>dXBkYXRlLXR1bmVs</path-name>
+          </symbolic-path-name>
+            <vs-tlv>
+                 <enterprise-number>9</enterprise-number>
+                 <linux-sub-tlvs>
+                    <linux-value>5</linux-value>
+                 </linux-sub-tlvs>
+            </vs-tlv>
+         </tlvs>
+         <delegate>true</delegate>
+         <processing-rule>false</processing-rule>
+         <ignore>false</ignore>
+         <operational>true</operational>
+         <sync>false</sync>
+         <plsp-id>40</plsp-id>
+         <remove>false</remove>
+        </lsp>
+      </reported-lsp>
+      <ip-address>39.39.39.39</ip-address>
+     </path-computation-client>
+     <node-id>pcc://39.39.39.39</node-id>
+    </node>
+</topology>
diff --git a/restconf/restconf-util/src/test/resources/topology-bug1196-unix.xml b/restconf/restconf-util/src/test/resources/topology-bug1196-unix.xml
new file mode 100644 (file)
index 0000000..5213fda
--- /dev/null
@@ -0,0 +1,80 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- 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 -->
+<topology xmlns="urn:TBD:params:xml:ns:yang:network-topology">
+    <server-provided>true</server-provided>
+    <topology-id>example-pcep-topology</topology-id>
+    <topology-types/>
+    <node>
+     <path-computation-client xmlns="urn:opendaylight:params:xml:ns:yang:topology:pcep">
+      <state-sync>synchronized</state-sync>
+       <stateful-tlv>
+        <stateful>
+         <lsp-update-capability>true</lsp-update-capability>
+         <include-db-version>false</include-db-version>
+         <initiation>true</initiation>
+        </stateful>
+       </stateful-tlv>
+       <reported-lsp>
+        <name>update-tunel</name>
+        <path>
+          <bandwidth>
+           <bandwidth>AAAAAA==</bandwidth>
+           <ignore>false</ignore>
+           <processing-rule>false</processing-rule>
+          </bandwidth>
+          <ero>
+            <ignore>false</ignore>
+            <processing-rule>false</processing-rule>
+            <subobject>
+             <loose>false</loose>
+             <ip-prefix>
+              <ip-prefix>195.20.160.40/32</ip-prefix>
+             </ip-prefix>
+          </subobject>
+          <subobject>
+           <loose>false</loose>
+           <ip-prefix>
+            <ip-prefix>201.20.160.43/32</ip-prefix>
+           </ip-prefix>
+          </subobject>
+         </ero>
+         <lspa>
+          <exclude-any>0</exclude-any>
+          <hold-priority>7</hold-priority>
+          <ignore>false</ignore>
+          <include-all>0</include-all>
+          <include-any>0</include-any>
+          <local-protection-desired>false</local-protection-desired>
+          <processing-rule>false</processing-rule>
+          <setup-priority>7</setup-priority>
+         </lspa>
+        </path>
+        <lsp xmlns="urn:opendaylight:params:xml:ns:yang:pcep:ietf:stateful">
+         <tlvs>
+          <symbolic-path-name>
+           <path-name>dXBkYXRlLXR1bmVs</path-name>
+          </symbolic-path-name>
+            <vs-tlv>
+                 <enterprise-number>9</enterprise-number>
+                 <unix-sub-tlvs xmlns="urn:opendaylight:params:xml:ns:yang:network:topology-unix">
+                    <unix-value>5</unix-value>
+                 </unix-sub-tlvs>
+            </vs-tlv>
+         </tlvs>
+         <delegate>true</delegate>
+         <processing-rule>false</processing-rule>
+         <ignore>false</ignore>
+         <operational>true</operational>
+         <sync>false</sync>
+         <plsp-id>40</plsp-id>
+         <remove>false</remove>
+        </lsp>
+      </reported-lsp>
+      <ip-address>39.39.39.39</ip-address>
+     </path-computation-client>
+     <node-id>pcc://39.39.39.39</node-id>
+    </node>
+</topology>
index 30c62fb271e21c19f48b2748c02ae496906e16e5..9df939d2a432005969706884c4f1e81417462f6b 100644 (file)
@@ -17,7 +17,6 @@
     </parent>
 
     <modelVersion>4.0.0</modelVersion>
-    <groupId>org.opendaylight.yangtools</groupId>
     <artifactId>yang-binding</artifactId>
     <name>${project.artifactId}</name>
     <description>Java binding for YANG</description>
index 1ff28fbeeafe67d7503a6114db503dde245094e1..b135a86234bdf8136f393cd7eb5b62f4e48e23ee 100644 (file)
@@ -7,20 +7,18 @@
  */
 package org.opendaylight.yangtools.yang.binding;
 
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.concepts.Immutable;
-import org.opendaylight.yangtools.concepts.Path;
-
 import com.google.common.base.Objects;
 import com.google.common.base.Objects.ToStringHelper;
 import com.google.common.base.Preconditions;
 import com.google.common.collect.ImmutableCollection;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.Iterables;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.concepts.Path;
 
 /**
  *
@@ -492,7 +490,7 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
      * Interface which implementations are used as path components of the
      * path in overall data tree.
      */
-    public interface PathArgument {
+    public interface PathArgument extends Comparable<PathArgument> {
         Class<? extends DataObject> getType();
     }
 
@@ -527,6 +525,11 @@ public class InstanceIdentifier<T extends DataObject> implements Path<InstanceId
             final AbstractPathArgument<?> other = (AbstractPathArgument<?>) obj;
             return type.equals(other.type);
         }
+
+        @Override
+        public int compareTo(PathArgument arg) {
+            return type.getCanonicalName().compareTo(arg.getType().getCanonicalName());
+        }
     }
 
     /**
index 4fd4e17c2b25c56655da9ea479727462d10e42e0..b187013b179a0c5a89f481570f15ccf554ee0044 100644 (file)
@@ -3,13 +3,17 @@ package org.opendaylight.yangtools.yang.binding.util;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
 
+import com.google.common.base.Optional;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableMap.Builder;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.util.ArrayList;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
-
 import org.opendaylight.yangtools.yang.binding.Augmentable;
 import org.opendaylight.yangtools.yang.binding.Augmentation;
 import org.opendaylight.yangtools.yang.binding.DataContainer;
@@ -21,10 +25,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.IdentifiableIt
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.Item;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
 
-import com.google.common.base.Optional;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableMap.Builder;
-
 public class DataObjectReadingUtil {
 
     private DataObjectReadingUtil() {
@@ -48,10 +48,7 @@ public class DataObjectReadingUtil {
         checkArgument(childPath != null, "Child path must not be null");
         checkArgument(parentPath.containsWildcarded(childPath), "Parent object must be parent of child.");
 
-        final int commonOffset = parentPath.getPath().size();
-        final int lastIndex = childPath.getPath().size();
-        List<PathArgument> pathArgs = childPath.getPath().subList(commonOffset, lastIndex);
-
+        List<PathArgument> pathArgs = subList(parentPath.getPathArguments(), childPath.getPathArguments());
         @SuppressWarnings("rawtypes")
         Map<InstanceIdentifier, DataContainer> lastFound = Collections
                 .<InstanceIdentifier, DataContainer> singletonMap(parentPath, parent);
@@ -316,4 +313,31 @@ public class DataObjectReadingUtil {
             return (DataContainer) potential;
         }
     }
+
+    /**
+     * Create sublist view of child from element on [size-of-parent] position to
+     * last element.
+     *
+     * @param parent
+     * @param child
+     * @return sublist view of child argument
+     * @throws IllegalArgumentException
+     *             if parent argument is bigger than child
+     */
+    private static <P, C> List<C> subList(Iterable<P> parent, Iterable<C> child) {
+        Iterator<P> iParent = parent.iterator();
+        List<C> result = new ArrayList<>();
+        for (C arg : child) {
+            if (iParent.hasNext()) {
+                iParent.next();
+            } else {
+                result.add(arg);
+            }
+        }
+        if (iParent.hasNext()) {
+            throw new IllegalArgumentException("Parent argument is bigger than child.");
+        }
+        return result;
+    }
+
 }
index e31239dd8fbd49a0069a64602fb94c01c3c722b4..8abafcdd5de77724be737960c2e7b60c35966b70 100644 (file)
@@ -192,6 +192,15 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
         throw new IllegalArgumentException("Invalid input:" + input);
     }
 
+    /**
+     * Get the module component of the QName.
+     *
+     * @return Module component
+     */
+    public QNameModule getModule() {
+        return module;
+    }
+
     /**
      * Returns XMLNamespace assigned to the YANG module.
      *
@@ -290,6 +299,13 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
         return new QName(base, localName);
     }
 
+    public static QName create(final QNameModule module, final String prefix, final String localName) {
+        if (module == null) {
+            throw new NullPointerException("module may not be null");
+        }
+        return new QName(module, prefix, localName);
+    }
+
     /**
      *
      * Creates new QName.
@@ -300,7 +316,7 @@ public final class QName implements Immutable, Serializable, Comparable<QName> {
      * @return Instance of QName
      */
     public static QName create(final URI namespace, final Date revision, final String localName) {
-        return new QName(QNameModule.create(namespace, revision), null,localName);
+        return new QName(QNameModule.create(namespace, revision), null, localName);
     }
 
     /**
index 22428e36d4b1afbef8e76ef22c090ca8a5d44f9b..89a11c98eb2b56d736994e28a01e26cb0cfbb366 100644 (file)
@@ -16,7 +16,7 @@ import org.opendaylight.yangtools.concepts.Immutable;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-final class QNameModule implements Immutable, Serializable {
+public final class QNameModule implements Immutable, Serializable {
        private static final Logger LOG = LoggerFactory.getLogger(QNameModule.class);
        private static final long serialVersionUID = 1L;
 
index 9146315c47925353413ab4e7e7bb7fdf1b99a567..5554efe66c60bf1a23d43ad59d1b15161648a915 100644 (file)
@@ -11,10 +11,27 @@ import java.util.Map;
 
 import org.opendaylight.yangtools.yang.common.QName;
 
+/**
+ * 
+ * Container of attributes, which may be attached to {@link Node}
+ * 
+ */
 public interface AttributesContainer {
 
+    /**
+     * Returns immutable map of QName and value of the attribute.
+     * 
+     * @return immutable map of attribute names and values.
+     */
     Map<QName, String> getAttributes();
 
-    Object getAttributeValue(QName value);
+    /**
+     * Returns attribute value by supplied QName
+     * 
+     * 
+     * @param name Attribute name
+     * @return Value of attribute if present, null otherwise.
+     */
+    Object getAttributeValue(QName name);
 
 }
index c3af9052ec1917f5032a32a39067256ed3a547c2..48138231492a7923bccc8199fe409b88327332ae 100644 (file)
@@ -1,37 +1,66 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * Copyright (c) 2014 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.data.api;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
 import java.io.Serializable;
 import java.lang.reflect.Array;
 import java.util.Arrays;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Objects;
 import java.util.Set;
-
 import org.opendaylight.yangtools.concepts.Builder;
 import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.concepts.Path;
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
-import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
-import org.opendaylight.yangtools.yang.data.api.schema.LeafNode;
 import org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode;
-import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
-
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
 
+/**
+ * Unique identifier of a partical node instance in the data tree.
+ *
+ *
+ * <p>
+ * Java representation of YANG Built-in type <code>instance-identifier</code>,
+ * which conceptually is XPath expression minimised to uniquely identify element
+ * in data tree which conforms to constraints maintained by YANG Model,
+ * effectively this makes Instance Identifier a path to element in data tree.
+ * <p>
+ * Constraints put in YANG specification on instance-identifier allowed it to be
+ * effectively represented in Java and it's evaluation does not require
+ * full-blown XPath processor.
+ * <p>
+ * <h3>Path Arguments</h3>
+ * Path to the node represented in instance identifier consists of
+ * {@link PathArgument} which carries necessary information to uniquely identify
+ * node on particular level in the subtree.
+ * <p>
+ * <ul>
+ * <li>{@link NodeIdentifier} - Identifier of node, which has cardinality
+ * <code>0..1</code> in particular subtree in data tree.</li>
+ * <li>{@link NodeIdentifierWithPredicates} - Identifier of node (list item),
+ * which has cardinality <code>0..n</code>.</li>
+ * <li>{@link NodeWithValue} - Identifier of instance <code>leaf</code> node or
+ * <code>leaf-list</code> node.</li>
+ * <li>{@link AugmentationIdentifier} - Identifier of instance of
+ * <code>augmentation</code> node.</li>
+ * </ul>
+ *
+ *
+ * @see http://tools.ietf.org/html/rfc6020#section-9.13
+ *
+ *
+ */
 public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable, Serializable {
 
     private static final long serialVersionUID = 8467409862384206193L;
@@ -40,35 +69,67 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
     private transient String toStringCache = null;
     private transient Integer hashCodeCache = null;
 
+    /**
+     *
+     * Returns a list of path arguments.
+     *
+     * @deprecated Use {@link #getPathArguments()} instead.
+     * @return Immutable list of path arguments.
+     */
+    @Deprecated
     public List<PathArgument> getPath() {
         return path;
     }
 
+    /**
+     *
+     * Returns a ordered iteration of path arguments.
+     *
+     * @return Immutable iteration of path arguments.
+     */
+    public Iterable<PathArgument> getPathArguments() {
+        return path;
+    }
+
+    /**
+     *
+     *
+     * @deprecated Use {@link #create(Iterable)} instead.
+     * @param path
+     */
+    @Deprecated
     public InstanceIdentifier(final List<? extends PathArgument> path) {
         this.path = ImmutableList.copyOf(path);
     }
 
+    private InstanceIdentifier(final Iterable<? extends PathArgument> path) {
+        Preconditions.checkNotNull(path, "path must not be null.");
+        this.path = ImmutableList.copyOf(path);
+    }
+
     private InstanceIdentifier(final NodeIdentifier nodeIdentifier) {
         this.path = ImmutableList.<PathArgument> of(nodeIdentifier);
     }
 
+    public static final InstanceIdentifier create(final Iterable<? extends PathArgument> path) {
+        return new InstanceIdentifier(path);
+    }
+
     @Override
     public int hashCode() {
         /*
          * The hashCodeCache is safe, since the object contract requires
          * immutability of the object and all objects referenced from this
          * object.
-         *
          * Used lists, maps are immutable. Path Arguments (elements) are also
          * immutable, since the PathArgument contract requires immutability.
-         *
          * The cache is thread-safe - if multiple computations occurs at the
          * same time, cache will be overwritten with same result.
          */
         if (hashCodeCache == null) {
             final int prime = 31;
             int result = 1;
-            result = prime * result + ((path == null) ? 0 : path.hashCode());
+            result = prime * result + path.hashCode();
             hashCodeCache = result;
         }
         return hashCodeCache;
@@ -99,20 +160,37 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
         return true;
     }
 
+    /**
+     *
+     * Constructs a new Instance Identifier with new {@link NodeIdentifier} added to the end of path arguments
+     *
+     * @param name QName of {@link NodeIdentifier}
+     * @return Instance Identifier with additional path argument added to the end.
+     */
     public InstanceIdentifier node(final QName name) {
         return node(new NodeIdentifier(name));
     }
 
+    /**
+     *
+     * Constructs a new Instance Identifier with new {@link PathArgument} added to the end of path arguments
+     *
+     * @param arg Path argument which should be added to the end
+     * @return Instance Identifier with additional path argument added to the end.
+     */
     public InstanceIdentifier node(final PathArgument arg) {
-        return new InstanceIdentifier(ImmutableList.<PathArgument>builder().addAll(path).add(arg).build());
+        return create(ImmutableList.<PathArgument> builder().addAll(path).add(arg).build());
     }
 
     /**
-     * Get the relative path from an ancestor. This method attempts to perform the reverse
+     * Get the relative path from an ancestor. This method attempts to perform
+     * the reverse
      * of concatenating a base (ancestor) and a path.
      *
-     * @param ancestor Ancestor against which the relative path should be calculated
-     * @return This object's relative path from parent, or Optional.absent() if the
+     * @param ancestor
+     *            Ancestor against which the relative path should be calculated
+     * @return This object's relative path from parent, or Optional.absent() if
+     *         the
      *         specified parent is not in fact an ancestor of this object.
      */
     public Optional<InstanceIdentifier> relativeTo(final InstanceIdentifier ancestor) {
@@ -124,50 +202,100 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
         }
     }
 
-    static int hashCode( Object value ) {
-        if( value == null ) {
+    static int hashCode(final Object value) {
+        if (value == null) {
             return 0;
         }
 
-        if( value.getClass().equals( byte[].class ) ) {
-            return Arrays.hashCode( (byte[])value );
+        if (value.getClass().equals(byte[].class)) {
+            return Arrays.hashCode((byte[]) value);
         }
 
-        if( value.getClass().isArray() ) {
+        if (value.getClass().isArray()) {
             int hash = 0;
-            int length = Array.getLength( value );
-            for( int i = 0; i < length; i++ ) {
-                hash += Objects.hashCode( Array.get( value, i ) );
+            int length = Array.getLength(value);
+            for (int i = 0; i < length; i++) {
+                hash += Objects.hashCode(Array.get(value, i));
             }
 
             return hash;
         }
 
-        return Objects.hashCode( value );
+        return Objects.hashCode(value);
     }
 
     // Static factories & helpers
 
+    /**
+     *
+     * Returns a new InstanceIdentifier with only one path argument of type {@link NodeIdentifier} with supplied QName
+     *
+     * @param name QName of first node identifier
+     * @return Instance Identifier with only one path argument of type {@link NodeIdentifier}
+     */
     public static InstanceIdentifier of(final QName name) {
         return new InstanceIdentifier(new NodeIdentifier(name));
     }
 
+    /**
+     *
+     * Returns new builder for InstanceIdentifier with empty path arguments.
+     *
+     * @return new builder for InstanceIdentifier with empty path arguments.
+     */
     static public InstanceIdentifierBuilder builder() {
         return new BuilderImpl();
     }
 
+    /**
+    *
+    * Returns new builder for InstanceIdentifier with path arguments copied from original instance identifier.
+    *
+    * @param origin Instace Identifier from which path arguments are copied.
+    * @return new builder for InstanceIdentifier with path arguments copied from original instance identifier.
+    */
     static public InstanceIdentifierBuilder builder(final InstanceIdentifier origin) {
         return new BuilderImpl(origin.getPath());
     }
-
+   /**
+    *
+    * Returns new builder for InstanceIdentifier with first path argument set to {@link NodeIdentifier}.
+    *
+    * @param node QName of first {@link NodeIdentifier} path argument.
+    * @return  new builder for InstanceIdentifier with first path argument set to {@link NodeIdentifier}.
+    */
     public static InstanceIdentifierBuilder builder(final QName node) {
         return builder().node(node);
     }
 
-    public interface PathArgument extends Immutable, Serializable {
+    /**
+     *
+     * Path argument / component of InstanceIdentifier
+     *
+     * Path argument uniquelly identifies node in data tree on particular
+     * level.
+     * <p>
+     * This interface itself is used as common parent for actual
+     * path arguments types and should not be implemented by user code.
+     * <p>
+     * Path arguments SHOULD contain only minimum of information
+     * required to uniquely identify node on particular subtree level.
+     *
+     * For actual path arguments types see:
+     * <ul>
+     * <li>{@link NodeIdentifier} - Identifier of container or leaf
+     * <li>{@link NodeIdentifierWithPredicates} - Identifier of list entries, which have key defined
+     * <li>{@link AugmentationIdentifier} - Identifier of augmentation
+     * <li>{@link NodeWithValue} - Identifier of leaf-list entry
+     * </ul>
+     *
+     *
+     *
+     */
+    public interface PathArgument extends Comparable<PathArgument>, Immutable, Serializable {
 
         /**
-         * If applicable returns uniqee QName of data node as defined in YANG
+         * If applicable returns unique QName of data node as defined in YANG
          * Schema.
          *
          * This method may return null, if the corresponding schema node, does
@@ -179,34 +307,92 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
 
     }
 
+    private static abstract class AbstractPathArgument implements PathArgument {
+        private static final long serialVersionUID = -4546547994250849340L;
+        protected final QName nodeType;
+
+        protected AbstractPathArgument(final QName nodeType) {
+            this.nodeType = Preconditions.checkNotNull(nodeType);
+        }
+
+        @Override
+        public QName getNodeType() {
+            return nodeType;
+        }
+
+        @Override
+        public int compareTo(final PathArgument o) {
+            return nodeType.compareTo(o.getNodeType());
+        }
+
+    }
+
+    /**
+     *
+     * Fluent Builder of Instance Identifier instances
+     *
+     * @
+     *
+     */
     public interface InstanceIdentifierBuilder extends Builder<InstanceIdentifier> {
+
+        /**
+         *
+         * Adds {@link NodeIdentifier} with supplied QName to path arguments of resulting instance identifier.
+         *
+         * @param nodeType QName of {@link NodeIdentifier} which will be added
+         * @return this builder
+         */
         InstanceIdentifierBuilder node(QName nodeType);
 
+        /**
+         *
+         * Adds {@link NodeIdentifierWithPredicates} with supplied QName and key values to path arguments of resulting instance identifier.
+         *
+         * @param nodeType QName of {@link NodeIdentifierWithPredicates} which will be added
+         * @param keyValues Map of key components and their respective values for {@link NodeIdentifierWithPredicates}
+         * @return this builder
+         */
         InstanceIdentifierBuilder nodeWithKey(QName nodeType, Map<QName, Object> keyValues);
 
+        /**
+         *
+         * Adds {@link NodeIdentifierWithPredicates} with supplied QName and key, value.
+         *
+         * @param nodeType QName of {@link NodeIdentifierWithPredicates} which will be added
+         * @param key QName of key which will be added
+         * @param value value of key which will be added
+         * @return this builder
+         */
         InstanceIdentifierBuilder nodeWithKey(QName nodeType, QName key, Object value);
 
+        /**
+         *
+         * @return
+         * @deprecated use {@link #build()}
+         *
+         */
         @Deprecated
         InstanceIdentifier getIdentifier();
 
+        /**
+         *
+         * Builds an {@link InstanceIdentifier} with path arguments from this builder
+         *
+         * @return {@link InstanceIdentifier}
+         */
         InstanceIdentifier build();
     }
 
     /**
-     * Simple path argument identifying a {@link ContainerNode} or {@link LeafNode} leaf
-     * overall data tree.
+     * Simple path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.ContainerNode} or
+     * {@link org.opendaylight.yangtools.yang.data.api.schema.LeafNode} leaf in particular subtree.
      */
-    public static final class NodeIdentifier implements PathArgument, Comparable<NodeIdentifier> {
+    public static final class NodeIdentifier extends AbstractPathArgument {
         private static final long serialVersionUID = -2255888212390871347L;
-        private final QName nodeType;
 
         public NodeIdentifier(final QName node) {
-            this.nodeType = Preconditions.checkNotNull(node);
-        }
-
-        @Override
-        public QName getNodeType() {
-            return nodeType;
+            super(node);
         }
 
         @Override
@@ -231,29 +417,24 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
             return nodeType.toString();
         }
 
-        @Override
-        public int compareTo(final NodeIdentifier o) {
-            return nodeType.compareTo(o.nodeType);
-        }
     }
 
     /**
-     * Composite path argument identifying a {@link MapEntryNode} leaf
+     * Composite path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode} leaf
      * overall data tree.
      */
-    public static final class NodeIdentifierWithPredicates implements PathArgument {
+    public static final class NodeIdentifierWithPredicates extends AbstractPathArgument {
         private static final long serialVersionUID = -4787195606494761540L;
 
-        private final QName nodeType;
         private final Map<QName, Object> keyValues;
 
         public NodeIdentifierWithPredicates(final QName node, final Map<QName, Object> keyValues) {
-            this.nodeType = Preconditions.checkNotNull(node);
+            super(node);
             this.keyValues = ImmutableMap.copyOf(keyValues);
         }
 
         public NodeIdentifierWithPredicates(final QName node, final QName key, final Object value) {
-            this( node, ImmutableMap.of(key, value) );
+            this(node, ImmutableMap.of(key, value));
         }
 
         @Override
@@ -276,8 +457,8 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
 
         private int hashKeyValues() {
             int hash = 0;
-            for( Entry<QName,Object> entry: keyValues.entrySet() ) {
-                hash += Objects.hashCode( entry.getKey() ) + InstanceIdentifier.hashCode( entry.getValue() );
+            for (Entry<QName, Object> entry : keyValues.entrySet()) {
+                hash += Objects.hashCode(entry.getKey()) + InstanceIdentifier.hashCode(entry.getValue());
             }
 
             return hash;
@@ -312,15 +493,15 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
             return true;
         }
 
-        private boolean keyValuesEquals( Map<QName, Object> otherKeyValues ) {
-            if( otherKeyValues == null || keyValues.size() != otherKeyValues.size() ) {
+        private boolean keyValuesEquals(final Map<QName, Object> otherKeyValues) {
+            if (otherKeyValues == null || keyValues.size() != otherKeyValues.size()) {
                 return false;
             }
 
             boolean result = true;
-            for( Entry<QName,Object> entry: keyValues.entrySet() ) {
-                if( !otherKeyValues.containsKey( entry.getKey() ) ||
-                    !Objects.deepEquals( entry.getValue(), otherKeyValues.get( entry.getKey() ) ) ) {
+            for (Entry<QName, Object> entry : keyValues.entrySet()) {
+                if (!otherKeyValues.containsKey(entry.getKey())
+                        || !Objects.deepEquals(entry.getValue(), otherKeyValues.get(entry.getKey()))) {
 
                     result = false;
                     break;
@@ -340,14 +521,13 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
      * Simple path argument identifying a {@link LeafSetEntryNode} leaf
      * overall data tree.
      */
-    public static final class NodeWithValue implements PathArgument {
+    public static final class NodeWithValue extends AbstractPathArgument {
         private static final long serialVersionUID = -3637456085341738431L;
 
-        private final QName nodeType;
         private final Object value;
 
         public NodeWithValue(final QName node, final Object value) {
-            this.nodeType = Preconditions.checkNotNull(node);
+            super(node);
             this.value = value;
         }
 
@@ -364,7 +544,7 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
         public int hashCode() {
             final int prime = 31;
             int result = 1;
-            result = prime * result + ((value == null) ? 0 : InstanceIdentifier.hashCode( value ) );
+            result = prime * result + ((value == null) ? 0 : InstanceIdentifier.hashCode(value));
             result = prime * result + ((nodeType == null) ? 0 : nodeType.hashCode());
             return result;
         }
@@ -392,8 +572,18 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
     }
 
     /**
-     * Composite path argument identifying a {@link AugmentationNode} leaf
-     * overall data tree.
+     * Composite path argument identifying a {@link org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode} node in
+     * particular subtree.
+     *
+     * Augmentation is uniquely identified by set of all possible child nodes.
+     * This is possible
+     * to identify instance of augmentation,
+     * since RFC6020 states that <code>augment</code> that augment
+     * statement must not add multiple nodes from same namespace
+     * / module to the target node.
+     *
+     *
+     * @see http://tools.ietf.org/html/rfc6020#section-7.15
      */
     public static final class AugmentationIdentifier implements PathArgument {
         private static final long serialVersionUID = -8122335594681936939L;
@@ -405,18 +595,36 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
             throw new UnsupportedOperationException("Augmentation node has no QName");
         }
 
+        /**
+         *
+         * Construct new augmentation identifier using supplied set of possible
+         * child nodes
+         *
+         * @param childNames
+         *            Set of possible child nodes.
+         */
         public AugmentationIdentifier(final Set<QName> childNames) {
             this.childNames = ImmutableSet.copyOf(childNames);
         }
 
         /**
          * Augmentation node has no QName
+         *
+         * @deprecated Use
+         *             {@link AugmentationIdentifier#AugmentationIdentifier(Set)}
+         *             instead.
          */
         @Deprecated
         public AugmentationIdentifier(final QName nodeType, final Set<QName> childNames) {
             this(childNames);
         }
 
+        /**
+         *
+         * Returns set of all possible child nodes
+         *
+         * @return set of all possible child nodes.
+         */
         public Set<QName> getPossibleChildNames() {
             return childNames;
         }
@@ -451,6 +659,31 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
         public int hashCode() {
             return childNames.hashCode();
         }
+
+        @Override
+        public int compareTo(PathArgument o) {
+            if (!(o instanceof AugmentationIdentifier)) {
+                return -1;
+            }
+            AugmentationIdentifier other = (AugmentationIdentifier) o;
+            Set<QName> otherChildNames = other.getPossibleChildNames();
+            int thisSize = childNames.size();
+            int otherSize = otherChildNames.size();
+            if (thisSize == otherSize) {
+                Iterator<QName> otherIterator = otherChildNames.iterator();
+                for (QName name : childNames) {
+                    int c = name.compareTo(otherIterator.next());
+                    if (c != 0) {
+                        return c;
+                    }
+                }
+                return 0;
+            } else if (thisSize < otherSize) {
+                return 1;
+            } else {
+                return -1;
+            }
+        }
     }
 
     private static class BuilderImpl implements InstanceIdentifierBuilder {
@@ -526,10 +759,8 @@ public class InstanceIdentifier implements Path<InstanceIdentifier>, Immutable,
          * The toStringCache is safe, since the object contract requires
          * immutability of the object and all objects referenced from this
          * object.
-         *
          * Used lists, maps are immutable. Path Arguments (elements) are also
          * immutable, since the PathArgument contract requires immutability.
-         *
          * The cache is thread-safe - if multiple computations occurs at the
          * same time, cache will be overwritten with same result.
          */
index 6032b0dfe6534aab9823c9c7c1bee10905ddb7a1..9057b747d31d62ceebfd207ff95379bf81b75c16 100644 (file)
@@ -31,6 +31,8 @@ public interface Node<T> extends Entry<QName, T> {
      * Returns parent node
      *
      * @return parent node
+     * @deprecated Unused, Deprecated because  reference to parent disallows of sharing one instance
+     *   in multiple trees / subtress.
      */
     @Deprecated
     CompositeNode getParent();
index f7c7d5c3355cab9c377b0f9e3c8f159a99c9250a..9a98405705ecb6d8ce7b093db5de670b81cf744d 100644 (file)
@@ -9,7 +9,12 @@ package org.opendaylight.yangtools.yang.data.api.codec;
 
 import org.opendaylight.yangtools.concepts.Codec;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
-
+/**
+ *
+ * Codec which serializes / deserializes InstanceIdentifier
+ *
+ * @param <T> Target type
+ */
 public interface InstanceIdentifierCodec<T>  extends Codec<T,InstanceIdentifier> {
     @Override
     T serialize(InstanceIdentifier data);
diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/AnyXmlNode.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/AnyXmlNode.java
new file mode 100644 (file)
index 0000000..6d89b60
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2014 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.data.api.schema;
+
+import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
+import org.opendaylight.yangtools.yang.data.api.Node;
+
+/**
+ * Anyxml normalizedNode.
+ *
+ * <p>
+ * This node contains values for anyxml as either SimpleNode or CompositeNode.
+ * The concrete value depends on the current value of anyxml node.
+ * </p>
+ *
+ * <p>
+ * For yang node: anyxml foo;
+ *
+ * <ul>
+ * <li>
+ * with xml value:
+ * <pre>
+ * {@code <foo>justSomeString</foo>}
+ * </pre>
+ * </li>
+ *
+ * this AnyXmlNode returns SimpleNode with QName{namespace=someNamespace, revision=someRevision, localName=foo} and value="justSomeString"
+ *
+ * <li>
+ * but with xml value:
+ * <pre>
+ * {@code <foo><bar>stringInXml</bar></foo>}
+ * </pre>
+ * </li>
+ *
+ * this AnyXmlNode returns CompositeNode with QName{}namespace=someNamespace, revision=someRevision, localName=foo}
+ * and values [SimpleNode with QName{}namespace=someNamespace, revision=someRevision, localName=bar} and value="stringInXml"]
+ * </ul>
+ * </p>
+ */
+public interface AnyXmlNode extends AttributesContainer, DataContainerChild<NodeIdentifier, Node<?>> {
+
+    @Override
+    NodeIdentifier getIdentifier();
+
+    /**
+     * @return anyxml node value represented as SimpleNode or CompositeNode.
+     * Returned node contains top level element that duplicates the anyxml node.
+     */
+    @Override
+    Node<?> getValue();
+}
index 1653b5705e0f0fa14638e1716b410269c6fdfd45..fa7a03fa5698ae4fa1c5902a7aafa26ef2af72ec 100644 (file)
@@ -10,12 +10,16 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 
-import com.google.common.base.Optional;
 
 /**
  *
- * Node representing Augmentation.
+ * Data instance of <code>augment</code> assiociated with parent node.
+ * 
+ * Augmentation is addition of subtree defined by other external YANG Model and
+ * is schema for subtree is described by instance of  {@link AugmentationSchema}
+ * associated with parent node of this node.
  *
  * Augmentation node MUST NOT be direct child of other augmentation node.
  *
@@ -25,12 +29,21 @@ public interface AugmentationNode extends //
     DataContainerNode<AugmentationIdentifier>,
     DataContainerChild<InstanceIdentifier.AugmentationIdentifier, Iterable<DataContainerChild<? extends PathArgument, ?>>> {
 
+    /**
+     * Gets identifier of augmentation node
+     * 
+     * Returned identifier of augmentation node contains all possible 
+     * direct child QNames.
+     * 
+     * This is sufficient to identify instance of augmentation,
+     * since RFC6020 states that <code>augment</code> that augment
+     * statement must not add multiple nodes from same namespace 
+     * / module
+     * to the target node.
+     * 
+     * @return Identifier which uniquelly identifies augmentation in particular subtree.
+     * 
+     */
     @Override
-    Iterable<DataContainerChild<? extends PathArgument, ?>> getValue();
-
-    @Override
-    Optional<DataContainerChild<? extends PathArgument, ?>> getChild(PathArgument child);
-
-    @Override
-    AugmentationIdentifier getIdentifier();
+    public AugmentationIdentifier getIdentifier();
 }
index 06d1325ab97311374e70f8b69684de008347b629..6ce46cb044f17a27c791d7735e65c9ab8d46f971 100644 (file)
@@ -10,13 +10,16 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 
-import com.google.common.base.Optional;
-
 /**
  *
- * Node representing choice.
+ * Node representing data instance of <code>choice</code>.
  *
- * @author Tony Tkacik
+ * Choice node is instance of one of possible alternatives, from which
+ * only one is allowed to exist at one time in particular context of parent node.
+   YANG Model and
+ * schema for choice is described by instance of  {@link org.opendaylight.yangtools.yang.model.api.ChoiceNode}.
+ * Valid alternatives of subtree are described by instances of {@link org.opendaylight.yangtools.yang.model.api.ChoiceCaseNode}
+ * which are retrieved via {@link org.opendaylight.yangtools.yang.model.api.ChoiceNode#getCases()}.
  *
  */
 public interface ChoiceNode extends //
@@ -24,9 +27,4 @@ public interface ChoiceNode extends //
         DataContainerNode<NodeIdentifier>,
         DataContainerChild<NodeIdentifier, Iterable<DataContainerChild<? extends PathArgument, ?>>> {
 
-    @Override
-    NodeIdentifier getIdentifier();
-
-    @Override
-    Optional<DataContainerChild<? extends PathArgument, ?>> getChild(PathArgument child);
 }
index 5584e70d2827b3e13a4f45f0b6b1394bbec474bd..b4872df34c408851184f5e8f187425c8435850e6 100644 (file)
@@ -11,16 +11,17 @@ import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 
-import com.google.common.base.Optional;
-
+/**
+ * Data subtree with cardinality 0..1 in the context of parent node
+ * 
+ * Node which does not have value but contains valid {@link DataContainerChild} nodes.
+ * 
+ * Schema of this node is described by instance of {@link org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode}.
+ * 
+ */
 public interface ContainerNode extends //
         AttributesContainer,
         DataContainerNode<NodeIdentifier>,
         DataContainerChild<NodeIdentifier, Iterable<DataContainerChild<? extends PathArgument, ?>>> {
 
-    @Override
-    NodeIdentifier getIdentifier();
-
-    @Override
-    Optional<DataContainerChild<? extends PathArgument, ?>> getChild(PathArgument child);
 }
index f0520eed9bde3ecf1f550416e601fe1d30f987f6..c1e3844540430e9d35bfb97aeef35cfeca956af4 100644 (file)
@@ -12,22 +12,24 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 /**
  *
  * Marker interface for direct children of {@link DataContainerNode}.
- *
- * Implementation notes:
+ * 
+ * <h3>Implementation notes</h3>
  * This interface should not be implemented directly, but rather using one
  * of its subinterfaces:
  *
+ * <ul>
+ * <li>{@link LeafNode}
+ * <li>{@link ContainerNode}
+ * <li>{@link ChoiceNode}
+ * <li>{@link MapNode}
+ * <li>{@link AugmentationNode}
+ *</ul>
  *
- * {@link LeafNode}
- * {@link ContainerNode}
- * {@link ChoiceNode}
- * {@link MapNode}
- * {@link AugmentationNode}
- *
- * @param <K>
- * @param <V>
+ * @param <K> Path Argument Type which is used to identify node
+ * @param <V> Value type
  */
 public interface DataContainerChild<K extends PathArgument,V> extends NormalizedNode<K, V> {
+
     @Override
     K getIdentifier();
 }
index 717f79dd449b20db62e8876d68c3488efa07a7c9..0c3fc224bdabbfac2c3e1f278f0e56fecbc79ef9 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * Copyright (c) 2014 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
@@ -9,16 +8,39 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 
-import com.google.common.base.Optional;
-
+/**
+ *
+ * Abstract node which does not have value but contains valid {@link DataContainerChild} nodes.
+ *
+ * Schema of this node is described by instance of {@link org.opendaylight.yangtools.yang.model.api.DataNodeContainer}.
+ *
+ * <h2>Implementation notes</h2>
+ * This interface should not be implemented directly, but rather implementing one of it's subclasses
+ * <ul>
+ * <li>{@link ContainerNode}
+ * <li>{@link MapEntryNode}
+ * <li>{@link UnkeyedListEntryNode}
+ * <li>{@link ChoiceNode}
+ * <li>{@link AugmentationNode}
+ * </ul>
+ *
+ * @param <K> {@link PathArgument} which identifies instance of {@link DataContainerNode}
+ */
 public interface DataContainerNode<K extends PathArgument> extends //
         NormalizedNodeContainer<K, PathArgument, DataContainerChild<? extends PathArgument, ?>> {
-    @Override
-    K getIdentifier();
 
+    /**
+     * Returns iteration of all child nodes
+     *
+     * Order of returned child nodes may be defined by subinterfaces.
+     *
+     * <b>Implementation Notes:</b>
+     * <p>
+     * All nodes returned in this iterable, MUST also be accessible via
+     * {@link #getChild(PathArgument)} using their associated identifier.
+     *
+     * @return Iteration of all child nodes
+     */
     @Override
     Iterable<DataContainerChild<? extends PathArgument, ?>> getValue();
-
-    @Override
-    Optional<DataContainerChild<? extends PathArgument, ?>> getChild(PathArgument child);
 }
index d113dd2c33c04eb481c6fa617a9e28728c6f6e15..89d9f49342b01bd182da8aee4786113a56c43275 100644 (file)
@@ -10,9 +10,28 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
 
+/**
+ *
+ * Leaf node with multiplicity 0..1
+ *
+ * Leaf node has a value, but no child nodes in the data tree, schema
+ * for leaf node and its value is described by {@link org.opendaylight.yangtools.yang.model.api.LeafSchemaNode}.
+ *
+ * @param <T> Value type
+ */
 public interface LeafNode<T> extends //
         AttributesContainer,
         DataContainerChild<NodeIdentifier, T> {
+
+
+    /**
+     *
+     * Returns value of this leaf node
+     *
+     * @return Returned value of this leaf node. Value SHOULD meet criteria defined by schema.
+     *
+     */
     @Override
-    NodeIdentifier getIdentifier();
+    T getValue();
+
 }
index 663eb64da1dc7b31b8c9c890f22484813b23e5ea..103f88ff534c0bd14af9083487e61c41d0a0b3ad 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * Copyright (c) 2014 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
@@ -10,9 +9,49 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue;
 
-public interface LeafSetEntryNode<T> extends
-        AttributesContainer,
-        NormalizedNode<NodeWithValue, T> {
+/**
+ *
+ * Leaf node with multiplicity 0...n
+ *
+ * Leaf node has a value, but no child nodes in the data tree, schema
+ * for leaf node and its value is described by
+ * {@link org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode}.
+ *
+ * @param <T>
+ *            Value type
+ */
+public interface LeafSetEntryNode<T> extends AttributesContainer, NormalizedNode<NodeWithValue, T> {
+
+    /**
+     * Returns {@link NodeWithValue} which identifies this leaf set entry.
+     *
+     * Returned {@link NodeWithValue} contains same value as this node.
+     *
+     * <h3>Implementation notes</h3> Invocation of
+     * {@link NodeWithValue#getValue()} on returned instance of
+     * {@link NodeWithValue} must returns
+     * same value as invocation of {@link #getValue()}, such as
+     * following condition is allways met:
+     * <code>true == this.getIdentifier().getValue().equals(this.getValue())</code>
+     *
+     *
+     * @return {@link NodeWithValue} which identifies this leaf set entry.
+     */
     @Override
     NodeWithValue getIdentifier();
+
+    /**
+     *
+     * Returns value of this leaf node
+     *
+     * <h3>Implementation notes</h3> Invocation of {@link #getValue()} must
+     * provides same value as value in {@link #getIdentifier()}.
+     * <code>true == this.getIdentifier().getValue().equals(this.getValue())</code>
+     *
+     * @return Returned value of this leaf node. Value SHOULD meet criteria
+     *         defined by schema.
+     *
+     */
+    @Override
+    public T getValue();
 }
index 32b389342aa349b20edb9062659aa447d98efac3..70829e1eb69f7cee54610fd5a20189e431d1c39b 100644 (file)
@@ -10,19 +10,20 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue;
 
-import com.google.common.base.Optional;
-
+/**
+ *
+ * Node representing set of simple leaf nodes.
+ *
+ * Node containing instances of {@link LeafSetEntryNode}
+ *
+ * Schema and semantics of this node are described by instance of {@link org.opendaylight.yangtools.yang.model.api.LeafListSchema}.
+ *
+ *
+ * @param <T> Type of leaf node values.
+ */
 public interface LeafSetNode<T> extends
     MixinNode, //
     DataContainerChild<NodeIdentifier, Iterable<LeafSetEntryNode<T>>>, //
     NormalizedNodeContainer<NodeIdentifier, NodeWithValue,LeafSetEntryNode<T>> {
 
-    @Override
-    NodeIdentifier getIdentifier();
-
-    @Override
-    Iterable<LeafSetEntryNode<T>> getValue();
-
-    @Override
-    Optional<LeafSetEntryNode<T>> getChild(NodeWithValue child);
 }
index b5eb47e4cf48787ccacf3bbf18e4f49dc3820869..94ea04937c490a085820d857a20b597b91cd859e 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * Copyright (c) 2014 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
@@ -10,10 +9,26 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
 
-public interface MapEntryNode extends
-        AttributesContainer,
-        DataContainerNode<NodeIdentifierWithPredicates> {
+/**
+ *
+ * Instance of Map entry, this node does not contains value, but child nodes.
+ *
+ */
+public interface MapEntryNode extends AttributesContainer, DataContainerNode<NodeIdentifierWithPredicates> {
 
+    /**
+     *
+     * Returns identifier of this node in parent map node
+     *
+     * Contents of identifier is defined by <code>key</code> (
+     * {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.ListSchemaNode#getKeyDefinition()}
+     * ) statement in YANG schema for associated list item and child {@link LeafNode}s
+     * values with {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier}
+     * as defined in the schema.
+     *
+     * @return identifier of this node in the context of parent node
+     */
     @Override
     NodeIdentifierWithPredicates getIdentifier();
+
 }
index ec5bfc0448737c97d883f76355ac146d972bbe35..1b916c21ff771993e0fdf9fdf10c82108e0641e8 100644 (file)
@@ -11,9 +11,12 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifie
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates;
 
 /**
- * Containment node, which contains {@link MapEntryNode} of the same type.
+ * Containment node, which contains {@link MapEntryNode} of the same type, which may
+ * be quickly retrieved using key.
  *
- * This node maps to the list node in YANG schema.
+ * This node maps to the list node in YANG schema, schema and semantics of this node,
+ * its children and key construction is  defined by YANG <code>list</code>
+ * statement and its <code>key</code> and <code>ordered-by</code> substatements.
  *
  */
 public interface MapNode extends //
@@ -21,6 +24,4 @@ public interface MapNode extends //
         DataContainerChild<NodeIdentifier, Iterable<MapEntryNode>>,
         NormalizedNodeContainer<NodeIdentifier, NodeIdentifierWithPredicates, MapEntryNode> {
 
-    @Override
-    NodeIdentifier getIdentifier();
 }
index 2fec77fc7f6d6ef3c59e5e70bad139fd2c5b1af2..4e3416fd1fb22b5b83243cd1e922cdf5d6ee8d86 100644 (file)
@@ -1,3 +1,10 @@
+/*
+ * Copyright (c) 2014 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.data.api.schema;
 
 import org.opendaylight.yangtools.concepts.Identifiable;
@@ -10,8 +17,8 @@ import org.opendaylight.yangtools.yang.data.api.Node;
  * Node which is normalized according to the YANG schema
  * is identifiable by {@link InstanceIdentifier}.
  *
- *
- * @author Tony Tkacik
+ * See subinterfaces of this interface for concretization
+ * of node.
  *
  * @param <K> Local identifier of node
  * @param <V> Value of node
index 48d0b6eeb62c38a6b9cc4d0299ac959a3837e70a..b3d2bdb1af17381eb1f85f137eef46529dc45687 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * Copyright (c) 2014 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
@@ -12,10 +11,22 @@ import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument;
 import com.google.common.base.Optional;
 
 /**
- *
- * @param <I> Node Identifier type
- * @param <K> Child Node Identifier type
- * @param <V> Child Node type
+ * Node which is not leaf, but has child {@link NormalizedNode}s as its valzue.
+ * 
+ * 
+ * NormalizedNodeContainer does not have a value, but it has a child
+ * nodes. Definition of possible and valid child nodes is introduced
+ * in subclasses of this interface.
+ * 
+ * This interface should not be used directly, but rather use of of derived subinterfaces
+ * such as {@link DataContainerNode}, {@link MapNode}, {@link LeafSetNode}.
+ * 
+ * @param <I>
+ *            Node Identifier type
+ * @param <K>
+ *            Child Node Identifier type
+ * @param <V>
+ *            Child Node type
  */
 public interface NormalizedNodeContainer<I extends PathArgument, K extends PathArgument, V extends NormalizedNode<? extends K, ?>>
         extends NormalizedNode<I, Iterable<V>> {
@@ -23,14 +34,20 @@ public interface NormalizedNodeContainer<I extends PathArgument, K extends PathA
     @Override
     I getIdentifier();
 
+    /**
+     * Returns immutable iteration of child nodes of this node.
+     * 
+     */
     @Override
     Iterable<V> getValue();
 
     /**
-     *
-     *
+     * Returns child node identified by provided key.
+     * 
      * @param child
-     * @return
+     *            Path argument identifying child node
+     * @return Optional with child node if child exists.
+     *         {@link Optional#absent()} if child does not exists.
      */
     Optional<V> getChild(K child);
 }
index 63fe710241271aee0bf3dcce4f7042354812b81c..11bc39a28e8bf025c507e49cd62cf7909bf5c5e0 100644 (file)
@@ -7,6 +7,19 @@
  */
 package org.opendaylight.yangtools.yang.data.api.schema;
 
+
+/**
+ *
+ * Leaf set node which preserves user-supplied ordering.
+ *
+ * This node represents a data instance of <code>leaf-list</code> with
+ * <code>ordered-by user;</code> substatement.
+ *
+ * Except preserving user-ordering all other semantics and behaviour is same
+ * as in {@link LeafSetNode}.
+ *
+ * @param <T> Value type of Leaf entries
+ */
 public interface OrderedLeafSetNode<T> extends LeafSetNode<T>, OrderedNodeContainer<LeafSetEntryNode<T>> {
 
 }
index 963d7dab0b1068e29b6ad9518381a51f8ac6b07b..23aa10ed638af55d0002c642b0d7b3c5c4ef4249 100644 (file)
@@ -1,12 +1,24 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * Copyright (c) 2014 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.data.api.schema;
 
+/**
+ *
+ * Map node which preserves user-supplied ordering.
+ *
+ * <p>
+ * This node represents a data instance of <code>list</code> with
+ * <code>ordered-by user;</code> substatement and <code>key</code> definition.
+ *
+ * <p>
+ * Except preserving user-ordering all other semantics and behaviour is same as
+ * in {@link MapNode}.
+ *
+ */
 public interface OrderedMapNode extends MapNode, OrderedNodeContainer<MapEntryNode> {
 
 }
index 44b1a4b5da6575e6eeb1eb021d113977f6526b46..72e2901e75dee19c3d3950a56be706fe96bc4b73 100644 (file)
@@ -9,7 +9,28 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
 
+/**
+ *
+ * Normalized Node container which preserves user supplied ordering
+ * and allows addressing of child elements by positiion.
+ *
+ * @param <V>
+ */
 public interface OrderedNodeContainer<V extends NormalizedNode<?, ?>> extends MixinNode, NormalizedNode<NodeIdentifier, Iterable<V>> {
+
+    /**
+     * Returns child node by position
+     *
+     * @param position Position of child node
+     * @return Child Node
+     * @throws IndexOutOfBoundsException
+     */
     V getChild(int position);
+
+    /**
+     * Returns count of child nodes
+     *
+     * @return count of child nodes.
+     */
     int getSize();
 }
index 28f3f953c0092ee032970188d96b3b2b2719f4a5..c1dca0f700c92b795de51c10229206fe622128b0 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * Copyright (c) 2014 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
@@ -9,6 +8,17 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
 
+/**
+ * List entry node, which does not have value, but child nodes.
+ *
+ * Represents an instance of data, which schema is instance of
+ * {@link org.opendaylight.yangtools.yang.model.api.ListSchemaNode} with key undefined.
+ *
+ * This nodes itself does not contain any ordering information, user supplied
+ * ordering is preserved by parent node, which is instance of {@link UnkeyedListNode}.
+ *
+ *
+ */
 public interface UnkeyedListEntryNode extends DataContainerNode<NodeIdentifier> {
 
 }
index d6ac9a152d3d1bd634cc41bd93c24130d344fd35..ff2ca1f7d96cbbd610a7486356a91ea0d8373a04 100644 (file)
@@ -9,6 +9,22 @@ package org.opendaylight.yangtools.yang.data.api.schema;
 
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier;
 
+
+/**
+ *
+ * Containment node, which contains {@link UnkeyedListEntryNode} of the same type, which may
+ * be quickly retrieved using key.
+ *
+ * <p>
+ * This node maps to the <code>list</code> statement in YANG schema,
+ * which did not define <code>key</code> substatement.
+ *
+ * <p>
+ * Ordering of the elements is user-defined during construction of instance of this
+ * interface. Ordered view of elements (iteration)
+ * is provided by {@link #getValue()} call.
+ *
+ */
 public interface UnkeyedListNode extends
     DataContainerChild<NodeIdentifier, Iterable<UnkeyedListEntryNode>>,
     OrderedNodeContainer<UnkeyedListEntryNode> {
diff --git a/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/package-info.java b/yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/package-info.java
new file mode 100644 (file)
index 0000000..bed1483
--- /dev/null
@@ -0,0 +1,146 @@
+/**
+ *
+ * Definition of normalized YANG DOM Model
+ *
+ * Normalized DOM Model brings more direct mapping between YANG Model, DOM
+ * representation of data
+ *
+ * <h2>Normalized DOM Model</h2>
+ *
+ * <h3>Node Types</h3>
+ * <ul>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode} -
+ * Base type representing a node in a tree structure; all nodes are derived from
+ * it, it contains a leaf identifier and a value.
+ * <ul>
+ * <li>
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode} -
+ * Node which contains multiple leafs; it does not have a direct representation
+ * in the YANG syntax.
+ * <ul>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.ContainerNode} -
+ * Node, which represents a leaf which can occur only once per parent node; it
+ * contains multiple child leaves and maps to the <i>container</i> statement in
+ * YANG.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode} -
+ * Node which represents a leaf, which can occur multiple times; a leave is
+ * uniquely identified by the value of its key. A MapEntryNode may contain
+ * multiple child leaves. MapEntryNode maps to the instance of <i>list</i> in
+ * YANG.</li>
+ * <li>
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListEntryNode}
+ * - Node which represents a leaf, which can occur multiple times; a leave is
+ * uniquely identified by the value of its key. A MapEntryNode may contain
+ * multiple child leaves. MapEntryNode maps to the instance of <i>list</i> in
+ * YANG.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode} - Node
+ * which represents a leaf, which occurs mostly once per parent node, but
+ * possible values could have different types. Maps to <i>choice</i> statement.
+ * Types maps to the <i>case</i> statements for that <i>choice</i>.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode}
+ * - Node which represents a leaf, which occurs mostly once per parent node.</li>
+ * </ul>
+ * </li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.LeafNode} - Node
+ * which represents a leaf, which occurs mostly once per parent node. Contains
+ * simple value.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode}
+ * - Node which represents a leaf, which type could occurs multiple times per
+ * parent node. Maps to to the instances of <i>leaf-list</i> in YANG.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode} -
+ * Special node, which can occur only once per parent node; its leaves are
+ * LeafSetEntryNode nodes of specified type. Maps into the <i>leaf-list</i> in
+ * YANG.</li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.MapNode} - Special
+ * node, which can occur only once per parent node; its leaves are MapEntryNode
+ * nodes.
+ * <ul>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.OrderedMapNode} -
+ * Special node, which can occur only once per parent node; its leaves are
+ * MapEntryNode nodes.</li>
+ * </ul>
+ * </li>
+ * <li> {@link org.opendaylight.yangtools.yang.data.api.schema.UnkeyedListNode} -
+ * Special node, which can occur only once per parent node; its leaves are
+ * MapEntryNode nodes.</li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * <h3>Tree / subtree structure</h3> <h4>Grammar representation</h4>
+ *
+ * <pre>
+ *  {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument}*
+ *  {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier}| {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates}| {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue} | {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier}
+ *
+ *  TreeRoot = {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode}
+ *  {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode} = ( {@link org.opendaylight.yangtools.yang.data.api.schema.LeafNode} | {@link org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode} | {@link org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode} | {@link org.opendaylight.yangtools.yang.data.api.schema.MapNode} | {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode})*
+ *  ContainerDataNode = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier} {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode}
+ *
+ *  {@link org.opendaylight.yangtools.yang.data.api.schema.LeafNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier} SimpleValue
+ *  {@link org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.AugmentationIdentifier} {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode}
+ *  {@link org.opendaylight.yangtools.yang.data.api.schema.MapNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier} {@link org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode}
+ *  {@link org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifierWithPredicates} {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode}
+ *
+ *  // Special nodes
+ *  {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier} {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode}*
+ *  {@link org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeIdentifier} {@link org.opendaylight.yangtools.yang.data.api.schema.DataContainerNode}
+ *  {@link org.opendaylight.yangtools.yang.data.api.schema.LeafSetEntryNode} = {@link org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.NodeWithValue} SimpleValue
+ * </pre>
+ *
+ * The resulting tree organization is following:
+ *
+ * <ul>
+ * <li>(DataContainerNode)
+ * <ul>
+ * <li>(0..n) LeafNode</li>
+ * <li>(0..n) LeafSetNode
+ * <ul>
+ * <li>(0..n) LeafSetEntryNode</li>
+ * </ul>
+ * </li>
+ * <li>(0..n) ContainerNode
+ * <ul>
+ * <li>(Same as DataContainerNode)</li>
+ * </ul>
+ * </li>
+ * <li>(0..n) ContainerNode
+ * <ul>
+ * <li>(Same as DataContainerNode)</li>
+ * </ul>
+ * </li>
+ * <li>(0..n) MapNode
+ * <ul>
+ * <li>(0..n) MapEntryNode
+ * <ul>
+ * <li>(Same as DataContainerNode)</li>
+ * </ul>
+ * </li>
+ * </ul>
+ * </li>
+ * <li>(0..n) AugmentationNode
+ * <ul>
+ * <li>(Same as DataContainerNode)</li>
+ * </ul>
+ * </li>
+ * </ul>
+ * </li>
+ * </ul>
+ *
+ * <h3>Ordering of child nodes</h3>
+ *
+ * Ordering of child nodes is not enforced by this API definition, unless
+ * explicitly stated by subclasses of
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.OrderedNodeContainer}
+ * which marks nodes with semantic constrain to preserve user-supplied ordering.
+ * <p>
+ * Clients should not expect any specific ordering of child nodes for interfaces
+ * from this package which does not extend
+ * {@link org.opendaylight.yangtools.yang.data.api.schema.OrderedNodeContainer},
+ * since implementations are not required to have well-defined order, which
+ * allows for more efficient implementations. If such ordering is required by
+ * clients for serialization / debugability it SHOULD be done externally in
+ * code using these interfaces.
+ *
+ */
+package org.opendaylight.yangtools.yang.data.api.schema;
\ No newline at end of file
index 00d4160f5c9ffb3260d8deb993b633fcb9d81dc5..45819ccfe56842e9b0aa1175bad60275f758eb39 100644 (file)
@@ -8,6 +8,8 @@
 package org.opendaylight.yangtools.yang.data.impl.schema;
 
 import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
 import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ChoiceNode;
 import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
@@ -24,6 +26,8 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContaine
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.ListNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAnyXmlNodeBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAnyXmlNodeSchemaAwareBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableAugmentationNodeSchemaAwareBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableChoiceNodeBuilder;
@@ -44,6 +48,7 @@ import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOr
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableOrderedMapNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListEntryNodeBuilder;
 import org.opendaylight.yangtools.yang.data.impl.schema.builder.impl.ImmutableUnkeyedListNodeBuilder;
+import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.LeafListSchemaNode;
@@ -74,6 +79,15 @@ public final class Builders {
         return ImmutableLeafSetEntryNodeSchemaAwareBuilder.create(schema);
     }
 
+    public static <T> NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> anyXmlBuilder() {
+        return ImmutableAnyXmlNodeBuilder.create();
+    }
+
+    public static <T> NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> anyXmlBuilder(
+            final AnyXmlSchemaNode schema) {
+        return ImmutableAnyXmlNodeSchemaAwareBuilder.create(schema);
+    }
+
     public static <T> ListNodeBuilder<T,LeafSetEntryNode<T>> leafSetBuilder() {
         return ImmutableLeafSetNodeBuilder.create();
     }
diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAnyXmlNodeBuilder.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAnyXmlNodeBuilder.java
new file mode 100644 (file)
index 0000000..87b7840
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.data.impl.schema.builder.impl;
+
+import java.util.Map;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.data.impl.schema.nodes.AbstractImmutableNormalizedValueAttrNode;
+
+public class ImmutableAnyXmlNodeBuilder extends AbstractImmutableNormalizedNodeBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> {
+
+    public static NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> create() {
+        return new ImmutableAnyXmlNodeBuilder();
+    }
+
+    @Override
+    public AnyXmlNode build() {
+        return new ImmutableXmlNode(getNodeIdentifier(), getValue(), getAttributes());
+    }
+
+    private static final class ImmutableXmlNode extends AbstractImmutableNormalizedValueAttrNode<InstanceIdentifier.NodeIdentifier, Node<?>> implements AnyXmlNode {
+
+        ImmutableXmlNode(final InstanceIdentifier.NodeIdentifier nodeIdentifier, final Node<?> value, final Map<QName, String> attributes) {
+            super(nodeIdentifier, value, attributes);
+        }
+    }
+}
diff --git a/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAnyXmlNodeSchemaAwareBuilder.java b/yang/yang-data-impl/src/main/java/org/opendaylight/yangtools/yang/data/impl/schema/builder/impl/ImmutableAnyXmlNodeSchemaAwareBuilder.java
new file mode 100644 (file)
index 0000000..e531654
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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.data.impl.schema.builder.impl;
+
+import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.Node;
+import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.NormalizedNodeAttrBuilder;
+import org.opendaylight.yangtools.yang.model.api.AnyXmlSchemaNode;
+
+public final class ImmutableAnyXmlNodeSchemaAwareBuilder extends ImmutableAnyXmlNodeBuilder {
+
+    private ImmutableAnyXmlNodeSchemaAwareBuilder(AnyXmlSchemaNode schema) {
+        super.withNodeIdentifier(new InstanceIdentifier.NodeIdentifier(schema.getQName()));
+    }
+
+    public static NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> create(AnyXmlSchemaNode schema) {
+        return new ImmutableAnyXmlNodeSchemaAwareBuilder(schema);
+    }
+
+    @Override
+    public NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> withValue(Node<?> value) {
+        return super.withValue(value);
+    }
+
+    @Override
+    public NormalizedNodeAttrBuilder<InstanceIdentifier.NodeIdentifier, Node<?>, AnyXmlNode> withNodeIdentifier(InstanceIdentifier.NodeIdentifier nodeIdentifier) {
+        throw new UnsupportedOperationException("Node identifier created from schema");
+    }
+}
index f2b67f46eb40f0236b56b4dc437cd1b8b70def61..7a49d58e09df3810fee9c951e0f389529d3dcc54 100644 (file)
@@ -9,6 +9,17 @@ package org.opendaylight.yangtools.yang2sources.plugin;
 
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.Maps;
+import java.io.Closeable;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import org.apache.maven.model.Resource;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.plugin.MojoFailureException;
@@ -26,20 +37,6 @@ import org.opendaylight.yangtools.yang2sources.spi.CodeGenerator;
 import org.sonatype.plexus.build.incremental.BuildContext;
 import org.sonatype.plexus.build.incremental.DefaultBuildContext;
 
-import java.io.Closeable;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-
 class YangToSourcesProcessor {
     static final String LOG_PREFIX = "yang-to-sources:";
     static final String META_INF_YANG_STRING = "META-INF" + File.separator + "yang";
@@ -124,7 +121,7 @@ class YangToSourcesProcessor {
             }
 
             if (noChange) {
-               log.info(Util.message("None of %s input files changed", LOG_PREFIX, allFiles.size()));
+                log.info(Util.message("None of %s input files changed", LOG_PREFIX, allFiles.size()));
                 return null;
             }
 
@@ -136,6 +133,13 @@ class YangToSourcesProcessor {
             List<InputStream> all = new ArrayList<>(yangsInProject);
             closeables.addAll(yangsInProject);
             Map<InputStream, Module> allYangModules;
+
+            /**
+             * Set contains all modules generated from input sources. Number of
+             * modules may differ from number of sources due to submodules
+             * (parsed submodule's data are added to its parent module). Set
+             * cannot contains null values.
+             */
             Set<Module> projectYangModules;
             try {
                 if (inspectDependencies) {
@@ -149,8 +153,10 @@ class YangToSourcesProcessor {
 
                 projectYangModules = new HashSet<>();
                 for (InputStream inProject : yangsInProject) {
-                    Module module = checkNotNull(allYangModules.get(inProject), "Cannot find module by %s", inProject);
-                    projectYangModules.add(module);
+                    Module module = allYangModules.get(inProject);
+                    if (module != null) {
+                        projectYangModules.add(module);
+                    }
                 }
 
             } finally {
index 5010b4887ae394c66aba00979af46643601f2f71..de0caedd78c3dbd1a2d429eb4c56026a45605db1 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * 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
@@ -20,7 +19,16 @@ import com.google.common.base.Optional;
 public interface AugmentationSchema extends DataNodeContainer {
 
     /**
-     * @return when statement
+     *
+     * Returns when statement
+     *
+     * If when condition is present node defined by the parent data definition
+     * statement is only valid when the returned XPath
+     * expression conceptually evaluates to "true"
+     * for a particular instance, then the node defined by the parent data
+     * definition statement is valid; otherwise, it is not.
+     *
+     * @return XPath condition
      */
     RevisionAwareXPath getWhenCondition();
 
@@ -53,12 +61,13 @@ public interface AugmentationSchema extends DataNodeContainer {
      * @return collection of all unknown nodes defined in this augmentation
      */
     List<UnknownSchemaNode> getUnknownSchemaNodes();
+
     /**
      * Returns Augmentation Definition from which this augmentation is derived
      * if augmentation was added transitively via augmented uses.
      *
      * @return ugmentation Definition from which this augmentation is derived
-     * if augmentation was added transitively via augmented uses.
+     *         if augmentation was added transitively via augmented uses.
      */
     Optional<AugmentationSchema> getOriginalDefinition();
 
index 64d7328004e9ea33497b372d351e56ecd4428ca3..f05c20614d542618be17cef838aad0919f6b4e63 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.model.util;
 
+import com.google.common.base.Preconditions;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -16,7 +17,6 @@ import java.util.Date;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Set;
-
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.AugmentationTarget;
@@ -39,8 +39,6 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-
 /**
  * The Schema Context Util contains support methods for searching through Schema
  * Context modules for specified schema nodes via Schema Path or Revision Aware
@@ -491,69 +489,91 @@ public final class SchemaContextUtil {
         return result;
     }
 
-    private static DataSchemaNode findCorrectTargetFromGrouping(final DataSchemaNode node, final SchemaContext ctx) {
-        if (node.getPath().getPath().size() == 1) {
-            // uses is under module statement
-            Module m = findParentModule(ctx, node);
-            DataSchemaNode result = null;
-            for (UsesNode u : m.getUses()) {
-                SchemaNode targetGrouping = findNodeInSchemaContext(ctx, u.getGroupingPath().getPath());
-                if (!(targetGrouping instanceof GroupingDefinition)) {
-                    throw new IllegalArgumentException(String.format("Failed to generate code for augment in %s", u));
-                }
-                GroupingDefinition gr = (GroupingDefinition) targetGrouping;
-                result = gr.getDataChildByName(node.getQName().getLocalName());
-            }
-            if (result == null) {
-                throw new IllegalArgumentException("Failed to generate code for augment");
+    private static DataSchemaNode findCorrectImmediateTargetFromGrouping(final DataSchemaNode node, final SchemaContext ctx) {
+        // uses is under module statement
+        final Module m = findParentModule(ctx, node);
+        Preconditions.checkArgument(m != null, "Failed to find module for node {} in context {}", node, ctx);
+
+        for (final UsesNode u : m.getUses()) {
+            final SchemaNode targetGrouping = findNodeInSchemaContext(ctx, u.getGroupingPath().getPath());
+            Preconditions.checkArgument(targetGrouping instanceof GroupingDefinition,
+                    "Failed to generate code for augment in %s", u);
+
+            LOG.trace("Checking grouping {} for node {}", targetGrouping, node);
+            final GroupingDefinition gr = (GroupingDefinition) targetGrouping;
+            final DataSchemaNode result = gr.getDataChildByName(node.getQName().getLocalName());
+            if (result != null) {
+                return result;
             }
-            return result;
-        } else {
-            DataSchemaNode result = null;
+
+            LOG.debug("Skipped grouping {}, no matching node found", gr);
+        }
+
+        throw new IllegalArgumentException(
+                String.format("Failed to find uses node matching {} in context {}", node, ctx));
+    }
+
+    private static DataSchemaNode findCorrectTargetFromGrouping(final DataSchemaNode node, final SchemaContext ctx) {
+        if (node.getPath().getPath().size() != 1) {
             QName currentName = node.getQName();
+            // tmpPath is used to track level of nesting
             List<QName> tmpPath = new ArrayList<>();
             Object parent = null;
 
+            // create schema path of parent node
             SchemaPath sp = node.getPath();
-            List<QName> names = sp.getPath();
-            List<QName> newNames = new ArrayList<>(names);
+            List<QName> newNames = new ArrayList<>(sp.getPath());
+            // parentPath = nodePath - lastQName
             newNames.remove(newNames.size() - 1);
             SchemaPath newSp = SchemaPath.create(newNames, sp.isAbsolute());
+            // find parent node by its schema path
             parent = findDataSchemaNode(ctx, newSp);
 
             do {
                 tmpPath.add(currentName);
+
+                DataSchemaNode result = null;
+                // search parent node's used groupings for presence of wanted
+                // node
                 if (parent instanceof DataNodeContainer) {
                     DataNodeContainer dataNodeParent = (DataNodeContainer) parent;
                     for (UsesNode u : dataNodeParent.getUses()) {
-                        if (result == null) {
-                            result = getResultFromUses(u, currentName.getLocalName(), ctx);
+                        result = getResultFromUses(u, currentName.getLocalName(), ctx);
+                        if (result != null) {
+                            break;
                         }
                     }
                 }
+
+                // if node is not found in any of current parent's used
+                // groupings => parent is added by grouping too, so repeat same
+                // process for parent
                 if (result == null) {
+                    // set current name to name of parent node
                     currentName = ((SchemaNode) parent).getQName();
-                    if (parent instanceof SchemaNode) {
-                        SchemaPath nodeSp = ((SchemaNode) parent).getPath();
-                        List<QName> nodeNames = nodeSp.getPath();
-                        List<QName> nodeNewNames = new ArrayList<>(nodeNames);
-                        nodeNewNames.remove(nodeNewNames.size() - 1);
-                        if (nodeNewNames.isEmpty()) {
-                            parent = getParentModule((SchemaNode) parent, ctx);
-                        } else {
-                            SchemaPath nodeNewSp = SchemaPath.create(nodeNewNames, nodeSp.isAbsolute());
-                            parent = findDataSchemaNode(ctx, nodeNewSp);
-                        }
+                    Preconditions.checkArgument(parent instanceof SchemaNode,
+                            "Failed to generate code for augmend node {} at parent {}", node, parent);
+                    // create schema path for parent of current parent
+                    SchemaPath nodeSp = ((SchemaNode) parent).getPath();
+                    List<QName> nodeNewNames = new ArrayList<>(nodeSp.getPath());
+                    nodeNewNames.remove(nodeNewNames.size() - 1);
+                    // set new parent based on path
+                    if (nodeNewNames.isEmpty()) {
+                        parent = getParentModule((SchemaNode) parent, ctx);
                     } else {
-                        throw new IllegalArgumentException("Failed to generate code for augment");
+                        SchemaPath nodeNewSp = new SchemaPath(nodeNewNames, nodeSp.isAbsolute());
+                        parent = findDataSchemaNode(ctx, nodeNewSp);
                     }
+                } else {
+                    // if wanted node was found in grouping, traverse this node
+                    // based on level of nesting
+                    return getTargetNode(tmpPath, result, ctx);
                 }
-            } while (result == null && !(parent instanceof Module));
+            } while (!(parent instanceof Module));
 
-            if (result != null) {
-                result = getTargetNode(tmpPath, result, ctx);
-            }
-            return result;
+            return null;
+        } else {
+            return findCorrectImmediateTargetFromGrouping(node, ctx);
         }
     }
 
index f69c9d49bcc4adc7bc5b031834f136ac9a2ff5d3..de795220a8bc172bb5443840c2dd28d4bc99e96c 100644 (file)
@@ -13,19 +13,22 @@ import java.util.List;
 import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
 
+import com.google.common.base.Preconditions;
+
 /**
- * Basic implementation of Builder.
+ * Base helper implementation of Builders for Yang Model elements.
+ *
  */
 public abstract class AbstractBuilder implements Builder {
-    protected String moduleName;
-    protected final int line;
-    protected Builder parentBuilder;
+    private String moduleName;
+    private final int line;
+    private Builder parentBuilder;
 
     protected final List<UnknownSchemaNode> unknownNodes = new ArrayList<>();
     protected final List<UnknownSchemaNodeBuilder> addedUnknownNodes = new ArrayList<UnknownSchemaNodeBuilder>();
 
     protected AbstractBuilder(final String moduleName, final int line) {
-        this.moduleName = moduleName;
+        this.moduleName = Preconditions.checkNotNull(moduleName,"moduleName must not be null");
         this.line = line;
     }
 
@@ -35,6 +38,7 @@ public abstract class AbstractBuilder implements Builder {
     }
 
     @Override
+    @Deprecated
     public void setModuleName(final String moduleName) {
         this.moduleName = moduleName;
     }
index 13f8d93b8fac022d0de647aca5bdd29e0fc92eeb..ebb12dbc00ddf4ea565ba733beaf21072afdc956 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * 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
@@ -9,7 +8,9 @@ package org.opendaylight.yangtools.yang.parser.builder.api;
 
 import java.util.Collections;
 import java.util.HashSet;
+import java.util.Map;
 import java.util.Set;
+import java.util.TreeMap;
 import java.util.TreeSet;
 
 import org.opendaylight.yangtools.yang.common.QName;
@@ -26,7 +27,7 @@ import org.opendaylight.yangtools.yang.parser.util.YangParseException;
 public abstract class AbstractDataNodeContainerBuilder extends AbstractBuilder implements DataNodeContainerBuilder {
     protected final QName qname;
 
-    protected final Set<DataSchemaNode> childNodes = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+    protected final Map<QName, DataSchemaNode> childNodes = new TreeMap<>();
     protected final Set<DataSchemaNodeBuilder> addedChildNodes = new HashSet<>();
 
     protected final Set<GroupingDefinition> groupings = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
@@ -48,7 +49,7 @@ public abstract class AbstractDataNodeContainerBuilder extends AbstractBuilder i
         return qname;
     }
 
-    public Set<DataSchemaNode> getChildNodes() {
+    public Map<QName, DataSchemaNode> getChildNodes() {
         return childNodes;
     }
 
@@ -68,33 +69,32 @@ public abstract class AbstractDataNodeContainerBuilder extends AbstractBuilder i
     }
 
     @Override
-    public void addChildNode(DataSchemaNodeBuilder child) {
+    public void addChildNode(final DataSchemaNodeBuilder child) {
         QName childName = child.getQName();
         for (DataSchemaNodeBuilder addedChildNode : addedChildNodes) {
             if (addedChildNode.getQName().equals(childName)) {
-                throw new YangParseException(child.getModuleName(), child.getLine(), "Can not add '" + child + "' to '"
-                        + this + "' in module '" + moduleName + "': node with same name already declared at line "
-                        + addedChildNode.getLine());
+                throw new YangParseException(child.getModuleName(), child.getLine(), String.format(
+                        "Can not add '%s' to '%s' in module '%s': node with same name already declared at line %d",
+                        child, this, getModuleName(), addedChildNode.getLine()));
             }
         }
         addedChildNodes.add(child);
     }
 
     @Override
-    public void addChildNodeToContext(DataSchemaNodeBuilder child) {
+    public void addChildNodeToContext(final DataSchemaNodeBuilder child) {
         addedChildNodes.add(child);
     }
 
     @Override
-    public void addChildNode(DataSchemaNode child) {
+    public void addChildNode(final DataSchemaNode child) {
         QName childName = child.getQName();
-        for (DataSchemaNode childNode : childNodes) {
-            if (childNode.getQName().equals(childName)) {
-                throw new YangParseException(moduleName, line, "Can not add '" + child + "' to '" + this
-                        + "' in module '" + moduleName + "': node with same name already declared");
-            }
+        if (childNodes.containsKey(childName)) {
+            throw new YangParseException(getModuleName(), getLine(),
+                    String.format("Can not add '%s' to '%s' in module '%s': node with same name already declared",
+                            child, this, getModuleName()));
         }
-        childNodes.add(child);
+        childNodes.put(childName, child);
     }
 
     @Override
@@ -111,13 +111,13 @@ public abstract class AbstractDataNodeContainerBuilder extends AbstractBuilder i
     }
 
     @Override
-    public void addGrouping(GroupingBuilder grouping) {
+    public void addGrouping(final GroupingBuilder grouping) {
         QName groupingName = grouping.getQName();
         for (GroupingBuilder addedGrouping : addedGroupings) {
             if (addedGrouping.getQName().equals(groupingName)) {
-                throw new YangParseException(grouping.getModuleName(), grouping.getLine(), "Can not add '" + grouping
-                        + "': grouping with same name already declared in module '" + moduleName + "' at line "
-                        + addedGrouping.getLine());
+                throw new YangParseException(grouping.getModuleName(), grouping.getLine(), String.format(
+                        "Can not add '%s': grouping with same name already declared in module '%s' at line %d",
+                        grouping, getModuleName(), addedGrouping.getLine()));
             }
         }
         addedGroupings.add(grouping);
@@ -138,11 +138,11 @@ public abstract class AbstractDataNodeContainerBuilder extends AbstractBuilder i
     }
 
     @Override
-    public void addUsesNode(UsesNodeBuilder usesNode) {
+    public void addUsesNode(final UsesNodeBuilder usesNode) {
         addedUsesNodes.add(usesNode);
     }
 
-    protected static DataSchemaNode getChildNode(Set<DataSchemaNode> childNodes, QName name) {
+    protected static DataSchemaNode getChildNode(final Set<DataSchemaNode> childNodes, final QName name) {
         for (DataSchemaNode node : childNodes) {
             if (node.getQName().equals(name)) {
                 return node;
@@ -151,7 +151,7 @@ public abstract class AbstractDataNodeContainerBuilder extends AbstractBuilder i
         return null;
     }
 
-    protected static DataSchemaNode getChildNode(Set<DataSchemaNode> childNodes, String name) {
+    protected static DataSchemaNode getChildNode(final Set<DataSchemaNode> childNodes, final String name) {
         for (DataSchemaNode node : childNodes) {
             if (node.getQName().getLocalName().equals(name)) {
                 return node;
index 3ff7fdf8c37aa4fd0e20d329c8535ed35e670b3c..3c66869c1fb7eea54390c7c2ea95765e0f9d6c97 100644 (file)
@@ -77,7 +77,7 @@ public abstract class AbstractSchemaNodeBuilder extends AbstractBuilder implemen
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result + ((parentBuilder == null) ? 0 : parentBuilder.hashCode());
+        result = prime * result + ((getParent() == null) ? 0 : getParent().hashCode());
         result = prime * result + ((schemaPath == null) ? 0 : schemaPath.hashCode());
         return result;
     }
@@ -97,11 +97,11 @@ public abstract class AbstractSchemaNodeBuilder extends AbstractBuilder implemen
             return false;
         }
         AbstractSchemaNodeBuilder other = (AbstractSchemaNodeBuilder) obj;
-        if (parentBuilder == null) {
-            if (other.parentBuilder != null) {
+        if (getParent() == null) {
+            if (other.getParent() != null) {
                 return false;
             }
-        } else if (!parentBuilder.equals(other.parentBuilder)) {
+        } else if (!getParent().equals(other.getParent())) {
             return false;
         }
         if (schemaPath == null) {
index 6b1e49e1ed1d954a2d53b13be978c454a416b2b2..696e586122abfb4ca57959388a37aa7db9906718 100644 (file)
@@ -9,31 +9,41 @@ package org.opendaylight.yangtools.yang.parser.builder.api;
 
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.Status;
 
 /**
- * Interface for builders of 'augment' statement.
+ * Builder for {@link AugmentationSchema}, which represents 'augment' statement.
  */
-public interface AugmentationSchemaBuilder extends DataNodeContainerBuilder {
+public interface AugmentationSchemaBuilder extends DataNodeContainerBuilder,DocumentedNodeBuilder {
 
+    /**
+     * Returns when condition
+     *
+     * If when condition is present node defined by the parent data definition
+     * statement is only valid when the returned XPath
+     * expression conceptually evaluates to "true"
+     * for a particular instance, then the node defined by the parent data
+     * definition statement is valid; otherwise, it is not.
+     *
+     *
+     * @return
+     */
     String getWhenCondition();
 
+    /**
+     * Adds string representation of when condition.
+     *
+     * If when condition is present node defined by the parent data definition
+     * statement is only valid when the returned XPath
+     * expression conceptually evaluates to "true"
+     * for a particular instance, then the node defined by the parent data
+     * definition statement is valid; otherwise, it is not.
+     *
+     * @param whenCondition
+     */
     void addWhenCondition(String whenCondition);
 
-    String getDescription();
-
-    void setDescription(String description);
-
-    String getReference();
-
-    void setReference(String reference);
-
-    Status getStatus();
-
-    void setStatus(Status status);
-
     /**
-     * Get path to target node as single string.
+     * Returns target path representation as was present in schema source.
      *
      * @return path to target node as String
      */
@@ -65,6 +75,7 @@ public interface AugmentationSchemaBuilder extends DataNodeContainerBuilder {
      */
     void setTargetNodeSchemaPath(SchemaPath path);
 
+    @Override
     AugmentationSchema build();
 
     /**
@@ -82,6 +93,13 @@ public interface AugmentationSchemaBuilder extends DataNodeContainerBuilder {
      */
     void setResolved(boolean resolved);
 
+    /**
+     *
+     * Returns position of defining <code>augment</code> statement
+     * as was present in schema source.
+     *
+     * @return Position of definiing augment statement in source code.
+     */
     int getOrder();
 
 }
index 1f1052bb5a07d67deaea7b09048e9e8abbf02bd4..963bcc922a73debb5928a39e1d88852fa92207df 100644 (file)
@@ -9,15 +9,17 @@ package org.opendaylight.yangtools.yang.parser.builder.api;
 
 import java.util.List;
 
+import org.opendaylight.yangtools.concepts.Mutable;
 import org.opendaylight.yangtools.yang.parser.builder.impl.UnknownSchemaNodeBuilder;
 
 /**
  * Parent interface for all builder interfaces.
  */
-public interface Builder {
+public interface Builder extends Mutable {
 
     /**
-     * Get name of module in which this node is declared.
+     * Returns name of module in which node created by this builder
+     * was declared.
      *
      * @return module name
      */
@@ -27,18 +29,21 @@ public interface Builder {
      * Set name of module in which this node is declared.
      *
      * @param moduleName
+     * @deprecated Module name should be set during creation of builder.
      */
+    @Deprecated
     void setModuleName(String moduleName);
 
     /**
-     * Get current line in yang file.
+     * Get current line in yang file, on which statement
+     * associated with this builder was declared.
      *
      * @return current line in yang file
      */
     int getLine();
 
     /**
-     * Get parent node of this node.
+     * Returns parent node builder of this node.
      *
      * @return parent node builder or null if this is top level node
      */
@@ -53,7 +58,11 @@ public interface Builder {
     void setParent(Builder parent);
 
     /**
-     * Add unknown node to this builder.
+     * Adds an unknown node builder to this builder.
+     *
+     * When product (child) is builded by the {@link #build()}
+     * method, this builder is also built and unknown node is added
+     * as child to the product of this builder.
      *
      * @param unknownNode
      */
index ecedd8ef489b0a9d033a34d66441aee485e7e536..176bb9496da48980c9b5908d850d46bb8aab3628 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * 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
@@ -10,40 +9,45 @@ package org.opendaylight.yangtools.yang.parser.builder.api;
 import java.util.Set;
 
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
 /**
- * Interface for all yang data-node containers [augment, case, container,
- * grouping, list, module, notification].
+ * Common builder for for all YANG {@link DataNodeContainer}
+ * <code>augment, case, container,
+ * grouping, list, module, notification</code>.
  */
 public interface DataNodeContainerBuilder extends Builder {
 
     /**
-     * Get qname of this node.
+     * Returns QName of this node.
      *
      * @return QName of this node
      */
     QName getQName();
 
     /**
-     * Get schema path of this node.
+     * Returns Schema path of this node.
      *
      * @return SchemaPath of this node
      */
     SchemaPath getPath();
 
     /**
-     * Get builders of child nodes.
+     * Returns set of of child node builders.
+     *
+     * This child node builder are build, during invoking {@link #build()} and
+     * added as children to resulting {@link DataNodeContainer}.
      *
      * @return collection child nodes builders
      */
     Set<DataSchemaNodeBuilder> getChildNodeBuilders();
 
     /**
-     * Get child node by name.
+     * Retrieves child node builder by local name.
      *
      * @param name
      *            name of child to seek
@@ -97,20 +101,38 @@ public interface DataNodeContainerBuilder extends Builder {
      */
     void addUsesNode(UsesNodeBuilder usesBuilder);
 
+    /**
+     * Returns set of already built type definitions.
+     *
+     * @return set of already built type definitions.
+     */
     Set<TypeDefinition<?>> getTypeDefinitions();
 
     /**
-     * Get builders of typedef statement defined in this node.
+     * Returns builders of typedef statement defined in this node.
      *
-     * @return typedefBuilder
+     * @return  builders of typedef statement defined in this node.
      */
     Set<TypeDefinitionBuilder> getTypeDefinitionBuilders();
 
     /**
      * Add typedef builder to this node.
      *
-     * @param typedefBuilder
+     * @param typedefBuilder Builder to add to this node.
      */
     void addTypedef(TypeDefinitionBuilder typedefBuilder);
 
+    /**
+     * Returns an instance of product - DataNodeContainer
+     *
+     * Returns an instance of data node container with
+     * children and properties constructed as per this builder state,
+     * all nested builders are also built and their product is
+     * set to DataNodeContainer.
+     *
+     * @return Instance of DataNodeContainer
+     */
+    @Override
+    DataNodeContainer build();
+
 }
index e816e8c282e0cc7ff4f0c66c8f22d138bd14eff6..8fd0009a698b70c5224e3e38505b2a5736d93b99 100644 (file)
@@ -8,7 +8,6 @@
 package org.opendaylight.yangtools.yang.parser.builder.api;
 
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.parser.builder.impl.ConstraintsBuilder;
 
 /**
@@ -17,21 +16,18 @@ import org.opendaylight.yangtools.yang.parser.builder.impl.ConstraintsBuilder;
  */
 public interface DataSchemaNodeBuilder extends SchemaNodeBuilder, GroupingMember {
 
-    /**
-     * Build DataSchemaNode object from this builder.
-     */
-    DataSchemaNode build();
 
-    void setPath(SchemaPath path);
 
     /**
+     *
+     * Returns true if product of this builder is added by augmentation.
      *
      * @return true, if this node is added by augmentation, false otherwise
      */
     boolean isAugmenting();
 
     /**
-     * Set if this node is added by augmentation.
+     * Set if the product of the builder node is introduced by augmentation.
      *
      * @param augmenting
      */
@@ -45,9 +41,10 @@ public interface DataSchemaNodeBuilder extends SchemaNodeBuilder, GroupingMember
     boolean isConfiguration();
 
     /**
-     * Set config statement.
+     * Set config statement to the product.
+     *
      *
-     * @param config
+     * @param config true if config true was set, false if config false was set.
      */
     void setConfiguration(boolean config);
 
@@ -58,4 +55,12 @@ public interface DataSchemaNodeBuilder extends SchemaNodeBuilder, GroupingMember
      */
     ConstraintsBuilder getConstraints();
 
+    /**
+     * Build DataSchemaNode object from this builder.
+     *
+     * @return instance of {@link DataSchemaNode} based on the state present in this builder.
+     */
+    @Override
+    DataSchemaNode build();
+
 }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/DocumentedNodeBuilder.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/api/DocumentedNodeBuilder.java
new file mode 100644 (file)
index 0000000..4ff4fb8
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2014 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.parser.builder.api;
+
+import org.opendaylight.yangtools.yang.model.api.Status;
+
+/**
+ * Mixin-style builder interfac for nodes, which may have documentation attached.
+ *
+ **/
+public interface DocumentedNodeBuilder {
+
+    /**
+     * Returns description of resulting schema node
+     * as was defined by description statement.
+     *
+     * @return description statement
+     */
+    String getDescription();
+
+    /**
+     * Set description to this node.
+     *
+     * @param description
+     */
+    void setDescription(String description);
+
+    /**
+     * Get reference of this node.
+     *
+     * @return reference statement
+     */
+    String getReference();
+
+    /**
+     * Set reference to this node.
+     *
+     * @param reference
+     */
+    void setReference(String reference);
+
+    /**
+     * Get status of this node.
+     *
+     * @return status statement
+     */
+    Status getStatus();
+
+    /**
+     * Set status to this node.
+     *
+     * @param status
+     */
+    void setStatus(Status status);
+}
index b79f68a505f5ce106c955f45a51271149327a8fa..fb7b9c8d61739c909c37cee6092b65688bab8b82 100644 (file)
@@ -19,15 +19,75 @@ public interface GroupingBuilder extends DataNodeContainerBuilder, SchemaNodeBui
 
     /**
      * Build GroupingDefinition object from this builder.
+     *
+     * @return Instance of {@link GroupingDefinition} described by this builder.
      */
+    @Override
     GroupingDefinition build();
 
+    /**
+     *
+     * Returns instantiation of grouping child nodes under supplied builder.
+     *
+     * Supplied newParent is not modified.
+     *
+     * For each {@link #getChildNodeBuilders()} new builder is created,
+     * which has supplied new parent set as their {@link Builder#getParent()}
+     * and QNames have updated namespace and revision per supplied parent
+     * node.
+     *
+     * @param newParent Parent node, under which this grouping should be instantiated.
+     * @return Set of new builders representing instantiation of this grouping.
+     */
     Set<DataSchemaNodeBuilder> instantiateChildNodes(Builder newParent);
 
+
+   /**
+    *
+    * Returns instantiation of grouping type definitions under supplied builder.
+    *
+    * Supplied newParent is not modified.
+    *
+    * For each {@link #getTypeDefinitionBuilders()} new builder is created,
+    * which has supplied new parent set as their {@link Builder#getParent()}
+    * and QNames have updated namespace and revision per supplied parent
+    * node.
+    *
+    * @param newParent Parent node, under which this grouping should be instantiated.
+    * @return Set of new builders representing instantiation of this grouping.
+    */
     Set<TypeDefinitionBuilder> instantiateTypedefs(Builder newParent);
 
+   /**
+    *
+    * Returns instantiation of grouping definitions under supplied builder.
+    *
+    * Supplied newParent is not modified.
+    *
+    * For each {@link #getGroupingBuilders()} new builder is created,
+    * which has supplied new parent set as their {@link Builder#getParent()}
+    * and QNames have updated namespace and revision per supplied parent
+    * node.
+    *
+    * @param newParent Parent node, under which this grouping should be instantiated.
+    * @return Set of new builders representing instantiation of this grouping.
+    */
     Set<GroupingBuilder> instantiateGroupings(Builder newParent);
 
+    /**
+    *
+    * Returns instantiation of unknown nodes under supplied builder.
+    *
+    * Supplied newParent is not modified.
+    *
+    * For each {@link #getUnknownNodes()} new builder is created,
+    * which has supplied new parent set as their {@link Builder#getParent()}
+    * and QNames have updated namespace and revision per supplied parent
+    * node.
+    *
+    * @param newParent Parent node, under which this grouping should be instantiated.
+    * @return Set of new builders representing instantiation of this grouping.
+    */
     Set<UnknownSchemaNodeBuilder> instantiateUnknownNodes(Builder newParent);
 
 }
index cd0bb354e445270176947a3acdb00093f10051e9..2c9fe3aa1b8f56f5f35ce1d6d98bdfacdfdc236c 100644 (file)
@@ -10,79 +10,37 @@ package org.opendaylight.yangtools.yang.parser.builder.api;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaNode;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
-import org.opendaylight.yangtools.yang.model.api.Status;
 
 /**
- * Interface for all builders of SchemaNode nodes.
+ * Builder for {@link SchemaNode}.
  */
-public interface SchemaNodeBuilder extends Builder {
+public interface SchemaNodeBuilder extends DocumentedNodeBuilder, Builder {
 
     /**
-     * Get qname of this node.
+     * Returns qname of resulting {@link SchemaNode}.
      *
      * @return QName of this node
      */
     QName getQName();
 
     /**
-     * Get schema path of this node.
+     * Returns schema path of resulting  {@link SchemaNode}.
      *
      * @return SchemaPath of this node
      */
     SchemaPath getPath();
 
     /**
-     * Set path to this node.
+     * Updates schema path to resulting {@link SchemaNode}.
      *
      * @param path
      */
     void setPath(SchemaPath path);
 
-    /**
-     * Get description of this node.
-     *
-     * @return description statement
-     */
-    String getDescription();
-
-    /**
-     * Set description to this node.
-     *
-     * @param description
-     */
-    void setDescription(String description);
-
-    /**
-     * Get reference of this node.
-     *
-     * @return reference statement
-     */
-    String getReference();
-
-    /**
-     * Set reference to this node.
-     *
-     * @param reference
-     */
-    void setReference(String reference);
-
-    /**
-     * Get status of this node.
-     *
-     * @return status statement
-     */
-    Status getStatus();
-
-    /**
-     * Set status to this node.
-     *
-     * @param status
-     */
-    void setStatus(Status status);
-
     /**
      * Build SchemaNode object from this builder.
      */
+    @Override
     SchemaNode build();
 
 }
index c181fe1a66b4a2544d0c673fc14ea79b8e70f1e0..c4f7e1386a8a60e4b57398d540fe5db7324d95b3 100644 (file)
@@ -12,7 +12,7 @@ import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
 
 /**
- * Builders of all nodes, which can have 'type' statement must implement this
+ * Builder for nodes, which can have 'type' statement must implement this
  * interface. [typedef, type, leaf, leaf-list, deviate]
  */
 public interface TypeAwareBuilder extends Builder {
index 1b4eed27f1b2a018a9ecdc436371b008119ea69b..b98f15c69a5792a5e0614a8eb1ac8a54f10399c5 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * 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
@@ -20,32 +19,110 @@ import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
  */
 public interface TypeDefinitionBuilder extends TypeAwareBuilder, SchemaNodeBuilder, GroupingMember {
 
+    /**
+     * Sets QName for resulting type definition.
+     *
+     * @param qname QName of resulting type
+     */
     void setQName(QName qname);
 
+    @Override
     TypeDefinition<?> build();
 
+    /**
+     *
+     * Returns range restrictions of resulting type definition.
+     *
+     * @return range restrictions of resulting type definition.
+     */
     List<RangeConstraint> getRanges();
 
+    /**
+     * Set Range restrictions for resulting type definition.
+     *
+     * @param ranges
+     *            Range restrictions of resulting type definition.
+     */
     void setRanges(List<RangeConstraint> ranges);
 
+    /**
+     *
+     * Returns length restrictions of resulting type definition.
+     *
+     * @return length restrictions of resulting type definition.
+     */
     List<LengthConstraint> getLengths();
 
+    /**
+     * Set length restrictions for resulting type definition.
+     *
+     * @param lengths
+     *            Length restrictions of resulting type definition.
+     */
     void setLengths(List<LengthConstraint> lengths);
 
+    /**
+     *
+     * Returns pattern restrictions of resulting type definition.
+     *
+     * @return range restrictions of resulting type definition.
+     */
     List<PatternConstraint> getPatterns();
 
+    /**
+     * Set length restrictions for resulting type definition.
+     *
+     * @param lengths
+     *            Length restrictions of resulting type definition.
+     */
     void setPatterns(List<PatternConstraint> patterns);
 
+    /**
+     *
+     * Returns fractions digits of resulting type if it is derived
+     * from <code>decimal</code> built-in type.
+     *
+     * @return fractions digits of resulting type
+     */
     Integer getFractionDigits();
 
+    /**
+     *
+     * Sets fractions digits of resulting type if it is derived
+     * from <code>decimal</code> built-in type.
+     *
+     * @return fractions digits of resulting type
+     */
     void setFractionDigits(Integer fractionDigits);
 
+    /**
+     *
+     * Returns default value of resulting type
+     *
+     * @return default value of resulting type
+     */
     Object getDefaultValue();
 
+    /**
+     *
+     * Sets default value of resulting type
+     *
+     * @param defaultValue Default value of resulting type
+     */
     void setDefaultValue(Object defaultValue);
 
+    /**
+     * Gets unit definition for resulting type
+     *
+     * @return unit definition for resulting type
+     */
     String getUnits();
 
+    /**
+     * Sets units definition for resulting type
+     *
+     * @param units units definition for resulting type
+     */
     void setUnits(String units);
 
 }
index c56ee6425893484a83f3a78b6e49f136968925f5..ddff749d5e998815489b467958057350d5b678ba 100644 (file)
@@ -16,7 +16,7 @@ import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.opendaylight.yangtools.yang.parser.util.RefineHolder;
 
 /**
- * Interface for builders of 'uses' statement.
+ * Builder for  'uses' statement.
  */
 public interface UsesNodeBuilder extends GroupingMember {
 
@@ -25,6 +25,7 @@ public interface UsesNodeBuilder extends GroupingMember {
      * module, container, list, case, grouping, input, output, notification or
      * augment, return type is DataNodeContainerBuilder.
      */
+    @Override
     DataNodeContainerBuilder getParent();
 
     /**
@@ -133,11 +134,31 @@ public interface UsesNodeBuilder extends GroupingMember {
 
     /**
      * Build new UsesNode object.
+     *
+     *
+     * @return UsesNode Instance of {@link UsesNode} described by this builder.
      */
+    @Override
     UsesNode build();
 
+    /**
+     *
+     * Returns true if uses node was resolved and {@link #getGroupingBuilder()}
+     * was instantiated for parent done of this node.
+     *
+     * @return true if uses node was resolved and associated nodes were instantiated in parent node.
+     */
     boolean isResolved();
 
+    /**
+     *
+     * Sets state of instantiation of {@link #getGroupingBuilder()}
+     * into parent node of this node.
+     *
+     * @deprecated Do not use this, this should be internal to the implementation
+     *  and public API contract.
+     */
+    @Deprecated
     void setResolved(boolean resolved);
 
 }
index add703a0762b3ef68fd571f2142b0097c15f1765..7fd48b6a9bf6945481d6052f79d7dd1d0d116d85 100644 (file)
@@ -138,11 +138,11 @@ public final class AnyXmlBuilder extends AbstractSchemaNodeBuilder implements Da
         } else if (!schemaPath.equals(other.schemaPath)) {
             return false;
         }
-        if (parentBuilder == null) {
-            if (other.parentBuilder != null) {
+        if (getParent() == null) {
+            if (other.getParent() != null) {
                 return false;
             }
-        } else if (!parentBuilder.equals(other.parentBuilder)) {
+        } else if (!getParent().equals(other.getParent())) {
             return false;
         }
         return true;
index 3b75d1190cab0ccd863bf60c9883e9483e0f099d..3e4abd301dc1602f301e81b2890340ba18b7b3cf 100644 (file)
@@ -7,10 +7,6 @@
  */
 package org.opendaylight.yangtools.yang.parser.builder.impl;
 
-import com.google.common.base.Optional;
-import com.google.common.base.Preconditions;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
 import java.net.URI;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -18,7 +14,9 @@ import java.util.Date;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Set;
+
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
@@ -40,6 +38,11 @@ import org.opendaylight.yangtools.yang.parser.builder.api.UsesNodeBuilder;
 import org.opendaylight.yangtools.yang.parser.util.ParserUtils;
 import org.opendaylight.yangtools.yang.parser.util.YangParseException;
 
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
 public final class AugmentationSchemaBuilderImpl extends AbstractDataNodeContainerBuilder implements
         AugmentationSchemaBuilder {
     private final int order;
@@ -57,7 +60,7 @@ public final class AugmentationSchemaBuilderImpl extends AbstractDataNodeContain
     private boolean resolved;
     private AugmentationSchemaBuilder copyOf;
 
-    public AugmentationSchemaBuilderImpl(final String moduleName, final int line, final String augmentTargetStr, int order) {
+    public AugmentationSchemaBuilderImpl(final String moduleName, final int line, final String augmentTargetStr, final int order) {
         super(moduleName, line, null);
         this.order = order;
         this.augmentTargetStr = augmentTargetStr;
@@ -76,7 +79,7 @@ public final class AugmentationSchemaBuilderImpl extends AbstractDataNodeContain
 
     @Override
     public void addGrouping(final GroupingBuilder grouping) {
-        throw new YangParseException(moduleName, line, "augment can not contains grouping statement");
+        throw new YangParseException(getModuleName(), grouping.getLine(), "augment can not contains grouping statement");
     }
 
     @Override
@@ -104,11 +107,12 @@ public final class AugmentationSchemaBuilderImpl extends AbstractDataNodeContain
         }
 
         if (parent instanceof UsesNodeBuilder) {
-            ModuleBuilder mb = ParserUtils.getParentModule(this);
+            final ModuleBuilder mb = ParserUtils.getParentModule(this);
+            final QNameModule qm = QNameModule.create(mb.getNamespace(), mb.getRevision());
+
             List<QName> newPath = new ArrayList<>();
-            List<QName> parsedPath = targetPath.getPath();
-            for (QName name : parsedPath) {
-                newPath.add(new QName(mb.getNamespace(), mb.getRevision(), name.getPrefix(), name.getLocalName()));
+            for (QName name : targetPath.getPathFromRoot()) {
+                newPath.add(QName.create(qm, name.getPrefix(), name.getLocalName()));
             }
             instance.targetPath = SchemaPath.create(newPath, false);
         } else {
@@ -129,9 +133,9 @@ public final class AugmentationSchemaBuilderImpl extends AbstractDataNodeContain
 
         // CHILD NODES
         for (DataSchemaNodeBuilder node : addedChildNodes) {
-            childNodes.add(node.build());
+            childNodes.put(node.getQName(), node.build());
         }
-        instance.childNodes = ImmutableSet.copyOf(childNodes);
+        instance.childNodes = ImmutableSet.copyOf(childNodes.values());
 
         // USES
         for (UsesNodeBuilder builder : addedUsesNodes) {
@@ -175,7 +179,7 @@ public final class AugmentationSchemaBuilderImpl extends AbstractDataNodeContain
 
     @Override
     public void addTypedef(final TypeDefinitionBuilder type) {
-        throw new YangParseException(moduleName, line, "Augmentation can not contains typedef statement.");
+        throw new YangParseException(getModuleName(), type.getLine(), "Augmentation can not contains typedef statement.");
     }
 
     @Override
@@ -453,9 +457,9 @@ public final class AugmentationSchemaBuilderImpl extends AbstractDataNodeContain
         }
 
         @Override
-        public int compareTo(AugmentationSchemaImpl o) {
-            Iterator<QName> thisIt = this.targetPath.getPath().iterator();
-            Iterator<QName> otherIt = o.getTargetPath().getPath().iterator();
+        public int compareTo(final AugmentationSchemaImpl o) {
+            Iterator<QName> thisIt = this.targetPath.getPathFromRoot().iterator();
+            Iterator<QName> otherIt = o.getTargetPath().getPathFromRoot().iterator();
             while (thisIt.hasNext()) {
                 if (otherIt.hasNext()) {
                     int comp = thisIt.next().compareTo(otherIt.next());
index c38d0efd32399528195e33ca198a6ffe86bc36ae..3bd7a7390e6b6b4eabc1521480b2909b9e65a4ac 100644 (file)
@@ -159,11 +159,11 @@ public final class ChoiceBuilder extends AbstractSchemaNodeBuilder implements Da
         QName caseQName = caseNode.getQName();
         String caseName = caseQName.getLocalName();
 
-        for (ChoiceCaseBuilder addedCase : caseBuilders) {
-            if (addedCase.getQName().getLocalName().equals(caseName)) {
+        for (ChoiceCaseBuilder existingCase : caseBuilders) {
+            if (existingCase.getQName().getLocalName().equals(caseName)) {
                 throw new YangParseException(caseNode.getModuleName(), caseNode.getLine(), "Can not add '" + caseNode
-                        + "' to node '" + qname.getLocalName() + "' in module '" + moduleName
-                        + "': case with same name already declared at line " + addedCase.getLine());
+                        + "' to node '" + qname.getLocalName() + "' in module '" + getModuleName()
+                        + "': case with same name already declared at line " + existingCase.getLine());
             }
         }
 
@@ -178,7 +178,7 @@ public final class ChoiceBuilder extends AbstractSchemaNodeBuilder implements Da
                 caseBuilder.setAugmenting(true);
                 caseNode.setAugmenting(false);
             }
-            SchemaPath newPath = ParserUtils.createSchemaPath(caseNode.getPath(), caseQName);
+            SchemaPath newPath = caseNode.getPath().createChild(caseQName);
             caseNode.setPath(newPath);
             caseBuilder.addChildNode(caseNode);
             caseBuilders.add(caseBuilder);
@@ -264,11 +264,11 @@ public final class ChoiceBuilder extends AbstractSchemaNodeBuilder implements Da
         } else if (!schemaPath.equals(other.schemaPath)) {
             return false;
         }
-        if (parentBuilder == null) {
-            if (other.parentBuilder != null) {
+        if (getParent() == null) {
+            if (other.getParent() != null) {
                 return false;
             }
-        } else if (!parentBuilder.equals(other.parentBuilder)) {
+        } else if (!getParent().equals(other.getParent())) {
             return false;
         }
         return true;
index dd82fbef442f9c1994adcec94d5ce7e02d3bc755..bd94b0f6cc3997aeb7aa555fd2979af4060ff5de 100644 (file)
@@ -102,9 +102,9 @@ public final class ChoiceCaseBuilder extends AbstractDataNodeContainerBuilder im
 
         // CHILD NODES
         for (DataSchemaNodeBuilder node : addedChildNodes) {
-            childNodes.add(node.build());
+            childNodes.put(node.getQName(), node.build());
         }
-        instance.childNodes = ImmutableSet.copyOf(childNodes);
+        instance.childNodes = ImmutableSet.copyOf(childNodes.values());
 
         // USES
         for (UsesNodeBuilder builder : addedUsesNodes) {
@@ -163,7 +163,7 @@ public final class ChoiceCaseBuilder extends AbstractDataNodeContainerBuilder im
     }
 
     @Override
-    public void setStatus(Status status) {
+    public void setStatus(final Status status) {
         this.status = Preconditions.checkNotNull(status, "status cannot be null");
     }
 
@@ -194,7 +194,7 @@ public final class ChoiceCaseBuilder extends AbstractDataNodeContainerBuilder im
 
     @Override
     public void addTypedef(final TypeDefinitionBuilder typedefBuilder) {
-        throw new YangParseException(moduleName, line, "Can not add type definition to choice case.");
+        throw new YangParseException(getModuleName(), typedefBuilder.getLine(), "Can not add type definition to choice case.");
     }
 
     @Override
@@ -204,7 +204,7 @@ public final class ChoiceCaseBuilder extends AbstractDataNodeContainerBuilder im
 
     @Override
     public void setConfiguration(final boolean configuration) {
-        throw new YangParseException(moduleName, line, "Can not add config statement to choice case.");
+        throw new YangParseException(getModuleName(), getLine(), "Can not add config statement to choice case.");
     }
 
     @Override
@@ -244,11 +244,11 @@ public final class ChoiceCaseBuilder extends AbstractDataNodeContainerBuilder im
         } else if (!schemaPath.equals(other.schemaPath)) {
             return false;
         }
-        if (parentBuilder == null) {
-            if (other.parentBuilder != null) {
+        if (getParent() == null) {
+            if (other.getParent() != null) {
                 return false;
             }
-        } else if (!parentBuilder.equals(other.parentBuilder)) {
+        } else if (!getParent().equals(other.getParent())) {
             return false;
         }
         return true;
index ccf31553a4efcea6b274c393d9e3adbc68eb293f..516837151081a16ef985bcdcc1571f754689431c 100644 (file)
@@ -14,7 +14,16 @@ import java.util.List;
 import java.util.Set;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.*;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
 import org.opendaylight.yangtools.yang.parser.builder.api.AbstractDataNodeContainerBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationSchemaBuilder;
 import org.opendaylight.yangtools.yang.parser.builder.api.AugmentationTargetBuilder;
@@ -100,9 +109,9 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
 
         // CHILD NODES
         for (DataSchemaNodeBuilder node : addedChildNodes) {
-            childNodes.add(node.build());
+            childNodes.put(node.getQName(), node.build());
         }
-        instance.childNodes = ImmutableSet.copyOf(childNodes);
+        instance.childNodes = ImmutableSet.copyOf(childNodes.values());
 
         // GROUPINGS
         for (GroupingBuilder builder : addedGroupings) {
@@ -147,7 +156,7 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
         String typeName = type.getQName().getLocalName();
         for (TypeDefinitionBuilder addedTypedef : addedTypedefs) {
             if (addedTypedef.getQName().getLocalName().equals(typeName)) {
-                throw new YangParseException(moduleName, type.getLine(), "Can not add typedef '" + typeName
+                throw new YangParseException(getModuleName(), type.getLine(), "Can not add typedef '" + typeName
                         + "': typedef with same name already declared at line " + addedTypedef.getLine());
             }
         }
@@ -159,7 +168,7 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
     }
 
     @Override
-    public void addAugmentation(AugmentationSchemaBuilder augment) {
+    public void addAugmentation(final AugmentationSchemaBuilder augment) {
         augmentationBuilders.add(augment);
     }
 
@@ -169,7 +178,7 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
     }
 
     @Override
-    public void setPath(SchemaPath path) {
+    public void setPath(final SchemaPath path) {
         this.path = path;
     }
 
@@ -199,7 +208,7 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
     }
 
     @Override
-    public void setStatus(Status status) {
+    public void setStatus(final Status status) {
         this.status = Preconditions.checkNotNull(status, "status cannot be null");
     }
 
@@ -209,7 +218,7 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
     }
 
     @Override
-    public void setAugmenting(boolean augmenting) {
+    public void setAugmenting(final boolean augmenting) {
         this.augmenting = augmenting;
     }
 
@@ -229,7 +238,7 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
     }
 
     @Override
-    public void setConfiguration(boolean configuration) {
+    public void setConfiguration(final boolean configuration) {
         this.configuration = configuration;
     }
 
@@ -242,7 +251,7 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
         return presence;
     }
 
-    public void setPresence(boolean presence) {
+    public void setPresence(final boolean presence) {
         this.presence = presence;
     }
 
@@ -255,7 +264,7 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }
@@ -273,11 +282,13 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
         } else if (!path.equals(other.path)) {
             return false;
         }
-        if (parentBuilder == null) {
-            if (other.parentBuilder != null) {
+        // FIXME: Do we really need this? This actually triggers equals
+        // up to the root builder.
+        if (getParent() == null) {
+            if (other.getParent() != null) {
                 return false;
             }
-        } else if (!parentBuilder.equals(other.parentBuilder)) {
+        } else if (!getParent().equals(other.getParent())) {
             return false;
         }
         return true;
@@ -308,7 +319,7 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
 
         private boolean presence;
 
-        private ContainerSchemaNodeImpl(QName qname, SchemaPath path) {
+        private ContainerSchemaNodeImpl(final QName qname, final SchemaPath path) {
             this.qname = qname;
             this.path = path;
         }
@@ -374,12 +385,12 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
         }
 
         @Override
-        public DataSchemaNode getDataChildByName(QName name) {
+        public DataSchemaNode getDataChildByName(final QName name) {
             return getChildNode(childNodes, name);
         }
 
         @Override
-        public DataSchemaNode getDataChildByName(String name) {
+        public DataSchemaNode getDataChildByName(final String name) {
             return getChildNode(childNodes, name);
         }
 
@@ -413,7 +424,7 @@ public final class ContainerSchemaNodeBuilder extends AbstractDataNodeContainerB
         }
 
         @Override
-        public boolean equals(Object obj) {
+        public boolean equals(final Object obj) {
             if (this == obj) {
                 return true;
             }
index 71d1f06ef5e453750aa2122e4a19231a76702624..7d9805761391cfb4158a0ba642c08548a347873e 100644 (file)
@@ -7,12 +7,15 @@
  */
 package org.opendaylight.yangtools.yang.parser.builder.impl;
 
-import java.util.*;
+import java.util.List;
 
-import org.opendaylight.yangtools.yang.model.api.*;
+import org.opendaylight.yangtools.yang.model.api.Deviation;
 import org.opendaylight.yangtools.yang.model.api.Deviation.Deviate;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.parser.builder.api.AbstractBuilder;
-import org.opendaylight.yangtools.yang.parser.util.*;
+import org.opendaylight.yangtools.yang.parser.util.ParserUtils;
+import org.opendaylight.yangtools.yang.parser.util.YangParseException;
 
 import com.google.common.collect.ImmutableList;
 
@@ -36,7 +39,7 @@ public final class DeviationBuilder extends AbstractBuilder {
     @Override
     public Deviation build() {
         if (targetPath == null) {
-            throw new YangParseException(moduleName, line, "Unresolved deviation target");
+            throw new YangParseException(getModuleName(), getLine(), "Unresolved deviation target");
         }
 
         if (instance != null) {
@@ -75,7 +78,7 @@ public final class DeviationBuilder extends AbstractBuilder {
         } else if ("delete".equals(deviate)) {
             this.deviate = Deviate.DELETE;
         } else {
-            throw new YangParseException(moduleName, line, "Unsupported type of 'deviate' statement: " + deviate);
+            throw new YangParseException(getModuleName(), getLine(), "Unsupported type of 'deviate' statement: " + deviate);
         }
     }
 
index 90a49d1b196f30986c11d84713e3e4eb53a637b6..ced13261d0d85ffd0f9d02469b46134d83bdab11 100644 (file)
@@ -87,9 +87,9 @@ public final class GroupingBuilderImpl extends AbstractDataNodeContainerBuilder
 
         // CHILD NODES
         for (DataSchemaNodeBuilder node : addedChildNodes) {
-            childNodes.add(node.build());
+            childNodes.put(node.getQName(), node.build());
         }
-        instance.childNodes = ImmutableSet.copyOf(childNodes);
+        instance.childNodes = ImmutableSet.copyOf(childNodes.values());
 
         // GROUPINGS
         for (GroupingBuilder builder : addedGroupings) {
@@ -119,7 +119,7 @@ public final class GroupingBuilderImpl extends AbstractDataNodeContainerBuilder
     }
 
     @Override
-    public Set<DataSchemaNodeBuilder> instantiateChildNodes(Builder newParent) {
+    public Set<DataSchemaNodeBuilder> instantiateChildNodes(final Builder newParent) {
         final Set<DataSchemaNodeBuilder> nodes = new HashSet<>();
         for (DataSchemaNodeBuilder node : addedChildNodes) {
             DataSchemaNodeBuilder copy = CopyUtils.copy(node, newParent, true);
@@ -130,7 +130,7 @@ public final class GroupingBuilderImpl extends AbstractDataNodeContainerBuilder
     }
 
     @Override
-    public Set<TypeDefinitionBuilder> instantiateTypedefs(Builder newParent) {
+    public Set<TypeDefinitionBuilder> instantiateTypedefs(final Builder newParent) {
         final Set<TypeDefinitionBuilder> nodes = new HashSet<>();
         for (TypeDefinitionBuilder node : addedTypedefs) {
             TypeDefinitionBuilder copy = CopyUtils.copy(node, newParent, true);
@@ -140,7 +140,7 @@ public final class GroupingBuilderImpl extends AbstractDataNodeContainerBuilder
     }
 
     @Override
-    public Set<GroupingBuilder> instantiateGroupings(Builder newParent) {
+    public Set<GroupingBuilder> instantiateGroupings(final Builder newParent) {
         final Set<GroupingBuilder> nodes = new HashSet<>();
         for (GroupingBuilder node : addedGroupings) {
             GroupingBuilder copy = CopyUtils.copy(node, newParent, true);
@@ -154,7 +154,7 @@ public final class GroupingBuilderImpl extends AbstractDataNodeContainerBuilder
     }
 
     @Override
-    public Set<UnknownSchemaNodeBuilder> instantiateUnknownNodes(Builder newParent) {
+    public Set<UnknownSchemaNodeBuilder> instantiateUnknownNodes(final Builder newParent) {
         final Set<UnknownSchemaNodeBuilder> nodes = new HashSet<>();
         for (UnknownSchemaNodeBuilder node : addedUnknownNodes) {
             UnknownSchemaNodeBuilder copy = CopyUtils.copy(node, newParent, true);
@@ -173,7 +173,7 @@ public final class GroupingBuilderImpl extends AbstractDataNodeContainerBuilder
     public void addTypedef(final TypeDefinitionBuilder type) {
         String typeName = type.getQName().getLocalName();
         for (TypeDefinitionBuilder addedTypedef : addedTypedefs) {
-            throw new YangParseException(moduleName, type.getLine(), "Can not add typedef '" + typeName
+            throw new YangParseException(getModuleName(), type.getLine(), "Can not add typedef '" + typeName
                     + "': typedef with same name already declared at line " + addedTypedef.getLine());
         }
         addedTypedefs.add(type);
@@ -215,7 +215,7 @@ public final class GroupingBuilderImpl extends AbstractDataNodeContainerBuilder
     }
 
     @Override
-    public void setStatus(Status status) {
+    public void setStatus(final Status status) {
         this.status = Preconditions.checkNotNull(status, "status cannot be null");
     }
 
@@ -238,13 +238,13 @@ public final class GroupingBuilderImpl extends AbstractDataNodeContainerBuilder
     public int hashCode() {
         final int prime = 31;
         int result = 1;
-        result = prime * result + ((parentBuilder == null) ? 0 : parentBuilder.hashCode());
+        result = prime * result + ((getParent() == null) ? 0 : getParent().hashCode());
         result = prime * result + ((schemaPath == null) ? 0 : schemaPath.hashCode());
         return result;
     }
 
     @Override
-    public boolean equals(Object obj) {
+    public boolean equals(final Object obj) {
         if (this == obj) {
             return true;
         }
@@ -258,11 +258,11 @@ public final class GroupingBuilderImpl extends AbstractDataNodeContainerBuilder
             return false;
         }
         final GroupingBuilderImpl other = (GroupingBuilderImpl) obj;
-        if (parentBuilder == null) {
-            if (other.parentBuilder != null) {
+        if (getParent() == null) {
+            if (other.getParent() != null) {
                 return false;
             }
-        } else if (!parentBuilder.equals(other.parentBuilder)) {
+        } else if (!getParent().equals(other.getParent())) {
             return false;
         }
         if (schemaPath == null) {
@@ -349,12 +349,12 @@ public final class GroupingBuilderImpl extends AbstractDataNodeContainerBuilder
         }
 
         @Override
-        public DataSchemaNode getDataChildByName(QName name) {
+        public DataSchemaNode getDataChildByName(final QName name) {
             return getChildNode(childNodes, name);
         }
 
         @Override
-        public DataSchemaNode getDataChildByName(String name) {
+        public DataSchemaNode getDataChildByName(final String name) {
             return getChildNode(childNodes, name);
         }
 
@@ -368,7 +368,7 @@ public final class GroupingBuilderImpl extends AbstractDataNodeContainerBuilder
         }
 
         @Override
-        public boolean equals(Object obj) {
+        public boolean equals(final Object obj) {
             if (this == obj) {
                 return true;
             }
index fca44fb1efd266598758f2ffbda9cb79d2ae4fd6..b791ae8a8c4426b14acf3c354da0c188242b30d7 100644 (file)
@@ -11,8 +11,12 @@ import java.util.Collections;
 import java.util.List;
 
 import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.model.api.*;
-import org.opendaylight.yangtools.yang.model.api.type.*;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.PatternConstraint;
+import org.opendaylight.yangtools.yang.model.api.type.RangeConstraint;
 import org.opendaylight.yangtools.yang.model.util.BaseTypes;
 import org.opendaylight.yangtools.yang.model.util.IdentityrefType;
 import org.opendaylight.yangtools.yang.parser.builder.api.AbstractTypeAwareBuilder;
@@ -37,20 +41,20 @@ public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder imple
     }
 
     @Override
-    public void setQName(QName qname) {
+    public void setQName(final QName qname) {
         this.qname = qname;
     }
 
     @Override
     public IdentityrefType build() {
-        return new IdentityrefType(baseIdentity.build(), schemaPath);
+        return IdentityrefType.create(schemaPath, baseIdentity.build());
     }
 
     public String getBaseString() {
         return baseString;
     }
 
-    public void setBaseIdentity(IdentitySchemaNodeBuilder baseIdentity) {
+    public void setBaseIdentity(final IdentitySchemaNodeBuilder baseIdentity) {
         this.baseIdentity = baseIdentity;
     }
 
@@ -66,27 +70,27 @@ public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder imple
 
     @Override
     public void setType(final TypeDefinition<?> type) {
-        throw new YangParseException(moduleName, line, "Can not set type to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set type to " + NAME);
     }
 
     @Override
     public void setTypedef(final TypeDefinitionBuilder tdb) {
-        throw new YangParseException(moduleName, line, "Can not set type to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set type to " + NAME);
     }
 
     @Override
     public void setDescription(final String description) {
-        throw new YangParseException(moduleName, line, "Can not set description to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set description to " + NAME);
     }
 
     @Override
     public void setReference(final String reference) {
-        throw new YangParseException(moduleName, line, "Can not set reference to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set reference to " + NAME);
     }
 
     @Override
     public void setStatus(final Status status) {
-        throw new YangParseException(moduleName, line, "Can not set status to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set status to " + NAME);
     }
 
     @Override
@@ -96,12 +100,12 @@ public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder imple
 
     @Override
     public void setAddedByUses(final boolean addedByUses) {
-        throw new YangParseException(moduleName, line, "Identityref type can not be added by uses.");
+        throw new YangParseException(getModuleName(), getLine(), "Identityref type can not be added by uses.");
     }
 
     @Override
     public void addUnknownNodeBuilder(final UnknownSchemaNodeBuilder unknownNode) {
-        throw new YangParseException(moduleName, line, "Can not add unknown node to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not add unknown node to " + NAME);
     }
 
     @Override
@@ -115,7 +119,7 @@ public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder imple
     }
 
     @Override
-    public void setPath(SchemaPath path) {
+    public void setPath(final SchemaPath path) {
         this.schemaPath = path;
     }
 
@@ -140,8 +144,8 @@ public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder imple
     }
 
     @Override
-    public void setRanges(List<RangeConstraint> ranges) {
-        throw new YangParseException(moduleName, line, "Can not set ranges to " + NAME);
+    public void setRanges(final List<RangeConstraint> ranges) {
+        throw new YangParseException(getModuleName(), getLine(), "Can not set ranges to " + NAME);
     }
 
     @Override
@@ -150,8 +154,8 @@ public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder imple
     }
 
     @Override
-    public void setLengths(List<LengthConstraint> lengths) {
-        throw new YangParseException(moduleName, line, "Can not set lengths to " + NAME);
+    public void setLengths(final List<LengthConstraint> lengths) {
+        throw new YangParseException(getModuleName(), getLine(), "Can not set lengths to " + NAME);
     }
 
     @Override
@@ -160,8 +164,8 @@ public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder imple
     }
 
     @Override
-    public void setPatterns(List<PatternConstraint> patterns) {
-        throw new YangParseException(moduleName, line, "Can not set patterns to " + NAME);
+    public void setPatterns(final List<PatternConstraint> patterns) {
+        throw new YangParseException(getModuleName(), getLine(), "Can not set patterns to " + NAME);
     }
 
     @Override
@@ -170,8 +174,8 @@ public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder imple
     }
 
     @Override
-    public void setFractionDigits(Integer fractionDigits) {
-        throw new YangParseException(moduleName, line, "Can not set fraction digits to " + NAME);
+    public void setFractionDigits(final Integer fractionDigits) {
+        throw new YangParseException(getModuleName(), getLine(), "Can not set fraction digits to " + NAME);
     }
 
     @Override
@@ -185,18 +189,17 @@ public final class IdentityrefTypeBuilder extends AbstractTypeAwareBuilder imple
     }
 
     @Override
-    public void setDefaultValue(Object defaultValue) {
-        throw new YangParseException(moduleName, line, "Can not set default value to " + NAME);
+    public void setDefaultValue(final Object defaultValue) {
+        throw new YangParseException(getModuleName(), getLine(), "Can not set default value to " + NAME);
     }
 
     @Override
     public String getUnits() {
         return null;
     }
-
     @Override
-    public void setUnits(String units) {
-        throw new YangParseException(moduleName, line, "Can not set units to " + NAME);
+    public void setUnits(final String units) {
+        throw new YangParseException(getModuleName(), getLine(), "Can not set units to " + NAME);
     }
 
     @Override
index c5f9732d2fb194dab6022118df32b8d7732e9504..8234ec678238a83ae3804e4a57182d905788f857 100644 (file)
@@ -201,11 +201,11 @@ public final class LeafListSchemaNodeBuilder extends AbstractTypeAwareBuilder im
         } else if (!schemaPath.equals(other.schemaPath)) {
             return false;
         }
-        if (parentBuilder == null) {
-            if (other.parentBuilder != null) {
+        if (getParent() == null) {
+            if (other.getParent() != null) {
                 return false;
             }
-        } else if (!parentBuilder.equals(other.parentBuilder)) {
+        } else if (!getParent().equals(other.getParent())) {
             return false;
         }
         return true;
index f82cbac1bce717711938b722cfe12370dceb9d8e..318f5465abbcb8cc09f463f2920274f9480087e7 100644 (file)
@@ -81,7 +81,7 @@ public final class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implem
         instance.unitsStr = unitsStr;
 
         if (type == null && typedef == null) {
-            throw new YangParseException(moduleName, line, "Failed to resolve leaf type.");
+            throw new YangParseException(getModuleName(), getLine(), "Failed to resolve leaf type.");
         }
 
         // TYPE
@@ -218,11 +218,11 @@ public final class LeafSchemaNodeBuilder extends AbstractTypeAwareBuilder implem
         } else if (!schemaPath.equals(other.schemaPath)) {
             return false;
         }
-        if (parentBuilder == null) {
-            if (other.parentBuilder != null) {
+        if (getParent() == null) {
+            if (other.getParent() != null) {
                 return false;
             }
-        } else if (!parentBuilder.equals(other.parentBuilder)) {
+        } else if (!getParent().equals(other.getParent())) {
             return false;
         }
         return true;
index c50feeeab01bc6eece4dba0f7720f917ac25af85..4b533284f73abcd0c0782f55a5251d8239e21810 100644 (file)
@@ -112,9 +112,9 @@ public final class ListSchemaNodeBuilder extends AbstractDataNodeContainerBuilde
 
         // CHILD NODES
         for (DataSchemaNodeBuilder node : addedChildNodes) {
-            childNodes.add(node.build());
+            childNodes.put(node.getQName(), node.build());
         }
-        instance.childNodes = ImmutableSet.copyOf(childNodes);
+        instance.childNodes = ImmutableSet.copyOf(childNodes.values());
 
         // KEY
         if (keys == null) {
@@ -170,7 +170,7 @@ public final class ListSchemaNodeBuilder extends AbstractDataNodeContainerBuilde
         String typeName = type.getQName().getLocalName();
         for (TypeDefinitionBuilder addedTypedef : addedTypedefs) {
             if (addedTypedef.getQName().getLocalName().equals(typeName)) {
-                throw new YangParseException(moduleName, type.getLine(), "Can not add typedef '" + typeName
+                throw new YangParseException(getModuleName(), type.getLine(), "Can not add typedef '" + typeName
                         + "': typedef with same name already declared at line " + addedTypedef.getLine());
             }
         }
@@ -183,7 +183,7 @@ public final class ListSchemaNodeBuilder extends AbstractDataNodeContainerBuilde
     }
 
     @Override
-    public void setPath(SchemaPath path) {
+    public void setPath(final SchemaPath path) {
         this.schemaPath = path;
     }
 
@@ -213,7 +213,7 @@ public final class ListSchemaNodeBuilder extends AbstractDataNodeContainerBuilde
     }
 
     @Override
-    public void setStatus(Status status) {
+    public void setStatus(final Status status) {
         this.status = Preconditions.checkNotNull(status, "status cannot be null");
     }
 
@@ -240,7 +240,7 @@ public final class ListSchemaNodeBuilder extends AbstractDataNodeContainerBuilde
     }
 
     @Override
-    public void setAugmenting(boolean augmenting) {
+    public void setAugmenting(final boolean augmenting) {
         this.augmenting = augmenting;
     }
 
@@ -260,7 +260,7 @@ public final class ListSchemaNodeBuilder extends AbstractDataNodeContainerBuilde
     }
 
     @Override
-    public void setConfiguration(boolean configuration) {
+    public void setConfiguration(final boolean configuration) {
         this.configuration = configuration;
     }
 
@@ -304,11 +304,11 @@ public final class ListSchemaNodeBuilder extends AbstractDataNodeContainerBuilde
         } else if (!schemaPath.equals(other.schemaPath)) {
             return false;
         }
-        if (parentBuilder == null) {
-            if (other.parentBuilder != null) {
+        if (getParent() == null) {
+            if (other.getParent() != null) {
                 return false;
             }
-        } else if (!parentBuilder.equals(other.parentBuilder)) {
+        } else if (!getParent().equals(other.getParent())) {
             return false;
         }
         return true;
index e8716365d4adf6a88d16734074d1cd5055507ae2..9650deb85fa9abf715ca69ccd31a600b21a3f29e 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.yangtools.yang.parser.builder.impl;
 
 import java.net.URI;
 import java.util.ArrayList;
+import java.util.Collection;
 import java.util.Collections;
 import java.util.Date;
 import java.util.Deque;
@@ -143,7 +144,7 @@ public class ModuleBuilder extends AbstractDataNodeContainerBuilder {
         revision = base.getRevision();
 
         for (DataSchemaNode childNode : base.getChildNodes()) {
-            childNodes.add(childNode);
+            childNodes.put(childNode.getQName(), childNode);
         }
 
         typedefs.addAll(base.getTypeDefinitions());
@@ -181,9 +182,9 @@ public class ModuleBuilder extends AbstractDataNodeContainerBuilder {
 
         // CHILD NODES
         for (DataSchemaNodeBuilder child : addedChildNodes) {
-            childNodes.add(child.build());
+            childNodes.put(child.getQName(), child.build());
         }
-        instance.addChildNodes(childNodes);
+        instance.addChildNodes(childNodes.values());
 
         // GROUPINGS
         for (GroupingBuilder gb : addedGroupings) {
@@ -1115,7 +1116,7 @@ public class ModuleBuilder extends AbstractDataNodeContainerBuilder {
             return Collections.unmodifiableSet(childNodes);
         }
 
-        private void addChildNodes(final Set<DataSchemaNode> childNodes) {
+        private void addChildNodes(final Collection<DataSchemaNode> childNodes) {
             if (childNodes != null) {
                 this.childNodes.addAll(childNodes);
             }
@@ -1380,7 +1381,7 @@ public class ModuleBuilder extends AbstractDataNodeContainerBuilder {
 
         String msg = String.format("%s%s with same name '%s' already declared at line %d.", msgPrefix, type, name,
                 duplicateLine);
-        throw new YangParseException(moduleName, currentLine, msg);
+        throw new YangParseException(getModuleName(), currentLine, msg);
     }
 
     @Override
index 824bd1a262cc2cf8a1cef670ab5435a288de7252..8d7e4b669e0966b28533b21fbaad2fb0e38842e8 100644 (file)
@@ -78,8 +78,8 @@ public final class NotificationBuilder extends AbstractDataNodeContainerBuilder
 
     @Override
     public NotificationDefinition build() {
-        if (!(parentBuilder instanceof ModuleBuilder)) {
-            throw new YangParseException(moduleName, line, "Notification can be defined only under module (was " + parentBuilder + ")");
+        if (!(getParent() instanceof ModuleBuilder)) {
+            throw new YangParseException(getModuleName(), getLine(), "Notification can be defined only under module (was " + getParent() + ")");
         }
         if (instance != null) {
             return instance;
@@ -93,9 +93,9 @@ public final class NotificationBuilder extends AbstractDataNodeContainerBuilder
 
         // CHILD NODES
         for (DataSchemaNodeBuilder node : addedChildNodes) {
-            childNodes.add(node.build());
+            childNodes.put(node.getQName(), node.build());
         }
-        instance.childNodes = ImmutableSet.copyOf(childNodes);
+        instance.childNodes = ImmutableSet.copyOf(childNodes.values());
 
         // GROUPINGS
         for (GroupingBuilder builder : addedGroupings) {
@@ -147,7 +147,7 @@ public final class NotificationBuilder extends AbstractDataNodeContainerBuilder
     }
 
     @Override
-    public void setPath(SchemaPath path) {
+    public void setPath(final SchemaPath path) {
         this.schemaPath = path;
     }
 
@@ -177,7 +177,7 @@ public final class NotificationBuilder extends AbstractDataNodeContainerBuilder
     }
 
     @Override
-    public void setStatus(Status status) {
+    public void setStatus(final Status status) {
         this.status = Preconditions.checkNotNull(status, "status cannot be null");
     }
 
index 6b08839499fd2d5e39ab566e5c3cac957c5ac96a..620022d3fefa18a2e24e9df0159d0be5809fd66f 100644 (file)
@@ -84,7 +84,7 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
             for (TypeDefinitionBuilder tdb : typedefs) {
                 types.add(tdb.build());
             }
-            instance = new UnionType(types);
+            instance = UnionType.create(types);
             isBuilt = true;
         }
         return instance;
@@ -92,17 +92,17 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setDescription(final String description) {
-        throw new YangParseException(moduleName, line, "Can not set description to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set description to " + NAME);
     }
 
     @Override
     public void setReference(final String reference) {
-        throw new YangParseException(moduleName, line, "Can not set reference to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set reference to " + NAME);
     }
 
     @Override
     public void setStatus(final Status status) {
-        throw new YangParseException(moduleName, line, "Can not set status to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set status to " + NAME);
     }
 
     @Override
@@ -112,7 +112,7 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setAddedByUses(final boolean addedByUses) {
-        throw new YangParseException(moduleName, line, "Union type can not be added by uses.");
+        throw new YangParseException(getModuleName(), getLine(), "Union type can not be added by uses.");
     }
 
     @Override
@@ -122,12 +122,12 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public SchemaPath getPath() {
-        return BaseTypes.schemaPath(QNAME);
+        return SchemaPath.create(true,  QNAME);
     }
 
     @Override
     public void setPath(final SchemaPath path) {
-        throw new YangParseException(moduleName, line, "Can not set path to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set path to " + NAME);
     }
 
     @Override
@@ -152,7 +152,7 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setRanges(final List<RangeConstraint> ranges) {
-        throw new YangParseException(moduleName, line, "Can not set ranges to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set ranges to " + NAME);
     }
 
     @Override
@@ -162,7 +162,7 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setLengths(final List<LengthConstraint> lengths) {
-        throw new YangParseException(moduleName, line, "Can not set lengths to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set lengths to " + NAME);
     }
 
     @Override
@@ -172,7 +172,7 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setPatterns(final List<PatternConstraint> patterns) {
-        throw new YangParseException(moduleName, line, "Can not set patterns to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set patterns to " + NAME);
     }
 
     @Override
@@ -182,7 +182,7 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setFractionDigits(final Integer fractionDigits) {
-        throw new YangParseException(moduleName, line, "Can not set fraction digits to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set fraction digits to " + NAME);
     }
 
     @Override
@@ -197,7 +197,7 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setDefaultValue(final Object defaultValue) {
-        throw new YangParseException(moduleName, line, "Can not set default value to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set default value to " + NAME);
     }
 
     @Override
@@ -207,7 +207,7 @@ public final class UnionTypeBuilder extends AbstractTypeAwareBuilder implements
 
     @Override
     public void setUnits(final String units) {
-        throw new YangParseException(moduleName, line, "Can not set units to " + NAME);
+        throw new YangParseException(getModuleName(), getLine(), "Can not set units to " + NAME);
     }
 
     @Override
index 91c5e9a994e9acb2221a9ed1c0b7a79703655077..f038e236336c11e288bf5c81ed2d33289a8fcbdc 100644 (file)
@@ -95,7 +95,7 @@ public final class UsesNodeBuilderImpl extends AbstractBuilder implements UsesNo
     @Override
     public void setParent(final Builder parent) {
         if (!(parent instanceof DataNodeContainerBuilder)) {
-            throw new YangParseException(moduleName, line,
+            throw new YangParseException(getModuleName(), getLine(),
                     "Parent of 'uses' has to be instance of DataNodeContainerBuilder, but was: '" + parent + "'.");
         }
         this.parentBuilder = (DataNodeContainerBuilder) parent;
index d0af63da9b88f8babcf20de1755cb0cefb7178db..0b8a52f07222c23fc68d41af510809c2a260dbfd 100644 (file)
@@ -50,6 +50,7 @@ import org.opendaylight.yangtools.antlrv4.code.gen.YangLexer;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangParser;
 import org.opendaylight.yangtools.antlrv4.code.gen.YangParser.YangContext;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
 import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
@@ -449,7 +450,7 @@ public final class YangParserImpl implements YangContextParser {
         module.getAugmentBuilders().addAll(submodule.getAugmentBuilders());
         module.getAllAugments().addAll(submodule.getAllAugments());
         module.getChildNodeBuilders().addAll(submodule.getChildNodeBuilders());
-        module.getChildNodes().addAll(submodule.getChildNodes());
+        module.getChildNodes().putAll(submodule.getChildNodes());
         module.getGroupings().addAll(submodule.getGroupings());
         module.getGroupingBuilders().addAll(submodule.getGroupingBuilders());
         module.getTypeDefinitions().addAll(submodule.getTypeDefinitions());
@@ -850,8 +851,9 @@ public final class YangParserImpl implements YangContextParser {
                 prefix = baseQName.getPrefix();
             }
 
+            final QNameModule qm = QNameModule.create(ns, revision);
             for (QName qn : oldSchemaPath.getPath()) {
-                newPath.add(new QName(ns, revision, prefix, qn.getLocalName()));
+                newPath.add(QName.create(qm, prefix, qn.getLocalName()));
             }
         } else {
             for (QName qn : oldPath) {
@@ -918,7 +920,7 @@ public final class YangParserImpl implements YangContextParser {
      */
     private void checkAugmentMandatoryNodes(final Collection<AugmentationSchemaBuilder> augments) {
         for (AugmentationSchemaBuilder augment : augments) {
-            String augmentPrefix = augment.getTargetPath().getPath().get(0).getPrefix();
+            String augmentPrefix = augment.getTargetPath().getPathFromRoot().iterator().next().getPrefix();
             ModuleBuilder module = ParserUtils.getParentModule(augment);
             String modulePrefix = module.getPrefix();
 
@@ -1052,8 +1054,8 @@ public final class YangParserImpl implements YangContextParser {
             return true;
         }
 
-        List<QName> targetPath = augment.getTargetPath().getPath();
-        ModuleBuilder targetModule = findTargetModule(targetPath.get(0), module, modules, context, augment.getLine());
+        QName targetPath = augment.getTargetPath().getPathFromRoot().iterator().next();
+        ModuleBuilder targetModule = findTargetModule(targetPath, module, modules, context, augment.getLine());
         if (targetModule == null) {
             throw new YangParseException(module.getModuleName(), augment.getLine(), "Failed to resolve augment "
                     + augment);
@@ -1497,8 +1499,8 @@ public final class YangParserImpl implements YangContextParser {
         for (DeviationBuilder dev : module.getDeviationBuilders()) {
             int line = dev.getLine();
             SchemaPath targetPath = dev.getTargetPath();
-            List<QName> path = targetPath.getPath();
-            QName q0 = path.get(0);
+            Iterable<QName> path = targetPath.getPathFromRoot();
+            QName q0 = path.iterator().next();
             String prefix = q0.getPrefix();
             if (prefix == null) {
                 prefix = module.getPrefix();
@@ -1544,8 +1546,8 @@ public final class YangParserImpl implements YangContextParser {
         for (DeviationBuilder dev : module.getDeviationBuilders()) {
             int line = dev.getLine();
             SchemaPath targetPath = dev.getTargetPath();
-            List<QName> path = targetPath.getPath();
-            QName q0 = path.get(0);
+            Iterable<QName> path = targetPath.getPathFromRoot();
+            QName q0 = path.iterator().next();
             String prefix = q0.getPrefix();
             if (prefix == null) {
                 prefix = module.getPrefix();
@@ -1591,7 +1593,7 @@ public final class YangParserImpl implements YangContextParser {
      *            current module
      */
     private void processDeviation(final DeviationBuilder dev, final ModuleBuilder dependentModuleBuilder,
-            final List<QName> path, final ModuleBuilder module) {
+            final Iterable<QName> path, final ModuleBuilder module) {
         final int line = dev.getLine();
         Builder currentParent = dependentModuleBuilder;
 
index 6530c92510c8d6aabd43eb5640a4ae146b5c71ca..bbc49453bdd45cae6b4659fa73b49d73fa88ce03 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * Copyright (c) 2014 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/eplv10.html
@@ -30,6 +29,22 @@ import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableSet;
 
+/**
+ * Helper transfer object which holds basic and dependency information for YANG
+ * model.
+ *
+ *
+ *
+ * There are two concrete implementations of this interface:
+ * <ul>
+ * <li>{@link ModuleDependencyInfo} - Dependency information for module</li>
+ * <li>{@link SubmoduleDependencyInfo} - Dependency information for submodule</li>
+ * </ul>
+ *
+ * @see ModuleDependencyInfo
+ * @see SubmoduleDependencyInfo
+ *
+ */
 public abstract class YangModelDependencyInfo {
 
     private final String name;
@@ -39,8 +54,8 @@ public abstract class YangModelDependencyInfo {
     private final ImmutableSet<ModuleImport> moduleImports;
     private final ImmutableSet<ModuleImport> dependencies;
 
-    public YangModelDependencyInfo(final String name, final String formattedRevision, final ImmutableSet<ModuleImport> imports,
-            final ImmutableSet<ModuleImport> includes) {
+    protected YangModelDependencyInfo(final String name, final String formattedRevision,
+            final ImmutableSet<ModuleImport> imports, final ImmutableSet<ModuleImport> includes) {
         this.name = name;
         this.formattedRevision = formattedRevision;
         this.revision = QName.parseRevision(formattedRevision);
@@ -52,18 +67,41 @@ public abstract class YangModelDependencyInfo {
                 .build();
     }
 
+    /**
+     * Returns immutable collection of all module imports.
+     *
+     * This collection contains both <code>import</code> statements
+     * and <code>include</code> statements for submodules.
+     *
+     * @return Immutable collection of imports.
+     */
     public ImmutableSet<ModuleImport> getDependencies() {
         return dependencies;
     }
 
+    /**
+     * Returns model name
+     *
+     * @return model name
+     */
     public String getName() {
         return name;
     }
 
+    /**
+     * Returns formatted revision string
+     *
+     * @return formatted revision string
+     */
     public String getFormattedRevision() {
         return formattedRevision;
     }
 
+    /**
+     * Returns revision
+     *
+     * @return revision
+     */
     public Date getRevision() {
         return revision;
     }
@@ -106,33 +144,46 @@ public abstract class YangModelDependencyInfo {
         return true;
     }
 
+    /**
+     * Extracts {@link YangModelDependencyInfo} from input stream
+     * containing YANG model.
+     *
+     * This parsing does not validate full YANG module, only
+     * parses header up to the revisions and imports.
+     *
+     * @param yangStream
+     *            Opened Input stream containing text source of YANG model
+     * @return {@link YangModelDependencyInfo}
+     * @throws IllegalArgumentException
+     *             If input stream is not valid YANG stream
+     */
     public static YangModelDependencyInfo fromInputStream(final InputStream yangStream) {
         YangContext yangContext = YangParserImpl.parseStreamWithoutErrorListeners(yangStream);
 
         Optional<Module_stmtContext> moduleCtx = getFirstContext(yangContext, Module_stmtContext.class);
         if (moduleCtx.isPresent()) {
-            return fromModuleContext(moduleCtx.get());
+            return parseModuleContext(moduleCtx.get());
         }
         Optional<Submodule_stmtContext> submoduleCtx = getFirstContext(yangContext, Submodule_stmtContext.class);
         if (submoduleCtx.isPresent()) {
-            return fromSubmoduleContext(submoduleCtx.get());
+            return parseSubmoduleContext(submoduleCtx.get());
         }
         throw new IllegalArgumentException("Supplied stream is not valid yang file.");
     }
 
-    private static YangModelDependencyInfo fromModuleContext(final Module_stmtContext module) {
+    private static YangModelDependencyInfo parseModuleContext(final Module_stmtContext module) {
         String name = getArgumentString(module);
         // String prefix =
         // getArgumentString(module.module_header_stmts().prefix_stmt(0));
         String namespace = getArgumentString(module.module_header_stmts().namespace_stmt(0));
         String latestRevision = getLatestRevision(module.revision_stmts());
-        ImmutableSet<ModuleImport> imports = getImports(module.linkage_stmts().import_stmt());
-        ImmutableSet<ModuleImport> includes = getIncludes(module.linkage_stmts().include_stmt());
+        ImmutableSet<ModuleImport> imports = parseImports(module.linkage_stmts().import_stmt());
+        ImmutableSet<ModuleImport> includes = parseIncludes(module.linkage_stmts().include_stmt());
 
         return new ModuleDependencyInfo(name, latestRevision, namespace, imports, includes);
     }
 
-    private static ImmutableSet<ModuleImport> getImports(final List<Import_stmtContext> importStatements) {
+    private static ImmutableSet<ModuleImport> parseImports(final List<Import_stmtContext> importStatements) {
         ImmutableSet.Builder<ModuleImport> builder = ImmutableSet.builder();
         for (Import_stmtContext importStmt : importStatements) {
             String moduleName = getArgumentString(importStmt);
@@ -154,19 +205,19 @@ public abstract class YangModelDependencyInfo {
         return latestRevision;
     }
 
-    private static YangModelDependencyInfo fromSubmoduleContext(final Submodule_stmtContext submodule) {
+    private static YangModelDependencyInfo parseSubmoduleContext(final Submodule_stmtContext submodule) {
         String name = getArgumentString(submodule);
         Belongs_to_stmtContext belongsToStmt = submodule.submodule_header_stmts().belongs_to_stmt(0);
         String belongsTo = getArgumentString(belongsToStmt);
 
         String latestRevision = getLatestRevision(submodule.revision_stmts());
-        ImmutableSet<ModuleImport> imports = getImports(submodule.linkage_stmts().import_stmt());
-        ImmutableSet<ModuleImport> includes = getIncludes(submodule.linkage_stmts().include_stmt());
+        ImmutableSet<ModuleImport> imports = parseImports(submodule.linkage_stmts().import_stmt());
+        ImmutableSet<ModuleImport> includes = parseIncludes(submodule.linkage_stmts().include_stmt());
 
         return new SubmoduleDependencyInfo(name, latestRevision, belongsTo, imports, includes);
     }
 
-    private static ImmutableSet<ModuleImport> getIncludes(final List<Include_stmtContext> importStatements) {
+    private static ImmutableSet<ModuleImport> parseIncludes(final List<Include_stmtContext> importStatements) {
         ImmutableSet.Builder<ModuleImport> builder = ImmutableSet.builder();
         for (Include_stmtContext importStmt : importStatements) {
             String moduleName = getArgumentString(importStmt);
@@ -184,6 +235,11 @@ public abstract class YangModelDependencyInfo {
         return QName.parseRevision(formatedDate);
     }
 
+    /**
+     *
+     * Dependency information for YANG module.
+     *
+     */
     public static final class ModuleDependencyInfo extends YangModelDependencyInfo {
 
         private ModuleDependencyInfo(final String name, final String latestRevision, final String namespace,
@@ -193,15 +249,25 @@ public abstract class YangModelDependencyInfo {
 
         @Override
         public String toString() {
-            return "Module [name=" + getName() + ", revision=" + getRevision()
-                    + ", dependencies=" + getDependencies() + "]";
+            return "Module [name=" + getName() + ", revision=" + getRevision() + ", dependencies=" + getDependencies()
+                    + "]";
         }
     }
 
+    /**
+     *
+     * Dependency information for submodule, also provides name
+     * for parent module.
+     *
+     */
     public static final class SubmoduleDependencyInfo extends YangModelDependencyInfo {
 
         private final String belongsTo;
 
+        /**
+         * Returns name of parent module.
+         *
+         */
         public String getParentModule() {
             return belongsTo;
         }
@@ -214,11 +280,16 @@ public abstract class YangModelDependencyInfo {
 
         @Override
         public String toString() {
-            return "Submodule [name=" + getName() + ", revision=" + getRevision()
-                    + ", dependencies=" + getDependencies() + "]";
+            return "Submodule [name=" + getName() + ", revision=" + getRevision() + ", dependencies="
+                    + getDependencies() + "]";
         }
     }
 
+    /**
+     * Utility implementation of {@link ModuleImport} to be used by
+     * {@link YangModelDependencyInfo}.
+     *
+     */
     private static final class ModuleImportImpl implements ModuleImport {
 
         private final Date revision;
index fe0e81e43e22debf9286b50402c4d6dc24ee0674..1975d165a9305bd26801a2d0004936009f45f262 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * Copyright (c) 2014 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/eplv10.html
@@ -14,6 +13,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
+import org.opendaylight.yangtools.concepts.Delegator;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Module;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
@@ -29,7 +29,33 @@ import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableMultimap;
 import com.google.common.collect.ImmutableSet;
 
-public class YangSourceContext implements AdvancedSchemaSourceProvider<InputStream>, AutoCloseable {
+/**
+ *
+ * Context of YANG model sources
+ *
+ * YANG sources context represent information learned about set of model sources
+ * which could be derived from dependency information only.
+ *
+ * Contains following information:
+ * <ul>
+ * <li>{@link #getValidSources()} - set of {@link SourceIdentifier} which have
+ * their dependencies present and are safe to be used by full blown parser.
+ * <li>{@link #getMissingSources()} - set of {@link SourceIdentifier} which have
+ * been referenced by other YANG sources, but source code for them is missing.
+ * <li>{@link #getMissingDependencies()} - map of {@link SourceIdentifier} and
+ * their imports for which source codes was not available.
+ *
+ * {@link YangSourceContext} may be associated with {@link SchemaSourceProvider}
+ * (see {@link #getDelegate()}, which was used for retrieval of sources during
+ * context computation.
+ *
+ * {@link YangSourceContext} may be used as schema source provider to retrieve
+ * this sources.
+ *
+ *
+ */
+public class YangSourceContext implements AdvancedSchemaSourceProvider<InputStream>, AutoCloseable,
+        Delegator<AdvancedSchemaSourceProvider<InputStream>> {
 
     private final ImmutableSet<SourceIdentifier> validSources;
 
@@ -37,24 +63,62 @@ public class YangSourceContext implements AdvancedSchemaSourceProvider<InputStre
     private final ImmutableMultimap<SourceIdentifier, ModuleImport> missingDependencies;
     private AdvancedSchemaSourceProvider<InputStream> sourceProvider;
 
+    /**
+     * Construct YANG Source Context
+     * 
+     * @param validSourcesSet Set of identifiers of valid sources
+     * @param missingSourcesSet Set of identifiers of missing sources
+     * @param missingDependenciesMap Map of identifiers of resolved sources and their missing imports.
+     * @param sourceProvider Source provider which was used for context resolution or 
+     *          null if provider was not used.
+     */
     YangSourceContext(final ImmutableSet<SourceIdentifier> validSourcesSet,
             final ImmutableSet<SourceIdentifier> missingSourcesSet,
             final ImmutableMultimap<SourceIdentifier, ModuleImport> missingDependenciesMap,
-            final AdvancedSchemaSourceProvider<InputStream> sourceProvicer) {
-        validSources = validSourcesSet;
-        missingSources = missingSourcesSet;
-        missingDependencies = missingDependenciesMap;
-        sourceProvider = sourceProvicer;
+            final AdvancedSchemaSourceProvider<InputStream> sourceProvider) {
+        validSources = Preconditions.checkNotNull(validSourcesSet, "Valid source set must not be null");
+        missingSources = Preconditions.checkNotNull(missingSourcesSet, "Missing sources set must not be null");
+        missingDependencies = Preconditions.checkNotNull(missingDependenciesMap, "Missing dependencies map must not be null");
+        this.sourceProvider = sourceProvider;
     }
 
+    /**
+     * Returns set of valid source identifiers.
+     *
+     * Source identifier is considered valid if it's source
+     * was present during resolution and sources
+     * for all known dependencies was present at the time of creation
+     * of {@link YangSourceContext}.
+     *
+     * @return Set of valid source identifiers.
+     */
     public ImmutableSet<SourceIdentifier> getValidSources() {
         return validSources;
     }
 
+    /**
+     * Returns set of source identifiers, whom sources was not resolved.
+     *
+     * Source is considered missing if the source was not present
+     * during resolution of {@link YangSourceContext}.
+     *
+     * @return Set of missing sources.
+     */
     public ImmutableSet<SourceIdentifier> getMissingSources() {
         return missingSources;
     }
 
+    /**
+     * Returns a multimap of Source Identifier and imports which had missing
+     * sources.
+     *
+     * Maps a source identifier to its imports, which was not resolved
+     * during resolution of this context, so it is unable to fully
+     * processed source identifier.
+     *
+     *
+     * @return Multi-map of source identifier to it's unresolved dependencies.
+     */
     public ImmutableMultimap<SourceIdentifier, ModuleImport> getMissingDependencies() {
         return missingDependencies;
     }
@@ -77,6 +141,11 @@ public class YangSourceContext implements AdvancedSchemaSourceProvider<InputStre
         return sourceProvider;
     }
 
+    @Override
+    public AdvancedSchemaSourceProvider<InputStream> getDelegate() {
+        return sourceProvider;
+    }
+
     @Override
     public void close() {
         if (sourceProvider != null) {
@@ -84,33 +153,119 @@ public class YangSourceContext implements AdvancedSchemaSourceProvider<InputStre
         }
     }
 
+    /**
+     * Creates YANG Source context from supplied capabilities and schema source
+     * provider.
+     *
+     * @param capabilities
+     *            Set of QName representing module capabilities,
+     *            {@link QName#getLocalName()} represents
+     *            source name and {@link QName#getRevision()} represents
+     *            revision of source.
+     *
+     * @param schemaSourceProvider
+     *            - {@link SchemaSourceProvider} which should be used to resolve
+     *            sources.
+     * @return YANG source context which describes resolution of capabilities
+     *         and their dependencies
+     *         against supplied schema source provider.
+     */
     public static final YangSourceContext createFrom(final Iterable<QName> capabilities,
             final SchemaSourceProvider<InputStream> schemaSourceProvider) {
         YangSourceContextResolver resolver = new YangSourceFromCapabilitiesResolver(capabilities, schemaSourceProvider);
         return resolver.resolveContext();
     }
 
-    public static final YangSourceContext createFrom(final Map<SourceIdentifier, YangModelDependencyInfo> moduleDependencies) {
+    public static final YangSourceContext createFrom(
+            final Map<SourceIdentifier, YangModelDependencyInfo> moduleDependencies) {
         YangSourceContextResolver resolver = new YangSourceFromDependencyInfoResolver(moduleDependencies);
         return resolver.resolveContext();
     }
 
+    /**
+     * Tries to create schema context using {@link YangParserImpl} and valid
+     * sources
+     * retrieved from YANG Source context and schema source provider which
+     * was used to create YANG Source Context
+     *
+     * @param context
+     * @return Schema Context created from valid sources in YANG Source Context
+     * @deprecated Use {@link #toSchemaContext(AdvancedSchemaSourceProvider)}
+     *  with {@link #getDelegate()}
+     */
+    @Deprecated
     public static final SchemaContext toSchemaContext(final YangSourceContext context) {
-        List<InputStream> inputStreams = getValidInputStreams(context);
+        return context.toSchemaContext(context.getDelegate());
+    }
+
+    /**
+     * Tries to create schema context using {@link YangParserImpl} and valid
+     * sources
+     * retrieved from YANG Source context and schema source provider which
+     * was used to create YANG Source Context
+     *
+     * @param provider
+     *            Schema Source Provider to be used to retrieve sources
+     * @return Schema Context created from valid sources in YANG Source Context
+     */
+    public final SchemaContext toSchemaContext(AdvancedSchemaSourceProvider<InputStream> provider) {
+        List<InputStream> inputStreams = this.getValidInputStreams(provider);
         YangParserImpl parser = new YangParserImpl();
+        @SuppressWarnings("deprecation")
         Set<Module> models = parser.parseYangModelsFromStreams(inputStreams);
         return parser.resolveSchemaContext(models);
     }
 
+    /**
+     * Returns a list of valid input streams from YANG Source Context
+     * using schema source provider which was used to create YANG Source Context
+     *
+     * @param context
+     *            YANG Source context
+     * @return List of input streams for valid sources.
+     * @deprecated Use
+     *             {@link #getValidInputStreams(AdvancedSchemaSourceProvider)}
+     *             combined with {@link #getDelegate()} instead.
+     */
+    @Deprecated
     public static List<InputStream> getValidInputStreams(final YangSourceContext context) {
-        return getValidInputStreams(context, context.sourceProvider);
+        return context.getValidInputStreams(context.getDelegate());
     }
 
+    /**
+     * Returns a list of valid input streams from YANG Source Context
+     * using supplied schema source provider.
+     *
+     * @param context
+     *            YANG Source context from which list of valid sources is used
+     * @param provider
+     *            Schema Source Provider which is used to retrieve sources
+     * @return List of input streams.
+     * @deprecated Use
+     *             {@link #getValidInputStreams(AdvancedSchemaSourceProvider)}
+     *             instead.
+     */
+    @Deprecated
     public static List<InputStream> getValidInputStreams(final YangSourceContext context,
             final AdvancedSchemaSourceProvider<InputStream> provider) {
+        return context.getValidInputStreams(provider);
+    }
+
+    /**
+     * Returns a list of valid input streams from YANG Source Context
+     * using supplied schema source provider.
+     *
+     * @param context
+     *            YANG Source context from which list of valid sources is used
+     * @param provider
+     *            Schema Source Provider which is used to retrieve sources
+     * @return List of input streams.
+     */
+    public List<InputStream> getValidInputStreams(final AdvancedSchemaSourceProvider<InputStream> provider) {
+        Preconditions.checkNotNull(provider, "provider must not be null.");
         final HashSet<SourceIdentifier> sourcesToLoad = new HashSet<>();
-        sourcesToLoad.addAll(context.getValidSources());
-        for (SourceIdentifier source : context.getValidSources()) {
+        sourcesToLoad.addAll(this.getValidSources());
+        for (SourceIdentifier source : this.getValidSources()) {
             if (source.getRevision() != null) {
                 SourceIdentifier sourceWithoutRevision = SourceIdentifier.create(source.getName(),
                         Optional.<String> absent());
index 50f4a3e8cddf93ea63069b18cf0ed24150c8572e..ae63663699f9f4784dcc0aaeb26a2149070dff52 100644 (file)
@@ -1,6 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
- *
+ * Copyright (c) 2014 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/eplv10.html
@@ -13,6 +12,7 @@ import java.util.HashMap;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.ModuleImport;
 import org.opendaylight.yangtools.yang.model.util.repo.AdvancedSchemaSourceProvider;
+import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -21,20 +21,78 @@ import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMultimap;
 import com.google.common.collect.ImmutableSet;
 
+/**
+ *
+ * Resolution task for YANG Source Context
+ *
+ * {@link YangSourceContextResolver} and its subclasses are responsible for
+ * resolving {@link YangSourceContext} based on provided
+ * {@link SchemaSourceProvider} and set of modules to process.
+ *
+ *
+ * <h3>Implementation notes</h3>
+ *
+ * In order to customize resolution of {@link YangSourceContext} implementators
+ * of this class are required to implement following methods:
+ * <ul>
+ * <li>{@link #getDependencyInfo(SourceIdentifier)} - Retrieval of dependency
+ * information</li>
+ * <li>{@link #resolveContext()} - Main resolution algorithm
+ * <li>
+ * </ul>
+ *
+ * This abstract class provides utility methods for implementators which may be
+ * used in {@link #resolveContext()} to create {@link YangSourceContext}:
+ * <ul>
+ * <li>{@link #resolveSource(SourceIdentifier)} and
+ * {@link #resolveSource(String, Optional)} - Tries to resolve state for
+ * supplied model identifier and updates internal state. If state was not
+ * already resolved for identifier it invokes
+ * {@link #getDependencyInfo(SourceIdentifier)} for particular identifier. This
+ * method is recursivelly invoked for all dependencies.</li>
+ * <li>{@link #createSourceContext()} - Creates {@link YangSourceContext} based
+ * on previous invocations of {@link #resolveSource(SourceIdentifier)} methods.</li>
+ * </ul>
+ *
+ */
 public abstract class YangSourceContextResolver {
 
-    enum ResolutionState {
-        MISSING_SOURCE,
-        MISSING_DEPENDENCY,
-        OTHER_ERROR,
+    /**
+     * 
+     * State of source code resolution
+     * 
+     */
+    public enum ResolutionState {
+        /**
+         * 
+         * Source was missing during source resolution
+         * 
+         */
+        MISSING_SOURCE, 
+        /**
+         * 
+         * One or multiple of dependencies of source are missing 
+         * 
+         */
+        MISSING_DEPENDENCY, 
+        /**
+         * Other error ocurred during resolution
+         * 
+         */
+        OTHER_ERROR, 
+        /**
+         * Source, its dependencies and its transient dependencies
+         * are resolved.
+         * 
+         */
         EVERYTHING_OK,
     }
 
     private static final Logger LOG = LoggerFactory.getLogger(YangSourceContextResolver.class);
     private final HashMap<SourceIdentifier, YangSourceContextResolver.ResolutionState> alreadyProcessed = new HashMap<>();
     private final ImmutableSet.Builder<SourceIdentifier> missingSources = ImmutableSet.builder();
-    private final ImmutableMultimap.Builder<SourceIdentifier, ModuleImport> missingDependencies =
-            ImmutableMultimap.builder();
+    private final ImmutableMultimap.Builder<SourceIdentifier, ModuleImport> missingDependencies = ImmutableMultimap
+            .builder();
     private final ImmutableSet.Builder<SourceIdentifier> validSources = ImmutableSet.builder();
     private final AdvancedSchemaSourceProvider<InputStream> sourceProvider;
 
@@ -43,22 +101,127 @@ public abstract class YangSourceContextResolver {
     }
 
     public YangSourceContextResolver(final AdvancedSchemaSourceProvider<InputStream> sourceProvicer) {
-        super();
         this.sourceProvider = sourceProvicer;
     }
 
+    /**
+     * Resolves {@link YangSourceContext}
+     *
+     * Implementators of this method should invoke
+     * {@link #resolveSource(SourceIdentifier)} for sources which should be
+     * present in {@link YangSourceContext} and {@link #createSourceContext()}
+     * to create resulting {@link YangSourceContext} which will contain state
+     * derived by callbacks to {@link #getDependencyInfo(SourceIdentifier)}.
+     *
+     * @return Resolved {@link YangSourceContext}.
+     */
     public abstract YangSourceContext resolveContext();
-    public abstract Optional<YangModelDependencyInfo> getDependencyInfo(SourceIdentifier identifier);
 
+    /**
+     * Returns dependency information for provided identifier
+     *
+     * Implementations are required to:
+     * <ul>
+     * <li>return {@link Optional#absent()} If source code for source is not
+     * present</li>
+     * <li>return same dependency information for multiple invocations of this
+     * method for same source identifier.</li>
+     * <li>return latest available revision if {@link SourceIdentifier} does not
+     * specify revision. If no revision is available {@link Optional#absent()}
+     * MUST be returned.</li>
+     * </ul>
+     *
+     *
+     * Internal state of this object (and resulting {@link YangSourceContext}
+     * will be updated as following:
+     * <ul>
+     * <li>If {@link Optional#absent()} is returned:
+     * <ul>
+     * <li>source will be marked as {@link ResolutionState#MISSING_SOURCE} and
+     * source identifier will be contained in -
+     * {@link YangSourceContext#getMissingSources()}</li>
+     * <li>All sources which imported or included this source will be present in
+     * {@link YangSourceContext#getMissingDependencies()}</li>
+     * </ul>
+     *
+     *
+     *
+     * @param identifier
+     *            Source identifier
+     * @return Dependency Information for {@link SourceIdentifier},
+     *         {@link Optional#absent()} if no source is present.
+     */
+    abstract Optional<YangModelDependencyInfo> getDependencyInfo(SourceIdentifier identifier);
+
+    /**
+     * Return Source provider against which YANG source context was computed
+     *
+     * @return Source provider against which YANG source context was computed or null, if source provider
+     *   is not associated with computation.
+     */
     public AdvancedSchemaSourceProvider<InputStream> getSourceProvider() {
         return sourceProvider;
     }
 
-    public YangSourceContextResolver.ResolutionState resolveSource(final String name, final Optional<String> formattedRevision) {
+    /**
+     *
+     * Resolves resolution state for provided name and formated revision
+     *
+     * This method is shorthand for {@link #resolveSource(SourceIdentifier)}
+     * with argument <code>new SourceIdentifier(name, formattedRevision)</code>
+     *
+     * @see #resolveSource(SourceIdentifier)
+     * @param name
+     *            Name of YANG model
+     * @param formattedRevision
+     *            revision of YANG model
+     * @return Resolution context of YANG Source
+     */
+    public final YangSourceContextResolver.ResolutionState resolveSource(final String name,
+            final Optional<String> formattedRevision) {
         return resolveSource(new SourceIdentifier(name, formattedRevision));
     }
 
-    public YangSourceContextResolver.ResolutionState resolveSource(final SourceIdentifier identifier) {
+    /**
+     * Resolves state of source and updates internal state accordingly.
+     *
+     * <p>
+     * Resolves state of source and updates internal state based on resolution.
+     * This method tries to get module dependency info via user implementation
+     * of {@link #getDependencyInfo(SourceIdentifier)} and then is recursively
+     * called for each announced dependency in
+     * {@link YangModelDependencyInfo#getDependencies()}.
+     *
+     * <p>
+     * Resolution state of resolveSource is internally cached and is used in
+     * subsequent resolution of dependent modules and in creation of
+     * YANGSourceContext via {@link #createSourceContext()}.
+     *
+     * <p>
+     * Possible resolution state for sources are:
+     * <ul>
+     * <li>{@link ResolutionState#EVERYTHING_OK} - If sources for module and its
+     * dependencies are available</li>
+     * <li>{@link ResolutionState#MISSING_DEPENDENCY} - If dependency of source
+     * is missing (call to {@link #getDependencyInfo(SourceIdentifier)} for
+     * imported / included model returned returned {@link Optional#absent()}.</li>
+     * <li>{@link ResolutionState#MISSING_SOURCE} - If source is missing. (call
+     * of {@link #getDependencyInfo(SourceIdentifier)} returned
+     * {@link Optional#absent()}.</li>
+     * <li>{@link ResolutionState#OTHER_ERROR} - If other runtime error
+     * prevented resolution of informations.</li>
+     * </ul>
+     *
+     * Note: Multiple invocations of this method returns cached result, since
+     * {@link #getDependencyInfo(SourceIdentifier)} contract requires
+     * implementors to return same information during life of this object.
+     *
+     *
+     * @param identifier
+     *            Source Identifier
+     * @return Returns resolution state for source.
+     */
+    public final YangSourceContextResolver.ResolutionState resolveSource(final SourceIdentifier identifier) {
 
         if (alreadyProcessed.containsKey(identifier)) {
             return alreadyProcessed.get(identifier);
@@ -91,14 +254,15 @@ public abstract class YangSourceContextResolver {
 
     private boolean checkValidSource(final SourceIdentifier identifier, final YangModelDependencyInfo info) {
         if (!identifier.getName().equals(info.getName())) {
-            LOG.warn("Incorrect model returned. Identifier name was: {}, source contained: {}",
-                    identifier.getName(), info.getName());
+            LOG.warn("Incorrect model returned. Identifier name was: {}, source contained: {}", identifier.getName(),
+                    info.getName());
             throw new IllegalStateException("Incorrect source was returned");
         }
         return true;
     }
 
-    private void updateResolutionState(final SourceIdentifier identifier, final YangSourceContextResolver.ResolutionState potentialState) {
+    private void updateResolutionState(final SourceIdentifier identifier,
+            final YangSourceContextResolver.ResolutionState potentialState) {
         alreadyProcessed.put(identifier, potentialState);
         switch (potentialState) {
         case MISSING_SOURCE:
@@ -114,8 +278,7 @@ public abstract class YangSourceContextResolver {
 
     private YangSourceContextResolver.ResolutionState resolveDependency(final ModuleImport dependency) {
         String name = dependency.getModuleName();
-        Optional<String> formattedRevision = Optional
-                .fromNullable(QName.formattedRevision(dependency.getRevision()));
+        Optional<String> formattedRevision = Optional.fromNullable(QName.formattedRevision(dependency.getRevision()));
         return resolveSource(new SourceIdentifier(name, formattedRevision));
     }
 
index 92d3fbd11414142217d8030520de3d96b5e345b7..b9941d4e032a04bb4deab05ee28c74bdeb06caac 100644 (file)
@@ -16,10 +16,28 @@ import org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier;
 
 import com.google.common.base.Optional;
 
+/**
+ *
+ * Source code resolver which resolves Yang Source Context against
+ * {@link SchemaSourceProvider} and set of QName which represent capabilities.
+ *
+ * This source code resolver is useful for components which deals with
+ * capability exchange similar to YANG/Netconf specification
+ * and there is {@link SchemaSourceProvider} able to retrieve YANG models.
+ *
+ */
 public final class YangSourceFromCapabilitiesResolver extends YangSourceContextResolver {
 
     private final Iterable<QName> capabilities;
 
+    /**
+     * Construct new {@link YangSourceFromCapabilitiesResolver}.
+     *
+     * @param capabilities Set of QName representing module capabilities, {@link QName#getLocalName()} represents
+     * source name and {@link QName#getRevision()} represents revision of source.
+     *
+     * @param schemaSourceProvider - {@link SchemaSourceProvider} which should be used to resolve sources.
+     */
     public YangSourceFromCapabilitiesResolver(final Iterable<QName> capabilities,
             final SchemaSourceProvider<InputStream> schemaSourceProvider) {
         super(SchemaSourceProviders.toAdvancedSchemaSourceProvider(schemaSourceProvider));
@@ -40,16 +58,11 @@ public final class YangSourceFromCapabilitiesResolver extends YangSourceContextR
 
     @Override
     public Optional<YangModelDependencyInfo> getDependencyInfo(final SourceIdentifier identifier) {
-        Optional<InputStream> source = getSchemaSource(identifier);
+        Optional<InputStream> source = getSourceProvider().getSchemaSource(identifier);
         if (source.isPresent()) {
             return Optional.of(YangModelDependencyInfo.fromInputStream(source.get()));
         }
         return Optional.absent();
     }
 
-    private Optional<InputStream> getSchemaSource(final SourceIdentifier identifier) {
-        return getSourceProvider().getSchemaSource(identifier.getName(),
-                Optional.fromNullable(identifier.getRevision()));
-    }
-
 }
index 9893c6cfd1a9c8f7a22b7db9fe11adf83f07006e..bfe8bf908bb32a4420aca0d0cb48d3cf00c90795 100644 (file)
@@ -10,11 +10,20 @@ package org.opendaylight.yangtools.yang.parser.impl.util;
 import java.util.Map;
 import java.util.Map.Entry;
 
+import org.opendaylight.yangtools.yang.model.util.repo.SchemaSourceProvider;
 import org.opendaylight.yangtools.yang.model.util.repo.SourceIdentifier;
 
 import com.google.common.base.Optional;
 import com.google.common.collect.ImmutableMap;
 
+/**
+ * Resolver for YANG Schema Source which is based on DependencyInfo
+ *
+ * This resolver does not use {@link SchemaSourceProvider} but supplied map
+ * of source identifiers and {@link YangModelDependencyInfo} to construct
+ * {@link YangSourceContext}.
+ *
+ */
 public final class YangSourceFromDependencyInfoResolver extends YangSourceContextResolver {
 
     private final Map<SourceIdentifier, YangModelDependencyInfo> dependencyInfo;
index 65e3b1db3984b13736cf92400c8d577e620796f2..635e57e0679a836ab9d11c0770e6a83603ad8f19 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.yangtools.yang.parser.util;
 import java.util.Collections;
 import java.util.List;
 
+import org.opendaylight.yangtools.concepts.Immutable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.Status;
@@ -17,7 +18,7 @@ import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition;
 import org.opendaylight.yangtools.yang.model.api.type.BitsTypeDefinition.Bit;
 
-final class BitImpl implements BitsTypeDefinition.Bit {
+final class BitImpl implements BitsTypeDefinition.Bit, Immutable {
     private final Long position;
     private final QName qname;
     private final SchemaPath schemaPath;
index e546083c08c3b66d2f085dbbfc7a7e83eb6a3d51..d8727bd6ae6836e8783f306a87f3bc1b01916a32 100644 (file)
@@ -121,7 +121,7 @@ public final class RefineHolder extends AbstractBuilder {
         result = prime * result + ((minElements == null) ? 0 : minElements.hashCode());
         result = prime * result + ((must == null) ? 0 : must.hashCode());
         result = prime * result + ((name == null) ? 0 : name.hashCode());
-        result = prime * result + ((parentBuilder == null) ? 0 : parentBuilder.hashCode());
+        result = prime * result + ((getParent() == null) ? 0 : getParent().hashCode());
         result = prime * result + ((presence == null) ? 0 : presence.hashCode());
         result = prime * result + ((reference == null) ? 0 : reference.hashCode());
         return result;
@@ -202,11 +202,11 @@ public final class RefineHolder extends AbstractBuilder {
         } else if (!name.equals(other.name)) {
             return false;
         }
-        if (parentBuilder == null) {
-            if (other.parentBuilder != null) {
+        if (getParent() == null) {
+            if (other.getParent() != null) {
                 return false;
             }
-        } else if (!parentBuilder.equals(other.parentBuilder)) {
+        } else if (!getParent().equals(other.getParent())) {
             return false;
         }
         if (presence == null) {
index 056215fa52880f6b6377eee3d5b430f4bb015b60..4b194def8b523058ccb4038d665ab0dbdd5bc755 100644 (file)
@@ -26,4 +26,5 @@ public class YangParseException extends RuntimeException {
         super("Error in module '" + moduleName + "' at line " + line + ": " + errorMsg, exception);
     }
 
+
 }