Added support for resolving augmentations. 66/366/4
authorlsedlak <lsedlak@cisco.com>
Mon, 20 May 2013 16:35:22 +0000 (18:35 +0200)
committerlsedlak <lsedlak@cisco.com>
Tue, 21 May 2013 13:24:33 +0000 (15:24 +0200)
Added implementation into BindingGeneratorImpl to support generation of augmentati statements from yang models.
Added AugmentedTypeTest and augmented-test-models for testing of agumentation functionality.

Added ability to generate Java Interfaces that extends generic types.
Added Augmentation and Augmentable interfaces into yang-binding project.

Fixed bug in bad equals resolving in AbstractBaseType in binding-generator-util;
Added ReferencedTypeImpl into binding-generator-util;

Added findParentModule static method into SchemaContextUtil for resolving Module from SchemaNode in Schema Tree;
Added DATA_OBJECT, augmentableTypeFor and augmentationTypeFor into Types for referencing of Augmentable<T>, Augmentation<T> and DataObject interfaces defined in yang-binding;

Fixed incorrect resolving of namespaces and package names during generation of interfaces from yang lists;
Fixed bug in TypeProvider in resolving of extended types extended from multiple extended types;
Added ControllerTest and controller-models as test resources;
Changed position of revision date during package generation -> Now revision date comes after namespace;

Change-Id: I687925a622853bb6c9a809f17efd980c2960ae39
Signed-off-by: Lukas Sedlak <lsedlak@cisco.com>
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
52 files changed:
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/pom.xml
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/BindingGeneratorImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/yang/types/BaseYangTypes.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/yang/types/TypeProviderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AugmentedTypeTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/ControllerTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/GeneratedTypesTest.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/abstract-topology@2013-02-08.yang [moved from opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/src/main/yang/abstract-topology.yang with 74% similarity]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-abstract-topology@2013-05-03.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-network-link-attributes@2013-05-03.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-topology-tunnels@2013-05-03.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/iana-if-type@2012-06-05.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-inet-types@2010-09-24.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-interfaces@2012-11-15.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-yang-types@2010-09-24.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/controller-network.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/controller-openflow.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/ietf-inet-types@2010-09-24.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/ietf-yang-types@2010-09-24.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/pom.xml
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/AbstractBaseType.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/BindingGeneratorUtil.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/ReferencedTypeImpl.java [moved from opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/main/java/org/opendaylight/controller/sal/binding/generator/impl/ReferencedTypeImpl.java with 95% similarity]
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/Types.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/GeneratedTOBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-util/src/main/java/org/opendaylight/controller/binding/generator/util/generated/type/builder/GeneratedTypeBuilderImpl.java
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/pom.xml
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/controller/sal/java/api/generator/GeneratorJavaFile.java
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/main/java/org/opendaylight/controller/sal/java/api/generator/GeneratorUtil.java
opendaylight/sal/yang-prototype/code-generator/binding-java-api-generator/src/test/java/org/opendaylight/controller/sal/java/api/generator/test/GeneratorJavaFileTest.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/GeneratedType.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/GeneratedTypeBuilder.java
opendaylight/sal/yang-prototype/code-generator/code-generator-demo/pom.xml
opendaylight/sal/yang-prototype/code-generator/code-generator-demo/src/main/java/org/opendaylight/controller/yang/Demo.java
opendaylight/sal/yang-prototype/code-generator/maven-sal-api-gen-plugin/src/main/java/org/opendaylight/controller/maven/sal/api/gen/plugin/CodeGeneratorImpl.java
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin-it/.gitignore
opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/YangToSourcesMojo.java.bak [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/pom.xml
opendaylight/sal/yang-prototype/code-generator/pom.xml.bak [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/pom.xml
opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/src/main/java/Example.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/src/main/yang/controller-network.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/src/main/yang/controller-openflow.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/pom.xml
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/parser/impl/YangParserImpl.java
opendaylight/sal/yang-prototype/pom.xml
opendaylight/sal/yang-prototype/yang/pom.xml
opendaylight/sal/yang-prototype/yang/yang-binding/src/main/java/org/opendaylight/controller/yang/binding/Augmentable.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/yang/yang-binding/src/main/java/org/opendaylight/controller/yang/binding/Augmentation.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/yang/yang-common/pom.xml
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/DataNodeIterator.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/yang/model/util/SchemaContextUtil.java

index ff5aafec98b7768820e6ae07355db529d6166661..56a32b46cfde20c8701a2c7e500de6ea76bc2f23 100644 (file)
@@ -29,9 +29,8 @@
           <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
       <dependency>\r
-       <groupId>jaxen</groupId>\r
-       <artifactId>jaxen</artifactId>\r
-       <version>1.1.4</version>\r
+       <groupId>junit</groupId>\r
+       <artifactId>junit</artifactId>\r
       </dependency>\r
   </dependencies>\r
 </project>
\ No newline at end of file
index 3c0d9ed35a4d0b53e4634a30ea669e0c84661a70..a903ef15811daeb7197c4ef7a80ca612c30520e4 100644 (file)
@@ -7,18 +7,7 @@
  */
 package org.opendaylight.controller.sal.binding.generator.impl;
 
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil;
+import org.opendaylight.controller.binding.generator.util.ReferencedTypeImpl;
 import org.opendaylight.controller.binding.generator.util.Types;
 import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl;
 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
@@ -26,155 +15,146 @@ import org.opendaylight.controller.sal.binding.generator.spi.TypeProvider;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
 import org.opendaylight.controller.sal.binding.model.api.Type;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.EnumBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedPropertyBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTypeBuilder;
-import org.opendaylight.controller.sal.binding.model.api.type.builder.MethodSignatureBuilder;
+import org.opendaylight.controller.sal.binding.model.api.type.builder.*;
 import org.opendaylight.controller.sal.binding.yang.types.TypeProviderImpl;
 import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;
-import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
-import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
-import org.opendaylight.controller.yang.model.api.ListSchemaNode;
-import org.opendaylight.controller.yang.model.api.Module;
-import org.opendaylight.controller.yang.model.api.NotificationDefinition;
-import org.opendaylight.controller.yang.model.api.RpcDefinition;
-import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.api.SchemaPath;
-import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.*;
 import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.EnumTypeDefinition.EnumPair;
 import org.opendaylight.controller.yang.model.util.DataNodeIterator;
 import org.opendaylight.controller.yang.model.util.ExtendedType;
 
-public class BindingGeneratorImpl implements BindingGenerator {
+import java.util.*;
 
-    private static final String[] SET_VALUES = new String[] { "abstract",
-            "assert", "boolean", "break", "byte", "case", "catch", "char",
-            "class", "const", "continue", "default", "double", "do", "else",
-            "enum", "extends", "false", "final", "finally", "float", "for",
-            "goto", "if", "implements", "import", "instanceof", "int",
-            "interface", "long", "native", "new", "null", "package", "private",
-            "protected", "public", "return", "short", "static", "strictfp",
-            "super", "switch", "synchronized", "this", "throw", "throws",
-            "transient", "true", "try", "void", "volatile", "while" };
+import static org.opendaylight.controller.binding.generator.util.BindingGeneratorUtil.*;
+import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findDataSchemaNode;
+import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findParentModule;
 
-    public static final Set<String> JAVA_RESERVED_WORDS = new HashSet<String>(
-            Arrays.asList(SET_VALUES));
+public class BindingGeneratorImpl implements BindingGenerator {
 
-    private static Calendar calendar = new GregorianCalendar();
     private Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders;
     private TypeProvider typeProvider;
-    private String basePackageName;
+    private SchemaContext schemaContext;
 
     public BindingGeneratorImpl() {
         super();
     }
 
-    private static String validatePackage(final String packageName) {
-        if (packageName != null) {
-            final String[] packNameParts = packageName.split("\\.");
-            if (packNameParts != null) {
-                final StringBuilder builder = new StringBuilder();
-                for (int i = 0; i < packNameParts.length; ++i) {
-                    if (JAVA_RESERVED_WORDS.contains(packNameParts[i])) {
-                        packNameParts[i] = "_" + packNameParts[i];
-                    }
-                    if (i > 0) {
-                        builder.append(".");
-                    }
-                    builder.append(packNameParts[i]);
-                }
-                return builder.toString();
-            }
-        }
-        return packageName;
-    }
-
     @Override
     public List<Type> generateTypes(final SchemaContext context) {
-        final List<Type> genTypes = new ArrayList<Type>();
-
-        if (context != null) {
-            typeProvider = new TypeProviderImpl(context);
-            final Set<Module> modules = context.getModules();
-            
-            if (modules != null) {
-                for (final Module module : modules) {
-                    final DataNodeIterator moduleIterator = new DataNodeIterator(
-                            module);
-
-                    genTypeBuilders = new HashMap<String, Map<String, GeneratedTypeBuilder>>();
-                    final List<ContainerSchemaNode> schemaContainers = moduleIterator
-                            .allContainers();
-                    final List<ListSchemaNode> schemaLists = moduleIterator
-                            .allLists();
-
-                    basePackageName = BindingGeneratorUtil
-                            .moduleNamespaceToPackageName(
-                                    module.getNamespace(),
-                                    module.getYangVersion());
-
-                    if (schemaContainers.size() > 0) {
-                        for (final ContainerSchemaNode container : schemaContainers) {
-                            genTypes.add(containerToGenType(container));
-                        }
-                    }
-                    if (schemaLists.size() > 0) {
-                        for (final ListSchemaNode list : schemaLists) {
-                            genTypes.addAll(listToGenType(list));
-                        }
-                    }
+        if (context == null) {
+            throw new IllegalArgumentException("Schema Context reference cannot be NULL");
+        }
+        if (context.getModules() == null) {
+            throw new IllegalStateException("Schema Context does not contain defined modules!");
+        }
 
-                    final GeneratedType genDataType = moduleToDataType(module);
-                    final GeneratedType genRpcType = rpcMethodsToGenType(module);
-                    final GeneratedType genNotifyType = notifycationsToGenType(module);
+        final List<Type> genTypes = new ArrayList<>();
+        schemaContext = context;
+        typeProvider = new TypeProviderImpl(context);
+        final Set<Module> modules = context.getModules();
+        genTypeBuilders = new HashMap<>();
+        for (final Module module : modules) {
+            final DataNodeIterator moduleIterator = new DataNodeIterator(
+                    module);
+
+            final List<AugmentationSchema> sortedAugmentations = provideSortedAugmentations(module);
+            final List<ContainerSchemaNode> schemaContainers = moduleIterator
+                    .allContainers();
+            final List<ListSchemaNode> schemaLists = moduleIterator
+                    .allLists();
+
+            final String basePackageName = moduleNamespaceToPackageName(module);
+            if ((schemaContainers != null)
+                    && !schemaContainers.isEmpty()) {
+                for (final ContainerSchemaNode container : schemaContainers) {
+                    genTypes.add(containerToGenType(basePackageName,
+                            container));
+                }
+            }
+            if ((schemaLists != null) && !schemaLists.isEmpty()) {
+                for (final ListSchemaNode list : schemaLists) {
+                    genTypes.addAll(listToGenType(basePackageName, list));
+                }
+            }
 
-                    if (genDataType != null) {
-                        genTypes.add(genDataType);
-                    }
-                    if (genRpcType != null) {
-                        genTypes.add(genRpcType);
-                    }
-                    if (genNotifyType != null) {
-                        genTypes.add(genNotifyType);
-                    }
+            if ((sortedAugmentations != null)
+                    && !sortedAugmentations.isEmpty()) {
+                for (final AugmentationSchema augment : sortedAugmentations) {
+                    genTypes.addAll(augmentationToGenTypes(basePackageName, augment));
                 }
-                
-                //FIXME this is quick add of typedefs to generated types from type provider
-                genTypes.addAll(((TypeProviderImpl)typeProvider).getGeneratedTypeDefs());
+            }
+
+            final GeneratedType genDataType = moduleToDataType(basePackageName, module);
+            final List<GeneratedType> genRpcType = rpcMethodsToGenType(basePackageName, module);
+            final List<Type> genNotifyType = notifycationsToGenType(basePackageName, module);
+
+            if (genDataType != null) {
+                genTypes.add(genDataType);
+            }
+            if (genRpcType != null) {
+                genTypes.addAll(genRpcType);
+            }
+            if (genNotifyType != null) {
+                genTypes.addAll(genNotifyType);
             }
         }
+        genTypes.addAll(((TypeProviderImpl) typeProvider)
+                .getGeneratedTypeDefs());
+
         return genTypes;
     }
 
-    private GeneratedType moduleToDataType(final Module module) {
-        if (module != null) {
-            final Set<TypeDefinition<?>> typeDefinitions = module
-                    .getTypeDefinitions();
-            final GeneratedTypeBuilder moduleDataTypeBuilder = moduleTypeBuilder(
-                    module, "Data");
-
-            if (moduleDataTypeBuilder != null) {
-                if (typeDefinitions != null) {
-                    for (final TypeDefinition<?> typedef : typeDefinitions) {
-                        if (isDerivedFromEnumerationType(typedef)) {
-                            final EnumTypeDefinition enumBaseType = enumTypeDefFromExtendedType(typedef);
-                            resolveEnumFromTypeDefinition(enumBaseType, typedef
-                                    .getQName().getLocalName(),
-                                    moduleDataTypeBuilder);
+    private List<AugmentationSchema> provideSortedAugmentations(final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+        if (module.getAugmentations() == null) {
+            throw new IllegalStateException("Augmentations Set cannot be NULL!");
+        }
+
+        final Set<AugmentationSchema> augmentations = module
+                .getAugmentations();
+        final List<AugmentationSchema> sortedAugmentations = new ArrayList<>(
+                augmentations);
+        Collections.sort(sortedAugmentations,
+                new Comparator<AugmentationSchema>() {
+
+                    @Override
+                    public int compare(
+                            AugmentationSchema augSchema1,
+                            AugmentationSchema augSchema2) {
+
+                        if (augSchema1.getTargetPath().getPath()
+                                .size() > augSchema2
+                                .getTargetPath().getPath().size()) {
+                            return 1;
+                        } else if (augSchema1.getTargetPath()
+                                .getPath().size() < augSchema2
+                                .getTargetPath().getPath().size()) {
+                            return -1;
                         }
+                        return 0;
+
                     }
-                }
+                });
 
-                final Set<DataSchemaNode> dataNodes = module.getChildNodes();
-                resolveTypesFromDataSchemaNode(moduleDataTypeBuilder, dataNodes);
-                return moduleDataTypeBuilder.toInstance();
-            }
+        return sortedAugmentations;
+    }
+
+    private GeneratedType moduleToDataType(final String basePackageName, final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
         }
-        return null;
+
+        final GeneratedTypeBuilder moduleDataTypeBuilder = moduleTypeBuilder(
+                module, "Data");
+
+        if (moduleDataTypeBuilder != null) {
+            final Set<DataSchemaNode> dataNodes = module.getChildNodes();
+            resolveDataSchemaNodes(basePackageName, moduleDataTypeBuilder, dataNodes);
+        }
+        return moduleDataTypeBuilder.toInstance();
     }
 
     private boolean isDerivedFromEnumerationType(
@@ -209,8 +189,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 && (enumTypeDef.getQName() != null)
                 && (enumTypeDef.getQName().getLocalName() != null)) {
 
-            final String enumerationName = BindingGeneratorUtil
-                    .parseToClassName(enumName);
+            final String enumerationName = parseToClassName(enumName);
             final EnumBuilder enumBuilder = typeBuilder
                     .addEnumeration(enumerationName);
 
@@ -220,8 +199,8 @@ public class BindingGeneratorImpl implements BindingGenerator {
                     int listIndex = 0;
                     for (final EnumPair enumPair : enums) {
                         if (enumPair != null) {
-                            final String enumPairName = BindingGeneratorUtil
-                                    .parseToClassName(enumPair.getName());
+                            final String enumPairName = parseToClassName(enumPair
+                                    .getName());
                             Integer enumPairValue = enumPair.getValue();
 
                             if (enumPairValue == null) {
@@ -239,101 +218,282 @@ public class BindingGeneratorImpl implements BindingGenerator {
     }
 
     private GeneratedTypeBuilder moduleTypeBuilder(final Module module,
-            final String postfix) {
-        if (module != null) {
-            String packageName = resolveBasePackageName(module.getNamespace(),
-                    module.getYangVersion());
-            final String moduleName = BindingGeneratorUtil
-                    .parseToClassName(module.getName()) + postfix;
+                                                   final String postfix) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+        String packageName = moduleNamespaceToPackageName(module);
+        final String moduleName = parseToClassName(module.getName())
+                + postfix;
+
+        return new GeneratedTypeBuilderImpl(packageName, moduleName);
+
+    }
+
+    private List<GeneratedType> rpcMethodsToGenType(final String basePackageName, final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
 
-            if (packageName != null) {
-                packageName = validatePackage(packageName);
-                return new GeneratedTypeBuilderImpl(packageName, moduleName);
+        final Set<RpcDefinition> rpcDefinitions = module.getRpcs();
+        final List<GeneratedType> rpcTypes = new ArrayList<>();
+
+        if ((rpcDefinitions != null) && !rpcDefinitions.isEmpty()) {
+            for (final RpcDefinition rpc : rpcDefinitions) {
+                if (rpc != null) {
+                    final List<DataNodeIterator> rpcInOut = new ArrayList<>();
+                    rpcInOut.add(new DataNodeIterator(rpc.getInput()));
+                    rpcInOut.add(new DataNodeIterator(rpc.getOutput()));
+
+                    for (DataNodeIterator it : rpcInOut) {
+                        List<ContainerSchemaNode> nContainers = it.allContainers();
+                        if ((nContainers != null) && !nContainers.isEmpty()) {
+                            for (final ContainerSchemaNode container : nContainers) {
+                                rpcTypes.add(containerToGenType(basePackageName, container));
+                            }
+                        }
+                    }
+                }
             }
         }
-        return null;
+        return rpcTypes;
     }
 
-    private GeneratedType rpcMethodsToGenType(final Module module) {
-        if (module != null) {
-            final Set<RpcDefinition> rpcDefinitions = module.getRpcs();
-            //TODO: add implementation
-            if ((rpcDefinitions != null) && !rpcDefinitions.isEmpty()) {
-                final GeneratedTypeBuilder rpcTypeBuilder = moduleTypeBuilder(
-                        module, "Rpc");
+    private List<Type> notifycationsToGenType(final String basePackageName, final Module module) {
+        if (module == null) {
+            throw new IllegalArgumentException("Module reference cannot be NULL!");
+        }
+        final List<Type> notificationTypes = new ArrayList<>();
+        final Set<NotificationDefinition> notifications = module
+                .getNotifications();
+
+        if ((notifications != null) && !notifications.isEmpty()) {
+            for (final NotificationDefinition notification : notifications) {
+                if (notification != null) {
+                    final List<DataNodeIterator> notifyChildren = new ArrayList<>();
+
+                    for (DataSchemaNode childNode : notification.getChildNodes()) {
+                        if (childNode instanceof DataNodeContainer) {
+                            notifyChildren.add(new DataNodeIterator((DataNodeContainer) childNode));
+                        }
+                    }
 
-                for (final RpcDefinition rpc : rpcDefinitions) {
-                    if (rpc != null) {
+                    for (DataNodeIterator it : notifyChildren) {
+                        List<ContainerSchemaNode> nContainers = it.allContainers();
+                        List<ListSchemaNode> nLists = it.allLists();
+                        if ((nContainers != null) && !nContainers.isEmpty()) {
+                            for (final ContainerSchemaNode container : nContainers) {
+                                notificationTypes.add(containerToGenType(basePackageName, container));
+                            }
+                        }
+                        if ((nLists != null) && !nLists.isEmpty()) {
+                            for (final ListSchemaNode list : nLists) {
 
+                                notificationTypes.addAll(listToGenType(basePackageName, list));
+                            }
+                        }
                     }
                 }
             }
         }
-        return null;
+        return notificationTypes;
+    }
+
+    private List<Type> augmentationToGenTypes(final String augmentPackageName,
+                                              final AugmentationSchema augSchema) {
+        if (augmentPackageName == null) {
+            throw new IllegalArgumentException("Package Name cannot be NULL!");
+        }
+        if (augSchema == null) {
+            throw new IllegalArgumentException(
+                    "Augmentation Schema cannot be NULL!");
+        }
+        if (augSchema.getTargetPath() == null) {
+            throw new IllegalStateException(
+                    "Augmentation Schema does not contain Target Path (Target Path is NULL).");
+        }
+
+        final List<Type> genTypes = new ArrayList<>();
+
+        // EVERY augmented interface will extends Augmentation<T> interface
+        // and DataObject interface!!!
+        final SchemaPath targetPath = augSchema.getTargetPath();
+        final DataSchemaNode targetSchemaNode = findDataSchemaNode(schemaContext,
+                targetPath);
+        if ((targetSchemaNode != null) &&
+                (targetSchemaNode.getQName() != null) &&
+                (targetSchemaNode.getQName().getLocalName() != null)) {
+            final Module targetModule = findParentModule(schemaContext,
+                    targetSchemaNode);
+
+            final String targetBasePackage = moduleNamespaceToPackageName(targetModule);
+            final String targetPackageName = packageNameForGeneratedType(targetBasePackage,
+                    targetSchemaNode.getPath());
+
+            final String targetSchemaNodeName = targetSchemaNode.getQName().getLocalName();
+            final Set<DataSchemaNode> augChildNodes = augSchema
+                    .getChildNodes();
+            final GeneratedTypeBuilder augTypeBuilder = addRawAugmentGenTypeDefinition(
+                    augmentPackageName, targetPackageName, targetSchemaNodeName, augSchema);
+            if (augTypeBuilder != null) {
+                genTypes.add(augTypeBuilder.toInstance());
+            }
+            genTypes.addAll(augmentationBodyToGenTypes(augmentPackageName,
+                    augChildNodes));
+
+        }
+        return genTypes;
     }
 
-    private GeneratedType notifycationsToGenType(final Module module) {
-        if (module != null) {
-            final Set<NotificationDefinition> notifications = module
-                    .getNotifications();
-            //TODO: add implementation
-            if ((notifications != null) && !notifications.isEmpty()) {
-                final GeneratedTypeBuilder notifyTypeBuilder = moduleTypeBuilder(
-                        module, "Notification");
+    private GeneratedTypeBuilder addRawAugmentGenTypeDefinition(
+            final String augmentPackageName, final String targetPackageName,
+            final String targetSchemaNodeName,
+            final AugmentationSchema augSchema) {
+        final String targetTypeName = parseToClassName(targetSchemaNodeName);
+        Map<String, GeneratedTypeBuilder> augmentBuilders = genTypeBuilders
+                .get(augmentPackageName);
+        if (augmentBuilders == null) {
+            augmentBuilders = new HashMap<>();
+            genTypeBuilders.put(augmentPackageName, augmentBuilders);
+        }
+
+        final String augTypeName = augGenTypeName(augmentBuilders, targetTypeName);
+        final Type targetTypeRef = new ReferencedTypeImpl(targetPackageName, targetTypeName);
+        final Set<DataSchemaNode> augChildNodes = augSchema
+                .getChildNodes();
 
-                for (final NotificationDefinition notification : notifications) {
-                    if (notification != null) {
+        final GeneratedTypeBuilder augTypeBuilder = new GeneratedTypeBuilderImpl(
+                augmentPackageName, augTypeName);
 
-                    }
+        augTypeBuilder.addImplementsType(Types.DATA_OBJECT);
+        augTypeBuilder.addImplementsType(Types
+                .augmentationTypeFor(targetTypeRef));
+
+        augSchemaNodeToMethods(augmentPackageName, augTypeBuilder, augChildNodes);
+        augmentBuilders.put(augTypeName, augTypeBuilder);
+        return augTypeBuilder;
+    }
+
+    private List<Type> augmentationBodyToGenTypes(final String augBasePackageName,
+                                                  final Set<DataSchemaNode> augChildNodes) {
+        final List<Type> genTypes = new ArrayList<>();
+        final List<DataNodeIterator> augSchemaIts = new ArrayList<>();
+        for (final DataSchemaNode childNode : augChildNodes) {
+            if (childNode instanceof DataNodeContainer) {
+                augSchemaIts.add(new DataNodeIterator(
+                        (DataNodeContainer) childNode));
+
+                if (childNode instanceof ContainerSchemaNode) {
+                    genTypes.add(containerToGenType(augBasePackageName,
+                            (ContainerSchemaNode) childNode));
+                } else if (childNode instanceof ListSchemaNode) {
+                    genTypes.addAll(listToGenType(augBasePackageName,
+                            (ListSchemaNode) childNode));
                 }
             }
         }
-        return null;
+
+        for (final DataNodeIterator it : augSchemaIts) {
+            final List<ContainerSchemaNode> augContainers = it.allContainers();
+            final List<ListSchemaNode> augLists = it.allLists();
+
+            if ((augContainers != null) && !augContainers.isEmpty()) {
+                for (final ContainerSchemaNode container : augContainers) {
+                    genTypes.add(containerToGenType(augBasePackageName, container));
+                }
+            }
+            if ((augLists != null) && !augLists.isEmpty()) {
+                for (final ListSchemaNode list : augLists) {
+//                    final String listPackageName = packageNameForAugmentedType(
+//                            augBasePackageName, list.getPath());
+                    genTypes.addAll(listToGenType(augBasePackageName, list));
+                }
+            }
+        }
+        return genTypes;
+    }
+
+    private String augGenTypeName(
+            final Map<String, GeneratedTypeBuilder> builders,
+            final String genTypeName) {
+        String augTypeName = genTypeName;
+
+        int index = 1;
+        while ((builders != null) && builders.containsKey(genTypeName + index)) {
+            index++;
+        }
+        augTypeName += index;
+        return augTypeName;
     }
-    
-    private List<GeneratedType> augmentationToGenTypes(final Module module) {
-        final List<GeneratedType> augmentGenTypes = new ArrayList<GeneratedType>();
-        
-        //TODO: add implementation
-        
-        return augmentGenTypes;
-    }
-    
-    private GeneratedType containerToGenType(ContainerSchemaNode container) {
-        if (container == null) {
+
+    private GeneratedType containerToGenType(final String basePackageName,
+                                             ContainerSchemaNode containerNode) {
+        if (containerNode == null) {
             return null;
         }
-        final Set<DataSchemaNode> schemaNodes = container.getChildNodes();
-        final GeneratedTypeBuilder typeBuilder = addRawInterfaceDefinition(container);
 
-        resolveTypesFromDataSchemaNode(typeBuilder, schemaNodes);
+        final String packageName = packageNameForGeneratedType(
+                basePackageName, containerNode.getPath());
+        final Set<DataSchemaNode> schemaNodes = containerNode.getChildNodes();
+        final GeneratedTypeBuilder typeBuilder = addRawInterfaceDefinition(
+                packageName, containerNode);
+
+        resolveDataSchemaNodes(basePackageName, typeBuilder, schemaNodes);
         return typeBuilder.toInstance();
     }
 
-    private GeneratedTypeBuilder resolveTypesFromDataSchemaNode(
+    private GeneratedTypeBuilder resolveDataSchemaNodes(
+            final String basePackageName,
+            final GeneratedTypeBuilder typeBuilder,
+            final Set<DataSchemaNode> schemaNodes) {
+
+        if ((schemaNodes != null) && (typeBuilder != null)) {
+            for (final DataSchemaNode schemaNode : schemaNodes) {
+                if (schemaNode.isAugmenting()) {
+                    continue;
+                }
+                addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);
+            }
+        }
+        return typeBuilder;
+    }
+
+    private GeneratedTypeBuilder augSchemaNodeToMethods(
+            final String basePackageName,
             final GeneratedTypeBuilder typeBuilder,
             final Set<DataSchemaNode> schemaNodes) {
 
         if ((schemaNodes != null) && (typeBuilder != null)) {
-            for (final DataSchemaNode node : schemaNodes) {
-                if (node instanceof LeafSchemaNode) {
-                    resolveLeafSchemaNodeAsMethod(typeBuilder,
-                            (LeafSchemaNode) node);
-                } else if (node instanceof LeafListSchemaNode) {
-                    resolveLeafListSchemaNode(typeBuilder,
-                            (LeafListSchemaNode) node);
-
-                } else if (node instanceof ContainerSchemaNode) {
-                    resolveContainerSchemaNode(typeBuilder,
-                            (ContainerSchemaNode) node);
-                } else if (node instanceof ListSchemaNode) {
-                    resolveListSchemaNode(typeBuilder, (ListSchemaNode) node);
+            for (final DataSchemaNode schemaNode : schemaNodes) {
+                if (schemaNode.isAugmenting()) {
+                    addSchemaNodeToBuilderAsMethod(basePackageName, schemaNode, typeBuilder);
                 }
             }
         }
         return typeBuilder;
     }
 
+    private void addSchemaNodeToBuilderAsMethod(
+            final String basePackageName,
+            final DataSchemaNode schemaNode,
+            final GeneratedTypeBuilder typeBuilder) {
+        if (schemaNode != null && typeBuilder != null) {
+            if (schemaNode instanceof LeafSchemaNode) {
+                resolveLeafSchemaNodeAsMethod(typeBuilder,
+                        (LeafSchemaNode) schemaNode);
+            } else if (schemaNode instanceof LeafListSchemaNode) {
+                resolveLeafListSchemaNode(typeBuilder,
+                        (LeafListSchemaNode) schemaNode);
+            } else if (schemaNode instanceof ContainerSchemaNode) {
+                resolveContainerSchemaNode(basePackageName, typeBuilder,
+                        (ContainerSchemaNode) schemaNode);
+            } else if (schemaNode instanceof ListSchemaNode) {
+                resolveListSchemaNode(basePackageName, typeBuilder,
+                        (ListSchemaNode) schemaNode);
+            }
+        }
+    }
+
     private boolean resolveLeafSchemaNodeAsMethod(
             final GeneratedTypeBuilder typeBuilder, final LeafSchemaNode leaf) {
         if ((leaf != null) && (typeBuilder != null)) {
@@ -346,10 +506,10 @@ public class BindingGeneratorImpl implements BindingGenerator {
             if (leafName != null) {
                 final TypeDefinition<?> typeDef = leaf.getType();
 
-                Type type = null;
+                Type returnType = null;
                 if (!(typeDef instanceof EnumTypeDefinition)
                         && !isDerivedFromEnumerationType(typeDef)) {
-                    type = typeProvider
+                    returnType = typeProvider
                             .javaTypeForSchemaDefinitionType(typeDef);
                 } else {
                     if (isImported(leaf.getPath(), typeDef.getPath())) {
@@ -361,25 +521,27 @@ public class BindingGeneratorImpl implements BindingGenerator {
                                 enumTypeDef, leafName, typeBuilder);
 
                         if (enumBuilder != null) {
-                            type = new ReferencedTypeImpl(
+                            returnType = new ReferencedTypeImpl(
                                     enumBuilder.getPackageName(),
                                     enumBuilder.getName());
                         }
                     }
                 }
 
-                constructGetter(typeBuilder, leafName, leafDesc, type);
-                if (!leaf.isConfiguration()) {
-                    constructSetter(typeBuilder, leafName, leafDesc, type);
+                if (returnType != null) {
+                    constructGetter(typeBuilder, leafName, leafDesc, returnType);
+                    if (!leaf.isConfiguration()) {
+                        constructSetter(typeBuilder, leafName, leafDesc, returnType);
+                    }
+                    return true;
                 }
-                return true;
             }
         }
         return false;
     }
 
     private boolean isImported(final SchemaPath leafPath,
-            final SchemaPath typeDefPath) {
+                               final SchemaPath typeDefPath) {
         if ((leafPath != null) && (leafPath.getPath() != null)
                 && (typeDefPath != null) && (typeDefPath.getPath() != null)) {
 
@@ -412,22 +574,23 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 final TypeDefinition<?> typeDef = leaf.getType();
 
                 // TODO: properly resolve enum types
-                final Type javaType = typeProvider
+                final Type returnType = typeProvider
                         .javaTypeForSchemaDefinitionType(typeDef);
 
-                final GeneratedPropertyBuilder propBuilder = toBuilder
-                        .addProperty(BindingGeneratorUtil
-                                .parseToClassName(leafName));
+                if (returnType != null) {
+                    final GeneratedPropertyBuilder propBuilder = toBuilder
+                            .addProperty(parseToClassName(leafName));
 
-                propBuilder.setReadOnly(isReadOnly);
-                propBuilder.addReturnType(javaType);
-                propBuilder.addComment(leafDesc);
+                    propBuilder.setReadOnly(isReadOnly);
+                    propBuilder.addReturnType(returnType);
+                    propBuilder.addComment(leafDesc);
 
-                toBuilder.addEqualsIdentity(propBuilder);
-                toBuilder.addHashIdentity(propBuilder);
-                toBuilder.addToStringProperty(propBuilder);
+                    toBuilder.addEqualsIdentity(propBuilder);
+                    toBuilder.addHashIdentity(propBuilder);
+                    toBuilder.addToStringProperty(propBuilder);
 
-                return true;
+                    return true;
+                }
             }
         }
         return false;
@@ -458,14 +621,18 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return false;
     }
 
-    private boolean resolveContainerSchemaNode(
-            final GeneratedTypeBuilder typeBuilder,
-            final ContainerSchemaNode node) {
-        if ((node != null) && (typeBuilder != null)) {
-            final String nodeName = node.getQName().getLocalName();
+    private boolean resolveContainerSchemaNode(final String basePackageName,
+                                               final GeneratedTypeBuilder typeBuilder,
+                                               final ContainerSchemaNode containerNode) {
+        if ((containerNode != null) && (typeBuilder != null)) {
+            final String nodeName = containerNode.getQName().getLocalName();
 
             if (nodeName != null) {
-                final GeneratedTypeBuilder rawGenType = addRawInterfaceDefinition(node);
+                final String packageName = packageNameForGeneratedType(
+                        basePackageName, containerNode.getPath());
+
+                final GeneratedTypeBuilder rawGenType = addRawInterfaceDefinition(
+                        packageName, containerNode);
                 constructGetter(typeBuilder, nodeName, "", rawGenType);
 
                 return true;
@@ -474,17 +641,21 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return false;
     }
 
-    private boolean resolveListSchemaNode(
-            final GeneratedTypeBuilder typeBuilder, final ListSchemaNode node) {
-        if ((node != null) && (typeBuilder != null)) {
-            final String nodeName = node.getQName().getLocalName();
-
-            if (nodeName != null) {
-                final GeneratedTypeBuilder rawGenType = addRawInterfaceDefinition(node);
-                constructGetter(typeBuilder, nodeName, "",
+    private boolean resolveListSchemaNode(final String basePackageName,
+                                          final GeneratedTypeBuilder typeBuilder,
+                                          final ListSchemaNode schemaNode) {
+        if ((schemaNode != null) && (typeBuilder != null)) {
+            final String listName = schemaNode.getQName().getLocalName();
+
+            if (listName != null) {
+                final String packageName = packageNameForGeneratedType(
+                        basePackageName, schemaNode.getPath());
+                final GeneratedTypeBuilder rawGenType = addRawInterfaceDefinition(
+                        packageName, schemaNode);
+                constructGetter(typeBuilder, listName, "",
                         Types.listTypeFor(rawGenType));
-                if (!node.isConfiguration()) {
-                    constructSetter(typeBuilder, nodeName, "",
+                if (!schemaNode.isConfiguration()) {
+                    constructSetter(typeBuilder, listName, "",
                             Types.listTypeFor(rawGenType));
                 }
                 return true;
@@ -494,25 +665,23 @@ public class BindingGeneratorImpl implements BindingGenerator {
     }
 
     private GeneratedTypeBuilder addRawInterfaceDefinition(
-            final DataSchemaNode schemaNode) {
+            final String packageName, final DataSchemaNode schemaNode) {
         if (schemaNode == null) {
             return null;
         }
 
-        final String packageName = BindingGeneratorUtil
-                .packageNameForGeneratedType(basePackageName,
-                        schemaNode.getPath());
         final String schemaNodeName = schemaNode.getQName().getLocalName();
 
-        if ((packageName != null) && (schemaNode != null)
-                && (schemaNodeName != null)) {
-            final String genTypeName = BindingGeneratorUtil
-                    .parseToClassName(schemaNodeName);
+        if ((packageName != null) && (schemaNodeName != null)) {
+            final String genTypeName = parseToClassName(schemaNodeName);
             final GeneratedTypeBuilder newType = new GeneratedTypeBuilderImpl(
                     packageName, genTypeName);
 
+            newType.addImplementsType(Types.DATA_OBJECT);
+            newType.addImplementsType(Types.augmentableTypeFor(newType));
+
             if (!genTypeBuilders.containsKey(packageName)) {
-                final Map<String, GeneratedTypeBuilder> builders = new HashMap<String, GeneratedTypeBuilder>();
+                final Map<String, GeneratedTypeBuilder> builders = new HashMap<>();
                 builders.put(genTypeName, newType);
                 genTypeBuilders.put(packageName, builders);
             } else {
@@ -530,14 +699,14 @@ public class BindingGeneratorImpl implements BindingGenerator {
     private String getterMethodName(final String methodName) {
         final StringBuilder method = new StringBuilder();
         method.append("get");
-        method.append(BindingGeneratorUtil.parseToClassName(methodName));
+        method.append(parseToClassName(methodName));
         return method.toString();
     }
 
     private String setterMethodName(final String methodName) {
         final StringBuilder method = new StringBuilder();
         method.append("set");
-        method.append(BindingGeneratorUtil.parseToClassName(methodName));
+        method.append(parseToClassName(methodName));
         return method.toString();
     }
 
@@ -563,66 +732,104 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
         setMethod.addComment(comment);
         setMethod.addParameter(parameterType,
-                BindingGeneratorUtil.parseToValidParamName(schemaNodeName));
+                parseToValidParamName(schemaNodeName));
         setMethod.addReturnType(Types.voidType());
 
         return setMethod;
     }
 
-    private String resolveBasePackageName(final URI moduleNamespace,
-            final String yangVersion) {
-        final StringBuilder packageNameBuilder = new StringBuilder();
 
-        packageNameBuilder.append("org.opendaylight.yang.gen.v");
-        packageNameBuilder.append(yangVersion);
-        packageNameBuilder.append(".rev");
-        packageNameBuilder.append(calendar.get(Calendar.YEAR));
-        packageNameBuilder.append((calendar.get(Calendar.MONTH) + 1));
-        packageNameBuilder.append(calendar.get(Calendar.DAY_OF_MONTH));
-        packageNameBuilder.append(".");
+    private List<Type> listToGenType(final String basePackageName,
+                                     final ListSchemaNode list) {
+        if (basePackageName == null) {
+            throw new IllegalArgumentException(
+                    "Package Name for Generated Type cannot be NULL!");
+        }
+        if (list == null) {
+            throw new IllegalArgumentException(
+                    "List Schema Node cannot be NULL!");
+        }
+
+        final String packageName = packageNameForGeneratedType(
+                basePackageName, list.getPath());
+        final GeneratedTypeBuilder typeBuilder = resolveListTypeBuilder(
+                packageName, list);
+        final List<String> listKeys = listKeys(list);
+        GeneratedTOBuilder genTOBuilder = resolveListKeyTOBuilder(packageName,
+                list, listKeys);
 
-        String namespace = moduleNamespace.toString();
-        namespace = namespace.replace(":", ".");
-        namespace = namespace.replace("-", ".");
+        final Set<DataSchemaNode> schemaNodes = list.getChildNodes();
 
-        packageNameBuilder.append(namespace);
+        for (final DataSchemaNode schemaNode : schemaNodes) {
+            if (schemaNode.isAugmenting()) {
+                continue;
+            }
+            addSchemaNodeToListBuilders(basePackageName, schemaNode, typeBuilder,
+                    genTOBuilder, listKeys);
+        }
 
-        return packageNameBuilder.toString();
+//        if (list.isAugmenting()) {
+//            for (final DataSchemaNode schemaNode : schemaNodes) {
+//                if (schemaNode.isAugmenting()) {
+//                    addSchemaNodeToListBuilders(basePackageName, schemaNode, typeBuilder,
+//                            genTOBuilder, listKeys);
+//                }
+//            }
+//        } else {
+//            for (final DataSchemaNode schemaNode : schemaNodes) {
+//                if (schemaNode.isAugmenting()) {
+//                    continue;
+//                }
+//                addSchemaNodeToListBuilders(basePackageName, schemaNode, typeBuilder,
+//                        genTOBuilder, listKeys);
+//            }
+//        }
+        return typeBuildersToGenTypes(typeBuilder, genTOBuilder);
     }
 
-    private List<Type> listToGenType(final ListSchemaNode list) {
-        if (list == null) {
-            return null;
-        }
-        final GeneratedTypeBuilder typeBuilder = resolveListTypeBuilder(list);
-        final List<String> listKeys = listKeys(list);
-        GeneratedTOBuilder genTOBuilder = null;
-        if (listKeys.size() > 0) {
-            genTOBuilder = resolveListKey(list);
+    private void addSchemaNodeToListBuilders(final String basePackageName,
+                                             final DataSchemaNode schemaNode,
+                                             final GeneratedTypeBuilder typeBuilder,
+                                             final GeneratedTOBuilder genTOBuilder,
+                                             final List<String> listKeys) {
+        if (schemaNode == null) {
+            throw new IllegalArgumentException(
+                    "Data Schema Node cannot be NULL!");
         }
 
-        final Set<DataSchemaNode> schemaNodes = list.getChildNodes();
-        for (final DataSchemaNode node : schemaNodes) {
+        if (typeBuilder == null) {
+            throw new IllegalArgumentException(
+                    "Generated Type Builder cannot be NULL!");
+        }
 
-            if (node instanceof LeafSchemaNode) {
-                final LeafSchemaNode leaf = (LeafSchemaNode) node;
-                if (!isPartOfListKey(leaf, listKeys)) {
-                    resolveLeafSchemaNodeAsMethod(typeBuilder, leaf);
-                } else {
-                    resolveLeafSchemaNodeAsProperty(genTOBuilder, leaf, true);
-                }
-            } else if (node instanceof LeafListSchemaNode) {
-                resolveLeafListSchemaNode(typeBuilder,
-                        (LeafListSchemaNode) node);
-            } else if (node instanceof ContainerSchemaNode) {
-                resolveContainerSchemaNode(typeBuilder,
-                        (ContainerSchemaNode) node);
-            } else if (node instanceof ListSchemaNode) {
-                resolveListSchemaNode(typeBuilder, (ListSchemaNode) node);
+        if (schemaNode instanceof LeafSchemaNode) {
+            final LeafSchemaNode leaf = (LeafSchemaNode) schemaNode;
+            if (!isPartOfListKey(leaf, listKeys)) {
+                resolveLeafSchemaNodeAsMethod(typeBuilder, leaf);
+            } else {
+                resolveLeafSchemaNodeAsProperty(genTOBuilder, leaf, true);
             }
+        } else if (schemaNode instanceof LeafListSchemaNode) {
+            resolveLeafListSchemaNode(typeBuilder,
+                    (LeafListSchemaNode) schemaNode);
+        } else if (schemaNode instanceof ContainerSchemaNode) {
+            resolveContainerSchemaNode(basePackageName, typeBuilder,
+                    (ContainerSchemaNode) schemaNode);
+        } else if (schemaNode instanceof ListSchemaNode) {
+            resolveListSchemaNode(basePackageName, typeBuilder, (ListSchemaNode) schemaNode);
+        }
+
+    }
+
+    private List<Type> typeBuildersToGenTypes(
+            final GeneratedTypeBuilder typeBuilder,
+            GeneratedTOBuilder genTOBuilder) {
+        final List<Type> genTypes = new ArrayList<>();
+        if (typeBuilder == null) {
+            throw new IllegalArgumentException(
+                    "Generated Type Builder cannot be NULL!");
         }
 
-        final List<Type> genTypes = new ArrayList<Type>();
         if (genTOBuilder != null) {
             final GeneratedTransferObject genTO = genTOBuilder.toInstance();
             constructGetter(typeBuilder, genTO.getName(),
@@ -637,17 +844,14 @@ public class BindingGeneratorImpl implements BindingGenerator {
      * @param list
      * @return
      */
-    private GeneratedTOBuilder resolveListKey(final ListSchemaNode list) {
-        final String packageName = BindingGeneratorUtil
-                .packageNameForGeneratedType(basePackageName, list.getPath());
+    private GeneratedTOBuilder resolveListKey(final String packageName,
+                                              final ListSchemaNode list) {
         final String listName = list.getQName().getLocalName() + "Key";
-
-        return BindingGeneratorUtil.schemaNodeToTransferObjectBuilder(
-                packageName, list, listName);
+        return schemaNodeToTransferObjectBuilder(packageName, list, listName);
     }
 
     private boolean isPartOfListKey(final LeafSchemaNode leaf,
-            final List<String> keys) {
+                                    final List<String> keys) {
         if ((leaf != null) && (keys != null) && (leaf.getQName() != null)) {
             final String leafName = leaf.getQName().getLocalName();
             if (keys.contains(leafName)) {
@@ -658,7 +862,7 @@ public class BindingGeneratorImpl implements BindingGenerator {
     }
 
     private List<String> listKeys(final ListSchemaNode list) {
-        final List<String> listKeys = new ArrayList<String>();
+        final List<String> listKeys = new ArrayList<>();
 
         if (list.getKeyDefinition() != null) {
             final List<QName> keyDefinitions = list.getKeyDefinition();
@@ -671,23 +875,38 @@ public class BindingGeneratorImpl implements BindingGenerator {
     }
 
     private GeneratedTypeBuilder resolveListTypeBuilder(
-            final ListSchemaNode list) {
-        final String packageName = BindingGeneratorUtil
-                .packageNameForGeneratedType(basePackageName,
-                        list.getPath());
+            final String packageName, final ListSchemaNode list) {
+        if (packageName == null) {
+            throw new IllegalArgumentException(
+                    "Package Name for Generated Type cannot be NULL!");
+        }
+        if (list == null) {
+            throw new IllegalArgumentException(
+                    "List Schema Node cannot be NULL!");
+        }
+
         final String schemaNodeName = list.getQName().getLocalName();
-        final String genTypeName = BindingGeneratorUtil
-                .parseToClassName(schemaNodeName);
+        final String genTypeName = parseToClassName(schemaNodeName);
 
         GeneratedTypeBuilder typeBuilder = null;
-        if (genTypeBuilders.containsKey(packageName)) {
-            final Map<String, GeneratedTypeBuilder> builders = new HashMap<String, GeneratedTypeBuilder>();
+        final Map<String, GeneratedTypeBuilder> builders = genTypeBuilders.get(packageName);
+        if (builders != null) {
             typeBuilder = builders.get(genTypeName);
-
-            if (null == typeBuilder) {
-                typeBuilder = addRawInterfaceDefinition(list);
-            }
+        }
+        if (typeBuilder == null) {
+            typeBuilder = addRawInterfaceDefinition(packageName, list);
         }
         return typeBuilder;
     }
+
+    private GeneratedTOBuilder resolveListKeyTOBuilder(
+            final String packageName, final ListSchemaNode list,
+            final List<String> listKeys) {
+        GeneratedTOBuilder genTOBuilder = null;
+        if (listKeys.size() > 0) {
+            genTOBuilder = resolveListKey(packageName, list);
+        }
+
+        return genTOBuilder;
+    }
 }
index 9a38297566986076a99fd0822dde28b4a011f806..30207cc776cec82d22e829b0933e5c023d11665a 100644 (file)
@@ -7,6 +7,10 @@
  */
 package org.opendaylight.controller.sal.binding.yang.types;
 
+import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findDataSchemaNode;
+import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.findDataSchemaNodeForRelativeXPath;
+import static org.opendaylight.controller.yang.model.util.SchemaContextUtil.resolveModuleFromSchemaPath;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -38,14 +42,12 @@ import org.opendaylight.controller.yang.model.api.type.IdentityrefTypeDefinition
 import org.opendaylight.controller.yang.model.api.type.LeafrefTypeDefinition;
 import org.opendaylight.controller.yang.model.api.type.UnionTypeDefinition;
 import org.opendaylight.controller.yang.model.util.ExtendedType;
-import org.opendaylight.controller.yang.model.util.SchemaContextUtil;
 
 public class TypeProviderImpl implements TypeProvider {
 
     private final SchemaContext schemaContext;
-    private final SchemaContextUtil schemaContextUtil;
-    private Map<String, Map<String, GeneratedTransferObject>> generatedTypeDefinitions;
-    private final List<GeneratedTransferObject> generatedTypeDefs = new ArrayList<GeneratedTransferObject>();
+    private Map<String, Map<String, GeneratedTransferObject>> genTypeDefsContextMap;
+    private final List<GeneratedTransferObject> allTypeDefinitions;
 
     public TypeProviderImpl(final SchemaContext schemaContext) {
         if (schemaContext == null) {
@@ -53,21 +55,12 @@ public class TypeProviderImpl implements TypeProvider {
         }
 
         this.schemaContext = schemaContext;
-        schemaContextUtil = new SchemaContextUtil(schemaContext);
-        this.generatedTypeDefinitions = new HashMap<String, Map<String, GeneratedTransferObject>>();
-
-        resolveTypeDefsFromContext();
-
-        final Set<String> moduleNames = generatedTypeDefinitions.keySet();
-
-        for (final String moduleName : moduleNames) {
-            generatedTypeDefs.addAll(generatedTypeDefinitions.get(moduleName)
-                    .values());
-        }
+        this.genTypeDefsContextMap = new HashMap<String, Map<String, GeneratedTransferObject>>();
+        allTypeDefinitions = resolveTypeDefsFromContext();
     }
 
     public List<GeneratedTransferObject> getGeneratedTypeDefs() {
-        return generatedTypeDefs;
+        return allTypeDefinitions;
     }
 
     /*
@@ -102,12 +95,11 @@ public class TypeProviderImpl implements TypeProvider {
                     returnType = resolveEnumFromTypeDefinition(enumTypeDef,
                             typedefName);
                 } else {
-                    final Module module = schemaContextUtil
-                            .resolveModuleFromSchemaPath(typeDefinition
+                    final Module module = resolveModuleFromSchemaPath(schemaContext, typeDefinition
                                     .getPath());
 
                     if (module != null) {
-                        final Map<String, GeneratedTransferObject> genTOs = generatedTypeDefinitions
+                        final Map<String, GeneratedTransferObject> genTOs = genTypeDefsContextMap
                                 .get(module.getName());
                         if (genTOs != null) {
                             returnType = genTOs.get(typedefName);
@@ -129,19 +121,6 @@ public class TypeProviderImpl implements TypeProvider {
                             .javaTypeForSchemaDefinitionType(typeDefinition);
                 }
             }
-
-            // if (typeDefinition instanceof Leafref) {
-            // final LeafrefTypeDefinition leafref = (LeafrefTypeDefinition)
-            // typeDefinition;
-            // returnType = provideTypeForLeafref(leafref);
-            // } else if (typeDefinition instanceof IdentityrefTypeDefinition) {
-            //
-            // } else if (typeDefinition instanceof ExtendedType) {
-            // final TypeDefinition<?> baseType = typeDefinition.getBaseType();
-            // return javaTypeForSchemaDefinitionType(baseType);
-            // } else {
-            // returnType = baseTypeForExtendedType(typeDefinition);
-            // }
         }
         return returnType;
     }
@@ -151,7 +130,7 @@ public class TypeProviderImpl implements TypeProvider {
         if (extendTypeDef != null) {
             final TypeDefinition<?> baseTypeDef = extendTypeDef.getBaseType();
             if (baseTypeDef instanceof ExtendedType) {
-                baseTypeDefForExtendedType(baseTypeDef);
+                return baseTypeDefForExtendedType(baseTypeDef);
             } else {
                 return baseTypeDef;
             }
@@ -172,19 +151,6 @@ public class TypeProviderImpl implements TypeProvider {
                 returnType = BaseYangTypes.BASE_YANG_TYPES_PROVIDER
                         .javaTypeForSchemaDefinitionType(typeDefinition);
             }
-
-            // if (typeDefinition instanceof ExtendedType) {
-            // final TypeDefinition<?> extType = typeDefinition.getBaseType();
-            // return baseTypeForExtendedType(extType);
-            // } else if (typeDefinition instanceof EnumerationType) {
-            // final EnumTypeDefinition enumTypeDef = (EnumTypeDefinition)
-            // typeDefinition;
-            // final String enumName = enumTypeDef.getQName().getLocalName();
-            // return resolveEnumFromTypeDefinition(enumTypeDef, enumName);
-            // } else {
-            // returnType = BaseYangTypes.BASE_YANG_TYPES_PROVIDER
-            // .javaTypeForSchemaDefinitionType(typeDefinition);
-            // }
         }
         return returnType;
     }
@@ -201,16 +167,14 @@ public class TypeProviderImpl implements TypeProvider {
                 if (strXPath.matches(".*//[.* | .*//].*")) {
                     returnType = Types.typeForClass(Object.class);
                 } else {
-                    final Module module = schemaContextUtil
-                            .resolveModuleFromSchemaPath(leafrefType.getPath());
+                    final Module module = resolveModuleFromSchemaPath(schemaContext, leafrefType.getPath());
                     if (module != null) {
                         final DataSchemaNode dataNode;
                         if (xpath.isAbsolute()) {
-                            dataNode = schemaContextUtil.findDataSchemaNode(
+                            dataNode = findDataSchemaNode(schemaContext, 
                                     module, xpath);
                         } else {
-                            dataNode = schemaContextUtil
-                                    .findDataSchemaNodeForRelativeXPath(module,
+                            dataNode = findDataSchemaNodeForRelativeXPath(schemaContext, module,
                                             leafrefType, xpath);
                         }
                         returnType = resolveTypeFromDataSchemaNode(dataNode);
@@ -265,11 +229,9 @@ public class TypeProviderImpl implements TypeProvider {
             final String enumerationName = BindingGeneratorUtil
                     .parseToClassName(enumName);
 
-            Module module = schemaContextUtil
-                    .resolveModuleFromSchemaPath(enumTypeDef.getPath());
+            Module module = resolveModuleFromSchemaPath(schemaContext, enumTypeDef.getPath());
             final String basePackageName = BindingGeneratorUtil
-                    .moduleNamespaceToPackageName(module.getNamespace(),
-                            module.getYangVersion());
+                    .moduleNamespaceToPackageName(module);
             final String packageName = BindingGeneratorUtil
                     .packageNameForGeneratedType(basePackageName,
                             enumTypeDef.getPath());
@@ -315,23 +277,26 @@ public class TypeProviderImpl implements TypeProvider {
         return returnType;
     }
 
-    private void resolveTypeDefsFromContext() {
+    private List<GeneratedTransferObject> resolveTypeDefsFromContext() {
+        final List<GeneratedTransferObject> genTypeDefs = new ArrayList<GeneratedTransferObject>();
         final Set<Module> modules = schemaContext.getModules();
         if (modules != null) {
             for (final Module module : modules) {
                 if (module != null) {
+                    final String moduleName = module.getName();
                     final String basePackageName = BindingGeneratorUtil
-                            .moduleNamespaceToPackageName(
-                                    module.getNamespace(),
-                                    module.getYangVersion());
+                            .moduleNamespaceToPackageName(module);
 
                     final Set<TypeDefinition<?>> typeDefinitions = module
                             .getTypeDefinitions();
 
                     if ((typeDefinitions != null) && (basePackageName != null)) {
                         for (final TypeDefinition<?> typedef : typeDefinitions) {
-                            addGeneratedTypeDefinition(basePackageName,
-                                    module.getName(), typedef);
+                            final GeneratedTransferObject genTransObj = toGeneratedTransferObject(
+                                    basePackageName, moduleName, typedef);
+                            if (genTransObj != null) {
+                                genTypeDefs.add(genTransObj);
+                            }
                         }
                         // for (final TypeDefinition<?> typedef :
                         // typeDefinitions) {
@@ -342,17 +307,20 @@ public class TypeProviderImpl implements TypeProvider {
                 }
             }
         }
+        return genTypeDefs;
     }
 
-    private void addGeneratedTypeDefinition(final String basePackageName,
-            final String moduleName, final TypeDefinition<?> typedef) {
+    private GeneratedTransferObject toGeneratedTransferObject(
+            final String basePackageName, final String moduleName,
+            final TypeDefinition<?> typedef) {
         if ((basePackageName != null) && (moduleName != null)
                 && (typedef != null) && (typedef.getQName() != null)) {
-            final GeneratedTOBuilder genTO = typedefToTransferObject(
+            final GeneratedTOBuilder genTOBuilder = typedefToTransferObject(
                     basePackageName, typedef);
 
+            final String typedefName = typedef.getQName().getLocalName();
             final String propertyName = BindingGeneratorUtil
-                    .parseToValidParamName(typedef.getQName().getLocalName());
+                    .parseToValidParamName(typedefName);
 
             final TypeDefinition<?> baseTypeDefinition = baseTypeDefForExtendedType(typedef);
             if (!(baseTypeDefinition instanceof LeafrefTypeDefinition)
@@ -360,34 +328,40 @@ public class TypeProviderImpl implements TypeProvider {
                 Type returnType = null;
                 if (baseTypeDefinition instanceof EnumTypeDefinition) {
                     final EnumTypeDefinition enumTypeDef = (EnumTypeDefinition) baseTypeDefinition;
-                    final String enumName = typedef.getQName().getLocalName();
                     returnType = resolveEnumFromTypeDefinition(enumTypeDef,
-                            enumName);
+                            typedefName);
                 } else {
                     returnType = BaseYangTypes.BASE_YANG_TYPES_PROVIDER
                             .javaTypeForSchemaDefinitionType(baseTypeDefinition);
                 }
 
                 if (returnType != null) {
-                    final GeneratedPropertyBuilder genPropBuilder = genTO
+                    final GeneratedPropertyBuilder genPropBuilder = genTOBuilder
                             .addProperty(propertyName);
-                            
+
                     genPropBuilder.addReturnType(returnType);
-                    genTO.addEqualsIdentity(genPropBuilder);
-                    genTO.addHashIdentity(genPropBuilder);
-                    genTO.addToStringProperty(genPropBuilder);
-                    
-                    Map<String, GeneratedTransferObject> genTOsMap = generatedTypeDefinitions
+                    genTOBuilder.addEqualsIdentity(genPropBuilder);
+                    genTOBuilder.addHashIdentity(genPropBuilder);
+                    genTOBuilder.addToStringProperty(genPropBuilder);
+
+                    Map<String, GeneratedTransferObject> transferObjectsMap = genTypeDefsContextMap
                             .get(moduleName);
-                    if (genTOsMap == null) {
-                        genTOsMap = new HashMap<String, GeneratedTransferObject>();
-                        generatedTypeDefinitions.put(moduleName, genTOsMap);
+                    if (transferObjectsMap == null) {
+                        transferObjectsMap = new HashMap<String, GeneratedTransferObject>();
+                        genTypeDefsContextMap.put(moduleName,
+                                transferObjectsMap);
+                    }
+
+                    final GeneratedTransferObject transferObject = genTOBuilder
+                            .toInstance();
+                    if (transferObject != null) {
+                        transferObjectsMap.put(typedefName, transferObject);
+                        return transferObject;
                     }
-                    genTOsMap.put(typedef.getQName().getLocalName(),
-                            genTO.toInstance());
                 }
             }
         }
+        return null;
     }
 
     private void addUnionGeneratedTypeDefinition(final String basePackageName,
@@ -402,7 +376,7 @@ public class TypeProviderImpl implements TypeProvider {
 
                 final List<TypeDefinition<?>> unionTypes = unionTypeDef
                         .getTypes();
-                final Map<String, GeneratedTransferObject> genTOsMap = generatedTypeDefinitions
+                final Map<String, GeneratedTransferObject> genTOsMap = genTypeDefsContextMap
                         .get(moduleName);
                 final GeneratedTOBuilder unionGenTransObject = typedefToTransferObject(
                         basePackageName, typedef);
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AugmentedTypeTest.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/AugmentedTypeTest.java
new file mode 100644 (file)
index 0000000..66296a9
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * 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.controller.sal.binding.generator.impl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
+import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
+import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.SchemaContext;
+import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
+import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+
+public class AugmentedTypeTest {
+
+    private final static List<File> augmentModels = new ArrayList<>();
+    private final static String augmentFolderPath = AugmentedTypeTest.class
+            .getResource("/augment-test-models").getPath();
+
+    @BeforeClass
+    public static void loadTestResources() {
+        final File augFolder = new File(augmentFolderPath);
+
+        for (final File fileEntry : augFolder.listFiles()) {
+            if (fileEntry.isFile()) {
+                augmentModels.add(fileEntry);
+            }
+        }
+    }
+
+    @Test
+    public void augmentedAbstractTopologyTest() {
+        final YangModelParser parser = new YangParserImpl();
+        final Set<Module> modules = parser.parseYangModels(augmentModels);
+        final SchemaContext context = parser.resolveSchemaContext(modules);
+
+        assertNotNull(context);
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertNotNull(genTypes);
+        assertTrue(!genTypes.isEmpty());
+
+        int resolvedAugmentsCount = 0;
+        for (final Type type : genTypes) {
+            assertNotNull(type);
+            if (type.getName().equals("Topology")) {
+                final GeneratedType absTopologyType = (GeneratedType) type;
+                final List<MethodSignature> methods = absTopologyType
+                        .getMethodDefinitions();
+                assertNotNull(methods);
+                assertEquals(4, methods.size());
+            } else if (type.getName().equals("InterfaceKey")
+                    && type instanceof GeneratedTransferObject) {
+                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
+                final List<GeneratedProperty> properties = genTO
+                        .getProperties();
+
+                assertTrue(properties != null);
+                for (final GeneratedProperty property : properties) {
+                    if (property.getName().equals("InterfaceId")) {
+                        assertTrue(property.getReturnType() != null);
+                        assertFalse(property.getReturnType().equals(
+                                "java.lang.Void"));
+                        assertTrue(property.getReturnType().getName()
+                                .equals("String"));
+                        resolvedAugmentsCount++;
+                    }
+                }
+            } else if (type.getName().equals("Interface")
+                    && type instanceof GeneratedType) {
+                final GeneratedType genType = (GeneratedType) type;
+                final List<MethodSignature> methods = genType
+                        .getMethodDefinitions();
+
+                assertTrue(methods != null);
+                for (final MethodSignature method : methods) {
+                    if (method.getName().equals("getInterfaceKey")) {
+                        assertTrue(method.getReturnType() != null);
+                        assertFalse(method.getReturnType().equals(
+                                "java.lang.Void"));
+                        assertTrue(method.getReturnType().getName()
+                                .equals("InterfaceKey"));
+                        resolvedAugmentsCount++;
+                    } else if (method.getName().equals("getHigherLayerIf")) {
+                        assertTrue(method.getReturnType() != null);
+                        assertFalse(method.getReturnType().equals(
+                                "java.lang.Void"));
+                        assertTrue(method.getReturnType().getName()
+                                .equals("List"));
+                        resolvedAugmentsCount++;
+                    }
+                }
+            } else if (type.getName().equals("Tunnel")
+                    && type instanceof GeneratedType) {
+                final GeneratedType genType = (GeneratedType) type;
+                final List<MethodSignature> methods = genType
+                        .getMethodDefinitions();
+                assertTrue(methods != null);
+                for (MethodSignature method : methods) {
+                    if (method.getName().equals("getTunnelKey")) {
+                        assertTrue(method.getReturnType() != null);
+                        assertFalse(method.getReturnType().equals(
+                                "java.lang.Void"));
+                        assertTrue(method.getReturnType().getName()
+                                .equals("TunnelKey"));
+                        resolvedAugmentsCount++;
+                    }
+                }
+            } else if (type.getName().equals("TunnelKey")
+                    && type instanceof GeneratedTransferObject) {
+                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
+                final List<GeneratedProperty> properties = genTO
+                        .getProperties();
+
+                assertTrue(properties != null);
+                for (final GeneratedProperty property : properties) {
+                    if (property.getName().equals("TunnelId")) {
+                        assertTrue(property.getReturnType() != null);
+                        assertFalse(property.getReturnType().equals(
+                                "java.lang.Void"));
+                        assertTrue(property.getReturnType().getName()
+                                .equals("Uri"));
+                        resolvedAugmentsCount++;
+                    }
+                }
+            } else if (type.getName().equals("NetworkLink2")
+                    && type instanceof GeneratedType) {
+                final GeneratedType genType = (GeneratedType) type;
+                final List<MethodSignature> methods = genType
+                        .getMethodDefinitions();
+                assertTrue(methods != null);
+                for (MethodSignature method : methods) {
+                    if (method.getName().equals("getInterface")) {
+                        assertTrue(method.getReturnType() != null);
+                        assertFalse(method.getReturnType().equals(
+                                "java.lang.Void"));
+                        assertTrue(method.getReturnType().getName()
+                                .equals("String"));
+                        resolvedAugmentsCount++;
+                    }
+                }
+            }
+        }
+        assertEquals(6, resolvedAugmentsCount);
+    }
+
+    @Test
+    public void augmentedNetworkLinkTest() {
+
+    }
+
+    @Test
+    public void augmentedTopologyTunnelsTest() {
+
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/ControllerTest.java b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/java/org/opendaylight/controller/sal/binding/generator/impl/ControllerTest.java
new file mode 100644 (file)
index 0000000..fb31de5
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * 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.controller.sal.binding.generator.impl;
+
+
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
+import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.SchemaContext;
+import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
+import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class ControllerTest {
+
+    private final static List<File> controllerModels = new ArrayList<>();
+    private final static String controllerModelsFolderPath = ControllerTest.class
+            .getResource("/controller-models").getPath();
+
+    @BeforeClass
+    public static void loadTestResources() {
+        final File ctrlFolder = new File(controllerModelsFolderPath);
+
+        for (final File fileEntry : ctrlFolder.listFiles()) {
+            if (fileEntry.isFile()) {
+                controllerModels.add(fileEntry);
+            }
+        }
+    }
+
+    @Test
+    public void controllerAugmentationTest() {
+        final YangModelParser parser = new YangParserImpl();
+        final Set<Module> modules = parser.parseYangModels(controllerModels);
+        final SchemaContext context = parser.resolveSchemaContext(modules);
+
+        assertNotNull(context);
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertNotNull(genTypes);
+        assertTrue(!genTypes.isEmpty());
+    }
+}
index 92d9359130967008ccc76ea4bccb4f510023d8d6..c1035c3b90e37dbc5e05c2607166268c14c02686 100644 (file)
@@ -7,26 +7,21 @@
  */
 package org.opendaylight.controller.sal.binding.generator.impl;
 
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
 import org.junit.Test;
 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
-import org.opendaylight.controller.sal.binding.model.api.Enumeration;
-import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
-import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
-import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
-import org.opendaylight.controller.sal.binding.model.api.Type;
+import org.opendaylight.controller.sal.binding.model.api.*;
 import org.opendaylight.controller.yang.model.api.Module;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
 import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import static org.junit.Assert.*;
+
 public class GeneratedTypesTest {
 
     private SchemaContext resolveSchemaContextFromFiles(
@@ -67,19 +62,25 @@ public class GeneratedTypesTest {
 
         final SchemaContext context = resolveSchemaContextFromFiles(ianaIfTypePath);
         assertTrue(context != null);
-
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
         final List<Type> genTypes = bindingGen.generateTypes(context);
         assertTrue(genTypes != null);
         assertEquals(2, genTypes.size());
 
-        final Type type = genTypes.get(0);
-        assertTrue(type instanceof GeneratedType);
+        final Type type = genTypes.get(1);
+        assertTrue(type instanceof GeneratedTransferObject);
+
+        final GeneratedTransferObject genTransObj = (GeneratedTransferObject) type;
+        final List<GeneratedProperty> properties = genTransObj.getProperties();
+        assertNotNull(properties);
+        assertEquals(1, properties.size());
 
-        final GeneratedType genType = (GeneratedType) type;
-        assertEquals(1, genType.getEnumDefintions().size());
+        GeneratedProperty property = properties.get(0);
+        assertNotNull(property);
+        assertNotNull(property.getReturnType());
 
-        final Enumeration enumer = genType.getEnumDefintions().get(0);
+        assertTrue(property.getReturnType() instanceof Enumeration);
+        final Enumeration enumer = (Enumeration) property.getReturnType();
         assertEquals(272, enumer.getValues().size());
     }
 
@@ -134,7 +135,7 @@ public class GeneratedTypesTest {
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
         final List<Type> genTypes = bindingGen.generateTypes(context);
 
-        assertEquals(46, genTypes.size());
+        assertEquals(50, genTypes.size());
         assertTrue(genTypes != null);
 
         int resolvedLeafrefCount = 0;
@@ -419,7 +420,8 @@ public class GeneratedTypesTest {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
-            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
+            if (type instanceof GeneratedType &&
+                    !(type instanceof GeneratedTransferObject)) {
                 final GeneratedType genType = (GeneratedType) type;
                 if (genType.getName().equals("ListParentContainer")) {
                     assertEquals(2, genType.getMethodDefinitions().size());
@@ -502,7 +504,8 @@ public class GeneratedTypesTest {
         int genTypesCount = 0;
         int genTOsCount = 0;
         for (final Type type : genTypes) {
-            if (type instanceof GeneratedType && !(type instanceof GeneratedTransferObject)) {
+            if (type instanceof GeneratedType &&
+                    !(type instanceof GeneratedTransferObject)) {
                 genTypesCount++;
             } else if (type instanceof GeneratedTransferObject) {
                 final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
@@ -1,6 +1,6 @@
 module abstract-topology {
     yang-version 1;
-    namespace "urn:opendaylight:sal:topology";
+    namespace "urn:model:abstract:topology";
     prefix "tp";
 
     import ietf-inet-types { 
@@ -13,10 +13,12 @@ module abstract-topology {
 
     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.";
+    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 "~~~ WILL BE DEFINED LATER";
+        reference "http://www.opendaylight.org/";
     }
     
     typedef node-id-ref {
@@ -34,11 +36,14 @@ module abstract-topology {
     }
 
     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.";
+        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
+            description "It is presumed that datastore will contain many topologies. 
+            To distinguish between topologies it is vital to have
             UNIQUE topology identifier.";
         }
 
@@ -84,8 +89,12 @@ module abstract-topology {
                 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.";
+                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.";
             }
         }
     }
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-abstract-topology@2013-05-03.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-abstract-topology@2013-05-03.yang
new file mode 100644 (file)
index 0000000..28b7a9c
--- /dev/null
@@ -0,0 +1,75 @@
+module augment-abstract-topology {
+       yang-version 1;
+    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;
+    }
+       
+    import abstract-topology {
+       prefix "at";
+       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" {
+       container interfaces {
+            list interface {
+                key "interface-id";
+
+                leaf interface-id {
+                    type leafref {
+                        path "/if:interfaces/if:interface/if:name";
+                    }
+                }
+
+                leaf-list higher-layer-if {
+                    type leafref {
+                        path "/if:interfaces/if:interface/if:higher-layer-if";
+                    }
+                }
+            }
+        }
+    }
+
+    augment "at:topology/at:network-links/at:network-link" {
+       container tunnels {
+            list tunnel {
+               key "tunnel-id";
+
+                leaf tunnel-id {
+                    type leafref {
+                        path "../../../link-id";
+                    }
+                }
+                
+                container foo {
+                       leaf bar {
+                               type string;
+                       }
+                }
+            }
+        }
+    }
+
+    augment "at:topology/at:network-links/at:network-link" {
+       leaf interface {
+               type leafref {
+                path "/at:topology/atp:interfaces/atp:interface/atp:interface-id";
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-network-link-attributes@2013-05-03.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-network-link-attributes@2013-05-03.yang
new file mode 100644 (file)
index 0000000..3040cf7
--- /dev/null
@@ -0,0 +1,31 @@
+module augment-network-link-attributes {
+       yang-version 1;
+    namespace "urn:model:augment:network:link:attributes";
+    prefix "tp";
+
+    import abstract-topology {
+       prefix "at";
+       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/at:network-links/at:network-link/at:attributes" {
+       leaf longitude {
+            type decimal64 {    
+                fraction-digits 2;
+            }
+        }
+
+        leaf latitude {
+            type decimal64 {    
+                fraction-digits 2;
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-topology-tunnels@2013-05-03.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/augment-topology-tunnels@2013-05-03.yang
new file mode 100644 (file)
index 0000000..97f8ca5
--- /dev/null
@@ -0,0 +1,28 @@
+module augment-topology-tunnels {
+       yang-version 1;
+    namespace "urn:model:augment:topology:tunnels";
+    prefix "tp";
+
+    import abstract-topology {
+       prefix "at";
+       revision-date 2013-02-08;
+    }
+
+    import augment-abstract-topology {
+        prefix "aug-at";
+        revision-date 2013-05-03;
+    }
+
+    organization "OPEN DAYLIGHT";
+    contact "http://www.opendaylight.org/";
+
+    revision "2013-05-03" {
+        reference "http://www.opendaylight.org/";
+    }
+
+    augment "at:topology/at:network-links/at:network-link/aug-at:tunnels/aug-at:tunnel" {
+       leaf tunnel-name {
+            type string;
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/iana-if-type@2012-06-05.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/iana-if-type@2012-06-05.yang
new file mode 100644 (file)
index 0000000..a7fa137
--- /dev/null
@@ -0,0 +1,1516 @@
+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/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-inet-types@2010-09-24.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-inet-types@2010-09-24.yang
new file mode 100644 (file)
index 0000000..6a6c748
--- /dev/null
@@ -0,0 +1,418 @@
+ 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
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-interfaces@2012-11-15.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-interfaces@2012-11-15.yang
new file mode 100644 (file)
index 0000000..b9117d0
--- /dev/null
@@ -0,0 +1,565 @@
+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/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-yang-types@2010-09-24.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/augment-test-models/ietf-yang-types@2010-09-24.yang
new file mode 100644 (file)
index 0000000..e9d88ab
--- /dev/null
@@ -0,0 +1,396 @@
+ 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
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/controller-network.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/controller-network.yang
new file mode 100644 (file)
index 0000000..357e6ba
--- /dev/null
@@ -0,0 +1,172 @@
+module controller-network {
+       yang-version 1;
+       namespace "urn:opendaylight:controller:network";
+       prefix "topos";
+       
+       import ietf-inet-types { prefix "inet"; }
+       
+       revision 2013-05-20 {
+          description "Initial demo";
+       }
+       
+
+       
+       
+       typedef topology-id {
+               type string;
+       }
+
+       typedef node-id {
+               type string;
+       }
+
+       typedef link-id {
+               type string;
+       }
+
+       typedef tp-id {
+               type string;
+               description "identifier for termination points on a port";
+       }
+
+       typedef tp-ref {
+               type leafref {
+                       path "/network/topologies/topology/nodes/node/termination-points/termination-point/tp-id";
+               }
+       }
+       typedef topology-ref {
+               type leafref {
+                       path "/network/topologies/topology/topology-id";
+               }
+               description "This type is used for leafs that reference topology identifier instance.";
+               // currently not used
+       }
+
+       typedef node-ref {
+               type leafref {
+                       path "/network/topologies/topology/nodes/node/node-id";
+               }
+               description "This type is used for leafs that reference a node instance.";
+       }
+
+       typedef link-ref {
+               type leafref {
+                       path "/network/topologies/topology/links/link/link-id";
+               }
+               description "This type is used for leafs that reference a link instance.";
+               // currently not used
+       }
+       
+       typedef network-element-ref {
+               type leafref {
+                       path "/network/network-elements/network-element/element-id";
+               }
+       }
+
+
+       typedef element-id {
+               type string;
+       }
+       
+       container network {
+               container topologies {
+                       list 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.
+                               ";
+                               key "topology-id";
+                               leaf topology-id {
+                                       type topology-id; 
+                                       description "
+                                               It is presumed that datastore will contain many topologies. To
+                                               distinguish between topologies it is vital to have UNIQUE
+                                               topology identifier.
+                                       ";
+                               }
+
+                               container types {
+                                       description "
+                                               The container for definition of topology types.
+                                               The augmenting modules should add empty optional leaf 
+                                               to this container to signalize topology type.
+                                       ";
+                               }
+
+                               container nodes {
+                                       list node {
+                                               description "The list of network nodes defined for topology.";
+
+                                               key "node-id";
+                                               leaf node-id {
+                                                       type node-id;
+                                                       description "The Topology identifier of network-node.";
+                                               }
+
+                                               leaf supporting-ne {
+                                                       type network-element-ref;
+                                               }
+                                               
+                                               container termination-points {
+                                                       list termination-point {
+                                                               key "tp-id";
+                                                               leaf tp-id {
+                                                                       type tp-id;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+               
+                               container links {
+                                       list link {
+                                               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.
+                                               ";
+                                               key "link-id";
+               
+                                               leaf link-id {
+                                                       type link-id;
+                                               }
+                                               container source { 
+                                                       leaf source-node {
+                                                               type node-ref;
+                                                               description "Source node identifier.";
+                                                       }
+                                                       leaf source-tp {
+                                                               type tp-ref;
+                                                       }
+                                               }
+                                               container destination { 
+                                                       leaf dest-node {
+                                                               type node-ref;
+                                                               description "Destination node identifier.";
+                                                       }
+                                                       leaf dest-tp {
+                                                               type tp-ref;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               container network-elements {
+                       config true;
+                       list network-element {
+                               key "element-id";
+                               leaf element-id {
+                                       type element-id;
+                               }
+                       }
+               }
+       }
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/controller-openflow.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/controller-openflow.yang
new file mode 100644 (file)
index 0000000..62e937e
--- /dev/null
@@ -0,0 +1,79 @@
+module controller-openflow {
+
+    namespace "urn:opendaylight:controller:openflow";
+    prefix "of";
+    import controller-network {prefix cn;}
+    
+    
+    revision 2013-05-20 {
+       description "Initial demo";
+    }
+
+   
+
+
+
+    typedef datapath-id {
+        type string {
+            length 16;
+        }
+    }
+
+
+    augment "/cn:network/cn:topologies/cn:topology/cn:types" {
+        leaf openflow {type string;}
+    }
+
+    augment "/cn:network/cn:topologies/cn:topology/cn:links/cn:link/cn:source" {
+        when "../../../cn:types/of:openflow";
+
+        leaf logical-port {
+            type int32;
+        }
+    }
+
+    augment "/cn:network/cn:topologies/cn:topology/cn:links/cn:link/cn:destination" {
+        when "../../../cn:types/of:openflow";
+
+        leaf logical-port {
+            type int32;
+        }
+    }
+
+    augment "/cn:network/cn:topologies/cn:topology/cn:nodes/cn:node/" {
+        when "../../../cn:types/of:openflow";
+        leaf datapath-id {
+            type datapath-id;
+        }
+    }
+    
+    augment "/cn:network/cn:network-elements/cn:network-element" {
+        leaf datapath-id {
+            type datapath-id;
+        }
+
+        container ports {
+            list port {
+                key "logical-port-id";
+                
+                leaf logical-port-id {
+                    type int32;
+                }
+
+                // Should be replaced with ref to interface
+                leaf physical-name {
+                    type string;
+                }
+            }
+        }
+        container flow-tables {
+            list flow-table {
+                key "flow-table-id";
+                leaf flow-table-id {
+                    type string;
+                }
+
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/ietf-inet-types@2010-09-24.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/ietf-inet-types@2010-09-24.yang
new file mode 100644 (file)
index 0000000..de20feb
--- /dev/null
@@ -0,0 +1,418 @@
+ 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/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/ietf-yang-types@2010-09-24.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/controller-models/ietf-yang-types@2010-09-24.yang
new file mode 100644 (file)
index 0000000..51d9f8b
--- /dev/null
@@ -0,0 +1,396 @@
+ 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";
+   }
+
+ }
index 8a08ab4355dc86e2bcdd2ddfc933fdaafdd74b4a..db7676040db25c805bbbd3dedbb260e4f982813a 100644 (file)
        <artifactId>yang-model-api</artifactId>\r
        <version>0.5-SNAPSHOT</version>\r
       </dependency>\r
+      <dependency>\r
+       <groupId>junit</groupId>\r
+       <artifactId>junit</artifactId>\r
+      </dependency>\r
+      <dependency>\r
+       <groupId>org.opendaylight.controller</groupId>\r
+       <artifactId>yang-binding</artifactId>\r
+       <version>0.5-SNAPSHOT</version>\r
+      </dependency>\r
   </dependencies>\r
 </project>
\ No newline at end of file
index 5496cf96acf80e2b0a2829a615f407575d17dc20..6683230d028ef8c419b05413d0828a31fc84f772 100644 (file)
@@ -21,7 +21,6 @@ public class AbstractBaseType implements Type {
 \r
     @Override\r
     public String getName() {\r
-\r
         return name;\r
     }\r
 \r
@@ -52,7 +51,7 @@ public class AbstractBaseType implements Type {
         if (name == null) {\r
             if (other.getName() != null)\r
                 return false;\r
-        } else if (!name.equals(other.getPackageName()))\r
+        } else if (!name.equals(other.getName()))\r
             return false;\r
         if (packageName == null) {\r
             if (other.getPackageName() != null)\r
index 1e16a05def2789ae9fde0b24f236ed94e2aaecba..1fb862291f19700b673a153112bf6f4352d02553 100644 (file)
@@ -1,22 +1,15 @@
 package org.opendaylight.controller.binding.generator.util;
 
-import java.net.URI;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.GregorianCalendar;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
 import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTOBuilderImpl;
 import org.opendaylight.controller.sal.binding.model.api.type.builder.GeneratedTOBuilder;
 import org.opendaylight.controller.yang.common.QName;
-import org.opendaylight.controller.yang.model.api.SchemaNode;
-import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.*;
+
+import java.util.*;
 
 public class BindingGeneratorUtil {
 
-    private static final String[] SET_VALUES = new String[] { "abstract",
+    private static final String[] SET_VALUES = new String[]{"abstract",
             "assert", "boolean", "break", "byte", "case", "catch", "char",
             "class", "const", "continue", "default", "double", "do", "else",
             "enum", "extends", "false", "final", "finally", "float", "for",
@@ -24,12 +17,9 @@ public class BindingGeneratorUtil {
             "interface", "long", "native", "new", "null", "package", "private",
             "protected", "public", "return", "short", "static", "strictfp",
             "super", "switch", "synchronized", "this", "throw", "throws",
-            "transient", "true", "try", "void", "volatile", "while" };
-
-    private static Calendar calendar = new GregorianCalendar();
+            "transient", "true", "try", "void", "volatile", "while"};
 
-    private BindingGeneratorUtil() {
-    }
+    private BindingGeneratorUtil() {}
 
     public static final Set<String> JAVA_RESERVED_WORDS = new HashSet<String>(
             Arrays.asList(SET_VALUES));
@@ -53,7 +43,7 @@ public class BindingGeneratorUtil {
         }
         return packageName;
     }
-    
+
     public static String validateParameterName(final String parameterName) {
         if (parameterName != null) {
             if (JAVA_RESERVED_WORDS.contains(parameterName)) {
@@ -62,38 +52,38 @@ public class BindingGeneratorUtil {
         }
         return parameterName;
     }
-    
+
     public static GeneratedTOBuilder schemaNodeToTransferObjectBuilder(
-            final String basePackageName, final SchemaNode schemaNode, final String transObjectName) {
-        if (basePackageName != null && schemaNode != null && transObjectName != null) {
-            final String packageName = packageNameForGeneratedType(basePackageName,
-                    schemaNode.getPath());
-
-            if (packageName != null) {
-                final String genTOName = BindingGeneratorUtil
-                        .parseToClassName(transObjectName);
-                final GeneratedTOBuilder newType = new GeneratedTOBuilderImpl(
-                        packageName, genTOName);
-
-                return newType;
-            }
+            final String packageName, final SchemaNode schemaNode,
+            final String transObjectName) {
+        if (packageName != null && schemaNode != null
+                && transObjectName != null) {
+
+            final String genTOName = BindingGeneratorUtil
+                    .parseToClassName(transObjectName);
+            final GeneratedTOBuilder newType = new GeneratedTOBuilderImpl(
+                    packageName, genTOName);
+
+            return newType;
+
         }
         return null;
     }
 
     public static String moduleNamespaceToPackageName(
-            final URI moduleNamespace, final String yangVersion) {
+            final Module module) {
         final StringBuilder packageNameBuilder = new StringBuilder();
 
+        final Calendar calendar = Calendar.getInstance();
+        if (module.getRevision() == null) {
+            throw new IllegalArgumentException("Module " + module.getName()
+                    + " does not specify revision date!");
+        }
         packageNameBuilder.append("org.opendaylight.yang.gen.v");
-        packageNameBuilder.append(yangVersion);
-        packageNameBuilder.append(".rev");
-        packageNameBuilder.append(calendar.get(Calendar.YEAR));
-        packageNameBuilder.append((calendar.get(Calendar.MONTH) + 1));
-        packageNameBuilder.append(calendar.get(Calendar.DAY_OF_MONTH));
+        packageNameBuilder.append(module.getYangVersion());
         packageNameBuilder.append(".");
 
-        String namespace = moduleNamespace.toString();
+        String namespace = module.getNamespace().toString();
         namespace = namespace.replace("://", ".");
         namespace = namespace.replace("/", ".");
         namespace = namespace.replace(":", ".");
@@ -109,8 +99,13 @@ public class BindingGeneratorUtil {
         namespace = namespace.replace("=", ".");
 
         packageNameBuilder.append(namespace);
+        calendar.setTime(module.getRevision());
+        packageNameBuilder.append(".rev");
+        packageNameBuilder.append(calendar.get(Calendar.YEAR));
+        packageNameBuilder.append((calendar.get(Calendar.MONTH) + 1));
+        packageNameBuilder.append(calendar.get(Calendar.DAY_OF_MONTH));
 
-        return packageNameBuilder.toString();
+        return validateJavaPackage(packageNameBuilder.toString());
     }
 
     public static String packageNameForGeneratedType(
@@ -132,7 +127,7 @@ public class BindingGeneratorUtil {
         }
         return null;
     }
-    
+
     public static String parseToClassName(String token) {
         token = token.replace(".", "");
         String correctStr = parseToCamelCase(token);
@@ -142,7 +137,7 @@ public class BindingGeneratorUtil {
         correctStr = first + correctStr.substring(1);
         return correctStr;
     }
-    
+
     public static String parseToValidParamName(final String token) {
         final String validToken = token.replace(".", "");
         String correctStr = parseToCamelCase(validToken);
@@ -152,7 +147,7 @@ public class BindingGeneratorUtil {
         correctStr = first + correctStr.substring(1);
         return validateParameterName(correctStr);
     }
-    
+
     private static String parseToCamelCase(String token) {
         if (token == null) {
             throw new NullPointerException("Name can not be null");
@@ -168,7 +163,7 @@ public class BindingGeneratorUtil {
         correctStr = replaceWithCamelCase(correctStr, '_');
         return correctStr;
     }
-    
+
     private static String replaceWithCamelCase(String text, char removalChar) {
         StringBuilder sb = new StringBuilder(text);
         String toBeRemoved = String.valueOf(removalChar);
@@ -5,12 +5,12 @@
  * 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.controller.sal.binding.generator.impl;
+package org.opendaylight.controller.binding.generator.util;
 
 import org.opendaylight.controller.sal.binding.model.api.Type;
 
 
-final class ReferencedTypeImpl implements Type {
+public final class ReferencedTypeImpl implements Type {
     
     private final String packageName;
     private final String name;
index 8c65b4a26cc20f60309311c48f8fd800c25694ec..87bb47cb76e6819f9b93fd0180154b4545c25bd8 100644 (file)
@@ -14,12 +14,17 @@ import java.util.Set;
 import org.opendaylight.controller.sal.binding.model.api.ConcreteType;\r
 import org.opendaylight.controller.sal.binding.model.api.ParameterizedType;\r
 import org.opendaylight.controller.sal.binding.model.api.Type;\r
+import org.opendaylight.controller.yang.binding.Augmentable;\r
+import org.opendaylight.controller.yang.binding.Augmentation;\r
+import org.opendaylight.controller.yang.binding.DataObject;\r
 \r
 public class Types {\r
     private static final Type SET_TYPE = typeForClass(Set.class);\r
     private static final Type LIST_TYPE = typeForClass(List.class);\r
     private static final Type MAP_TYPE = typeForClass(Map.class);\r
-\r
+    \r
+    public static final Type DATA_OBJECT = typeForClass(DataObject.class);\r
+    \r
     private Types() {\r
     }\r
 \r
@@ -88,7 +93,17 @@ public class Types {
             Type... parameters) {\r
         return new ParametrizedTypeImpl(type, parameters);\r
     }\r
-\r
+    \r
+    public static ParameterizedType augmentableTypeFor(Type valueType) {\r
+        final Type augmentable = typeForClass(Augmentable.class);\r
+        return parameterizedTypeFor(augmentable, valueType);\r
+    }\r
+    \r
+    public static ParameterizedType augmentationTypeFor(Type valueType) {\r
+        final Type augmentation = typeForClass(Augmentation.class);\r
+        return parameterizedTypeFor(augmentation, valueType);\r
+    }\r
+    \r
     private static class ConcreteTypeImpl extends AbstractBaseType implements\r
             ConcreteType {\r
         private ConcreteTypeImpl(String pkName, String name) {\r
index 81104d244e769a9c3af593c4f466401a90f19312..01d9bbfa9fb05550d0e497df74fd89c0f52ba5c7 100644 (file)
@@ -17,7 +17,6 @@ import org.opendaylight.controller.sal.binding.model.api.Constant;
 import org.opendaylight.controller.sal.binding.model.api.Enumeration;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedProperty;
 import org.opendaylight.controller.sal.binding.model.api.GeneratedTransferObject;
-import org.opendaylight.controller.sal.binding.model.api.GeneratedType;
 import org.opendaylight.controller.sal.binding.model.api.MethodSignature;
 import org.opendaylight.controller.sal.binding.model.api.Type;
 import org.opendaylight.controller.sal.binding.model.api.type.builder.AnnotationTypeBuilder;
@@ -33,7 +32,7 @@ public final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
     private String comment = "";
     
     private GeneratedTransferObject extendsType;
-    private final List<GeneratedType> implementsTypes = new ArrayList<GeneratedType>();
+    private final List<Type> implementsTypes = new ArrayList<Type>();
     private final List<EnumBuilder> enumerations = new ArrayList<EnumBuilder>();
     private final List<GeneratedPropertyBuilder> properties = new ArrayList<GeneratedPropertyBuilder>();
     private final List<GeneratedPropertyBuilder> equalsProperties = new ArrayList<GeneratedPropertyBuilder>();
@@ -84,7 +83,7 @@ public final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
     }
     
     @Override
-    public boolean addImplementsType(final GeneratedType genType) {
+    public boolean addImplementsType(final Type genType) {
         if (genType != null) {
             return implementsTypes.add(genType);
         }
@@ -409,14 +408,14 @@ public final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
         private final List<AnnotationType> annotations;
         private final List<MethodSignature> methods;
         private final GeneratedTransferObject extendsType;
-        private final List<GeneratedType> implementsTypes;
+        private final List<Type> implementsTypes;
 
         public GeneratedTransferObjectImpl(final String packageName,
                 final String name,
                 final String comment,
                 final List<AnnotationTypeBuilder> annotationBuilders,
                 final GeneratedTransferObject extendsType,
-                final List<GeneratedType> implementsTypes,
+                final List<Type> implementsTypes,
                 final List<ConstantBuilder> constantBuilders,
                 final List<EnumBuilder> enumBuilders,
                 final List<MethodSignatureBuilder> methodBuilders,
@@ -511,7 +510,7 @@ public final class GeneratedTOBuilderImpl implements GeneratedTOBuilder {
         }
         
         @Override
-        public List<GeneratedType> getImplements() {
+        public List<Type> getImplements() {
             return implementsTypes;
         }
 
index 46b5cf46a8141ca871ef3abbe1d0ddd70eecbdac..3a3ded39babc818b3abdf57008307399e3ac4780 100644 (file)
@@ -29,7 +29,7 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
     private String comment = "";
     private final String name;
     private final List<AnnotationTypeBuilder> annotationBuilders = new ArrayList<AnnotationTypeBuilder>();
-    private final List<GeneratedType> implementsTypes = new ArrayList<GeneratedType>();
+    private final List<Type> implementsTypes = new ArrayList<Type>();
     private final List<EnumBuilder> enumDefinitions = new ArrayList<EnumBuilder>();
     private final List<ConstantBuilder> constantDefintions = new ArrayList<ConstantBuilder>();
     private final List<MethodSignatureBuilder> methodDefinitions = new ArrayList<MethodSignatureBuilder>();
@@ -97,7 +97,7 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
     }
 
     @Override
-    public boolean addImplementsType(final GeneratedType genType) {
+    public boolean addImplementsType(final Type genType) {
         if (genType != null) {
             return implementsTypes.add(genType);
         }
@@ -118,7 +118,7 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
         private final String name;
         private final String comment;
         private final List<AnnotationType> annotations;
-        private final List<GeneratedType> implementsTypes;
+        private final List<Type> implementsTypes;
         private final List<Enumeration> enumDefinitions;
         private final List<Constant> constantDefintions;
         private final List<MethodSignature> methodDefinitions;
@@ -126,7 +126,7 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
         public GeneratedTypeImpl(final Type parent, final String packageName,
                 final String name, final String comment,
                 final List<AnnotationTypeBuilder> annotationBuilders,
-                final List<GeneratedType> implementsTypes,
+                final List<Type> implementsTypes,
                 final List<EnumBuilder> enumBuilders,
                 final List<ConstantBuilder> constantBuilders,
                 final List<MethodSignatureBuilder> methodBuilders) {
@@ -204,7 +204,7 @@ public final class GeneratedTypeBuilderImpl implements GeneratedTypeBuilder {
         }
         
         @Override
-        public List<GeneratedType> getImplements() {
+        public List<Type> getImplements() {
             return implementsTypes;
         }
         
index 847986c001562a6f819d7469e461d2482f2e9342..438cd6a9938ea3a2af0db15bfd8ef5eff5473255 100644 (file)
@@ -24,5 +24,9 @@
                        <artifactId>binding-generator-util</artifactId>\r
                        <version>0.5-SNAPSHOT</version>\r
                </dependency>\r
+               <dependency>\r
+                       <groupId>junit</groupId>\r
+                       <artifactId>junit</artifactId>\r
+               </dependency>\r
        </dependencies>\r
 </project>
\ No newline at end of file
index bf608e17d6fa38b7b520f9d61ab7053844180e00..a0db8c7b6d500d7b7ea1b420c43a7456c2081a97 100644 (file)
@@ -37,7 +37,7 @@ public class GeneratorJavaFile {
             final Set<GeneratedType> types) {
         this.interfaceGenerator = codeGenerator;
         this.genTypes = types;
-        this.genTransferObjects = new HashSet<GeneratedTransferObject>();
+        this.genTransferObjects = new HashSet<>();
         classGenerator = new ClassCodeGenerator();
     }
 
@@ -49,40 +49,8 @@ public class GeneratorJavaFile {
         this.genTransferObjects = genTransferObjects;
     }
 
-    @Deprecated
-    public List<File> generateToFile(String path) throws IOException {
-        final List<File> result = new ArrayList<File>();
-
-        for (GeneratedType genType : genTypes) {
-            final String parentPath = generateParentPath(path,
-                    genType.getPackageName());
-
-            final File directory = new File(parentPath);
-            final File genFile = generateTypeToJavaFile(directory, genType,
-                    interfaceGenerator);
-            
-            if (genFile != null) {
-                result.add(genFile);
-            }
-        }
-
-        for (GeneratedTransferObject transferObject : genTransferObjects) {
-            final String parentPath = generateParentPath(path,
-                    transferObject.getPackageName());
-
-            final File directory = new File(parentPath);
-            final File genFile = generateTypeToJavaFile(directory,
-                    transferObject, classGenerator);
-
-            if (genFile != null) {
-                result.add(genFile);
-            }
-        }
-        return result;
-    }
-
     public List<File> generateToFile(final File parentDirectory) throws IOException {
-        final List<File> result = new ArrayList<File>();
+        final List<File> result = new ArrayList<>();
         for (GeneratedType type : genTypes) {
             final File genFile = generateTypeToJavaFile(parentDirectory, type,
                     interfaceGenerator);
@@ -110,12 +78,12 @@ public class GeneratorJavaFile {
         }
         if (type == null) {
             log.error("Cannot generate Type into Java File because " +
-                        "Generated Type is NULL!");
+                       "Generated Type is NULL!");
             throw new IllegalArgumentException("Generated Type Cannot be NULL!");
         }
         if (generator == null) {
             log.error("Cannot generate Type into Java File because " +
-                        "Code Generator instance is NULL!");
+                       "Code Generator instance is NULL!");
             throw new IllegalArgumentException("Code Generator Cannot be NULL!");
         }
         final File packageDir = packageToDirectory(parentDir,
@@ -154,40 +122,4 @@ public class GeneratorJavaFile {
         }
         return new File(parentDirectory, dirPathBuilder.toString());
     }
-    
-    @Deprecated
-    private String generateParentPath(String path, String pkg) {
-        List<String> dirs = new ArrayList<String>();
-        String pkgPath = "";
-        if (pkg != null) {
-            if (pkg.length() > 0) {
-                if (pkg.contains(".")) {
-                    String[] split = pkg.split("\\.");
-                    for (String dir : split) {
-                        dirs.add(dir);
-                    }
-                } else {
-                    dirs.add(pkg);
-                }
-                for (int i = 0; i < dirs.size(); i++) {
-                    if (i == 0) {
-                        pkgPath += dirs.get(i);
-                    } else {
-                        pkgPath += File.separator + dirs.get(i);
-                    }
-                }
-            }
-        }
-        String fullPath = "";
-        if (path != null) {
-            if (path.endsWith(File.separator)) {
-                fullPath = path + pkgPath;
-            } else {
-                fullPath = path + File.separator + pkgPath;
-            }
-        } else {
-            fullPath = pkgPath;
-        }
-        return fullPath;
-    }
 }
index 431835f6c09b3edbd401aba10f04037e8030f10f..9e9a3e5df1dcabb339e250ff1ec0ba5c11e78153 100644 (file)
@@ -73,7 +73,7 @@ public class GeneratorUtil {
         }
         builder.append(PUBLIC + GAP + type + GAP + genType.getName() + GAP);
 
-        final List<GeneratedType> genImplements = genType.getImplements();
+        final List<Type> genImplements = genType.getImplements();
         if (genType instanceof GeneratedTransferObject) {
             GeneratedTransferObject genTO = (GeneratedTransferObject) genType;
 
@@ -88,12 +88,10 @@ public class GeneratorUtil {
             } else {
                 builder.append(EXTENDS + GAP);
             }
-            builder.append(genImplements.get(0).getPackageName()
-                    + "." + genImplements.get(0).getName());
+            builder.append(getExplicitType(genImplements.get(0)));
             for (int i = 1; i < genImplements.size(); ++i) {
                 builder.append(", ");
-                builder.append(genImplements.get(i).getPackageName()
-                        + "." + genImplements.get(i).getName());
+                builder.append(getExplicitType(genImplements.get(i)));
             }
         }
 
@@ -192,9 +190,21 @@ public class GeneratorUtil {
      */
     public static String createMethodDeclaration(final MethodSignature method,
             final String indent) {
+        if (method == null) {
+            throw new IllegalArgumentException("Method Signature parameter MUST be specified and cannot be NULL!");
+        }
+
         final String comment = method.getComment();
-        final Type type = method.getReturnType();
         final String name = method.getName();
+        if (name == null) {
+            throw new IllegalStateException("Method Name cannot be NULL!");
+        }
+
+        final Type type = method.getReturnType();
+        if (type == null) {
+            throw new IllegalStateException("Method Return type cannot be NULL!");
+        }
+
         final List<Parameter> parameters = method.getParameters();
 
         final StringBuilder builder = new StringBuilder();
@@ -452,14 +462,18 @@ public class GeneratorUtil {
     }
 
     private static String getExplicitType(final Type type) {
+        if (type == null) {
+            throw new IllegalArgumentException("Type parameter MUST be specified and cannot be NULL!");
+        }
         String packageName = type.getPackageName();
         if (packageName.endsWith(".")) {
             packageName = packageName.substring(0, packageName.length() - 1);
         }
+
         final StringBuilder builder = new StringBuilder(packageName + "."
                 + type.getName());
         if (type instanceof ParameterizedType) {
-            ParameterizedType pType = (ParameterizedType) type;
+            final ParameterizedType pType = (ParameterizedType) type;
             Type[] pTypes = pType.getActualTypeArguments();
             builder.append("<");
             builder.append(getParameters(pTypes));
index b05e48ed69dee0407f6bf9f69d9cbc04ea840362..6c40c40cb13a60b1c70c639539d9f8c1dcbafc8c 100644 (file)
@@ -7,23 +7,9 @@
  */
 package org.opendaylight.controller.sal.java.api.generator.test;
 
-import static org.junit.Assert.*;
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.ToolProvider;
-
 import org.junit.After;
 import org.junit.Before;
+import org.junit.Ignore;
 import org.junit.Test;
 import org.opendaylight.controller.binding.generator.util.generated.type.builder.GeneratedTypeBuilderImpl;
 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
@@ -38,6 +24,17 @@ import org.opendaylight.controller.yang.model.api.Module;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
 import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
 
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.ToolProvider;
+import java.io.File;
+import java.io.IOException;
+import java.util.*;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
 public class GeneratorJavaFileTest {
     private static final String FS = File.separator;
     private static final String PATH = "test-dir";
@@ -88,12 +85,14 @@ public class GeneratorJavaFileTest {
         assertTrue(filesList.contains("Type3.java"));
     }
 
+    @Ignore
     @Test
     public void compilationTest() throws Exception {
         final YangParserImpl parser = new YangParserImpl();
         final BindingGenerator bindingGenerator = new BindingGeneratorImpl();
 
-        final File sourcesDir = new File("src/test/resources/yang");
+        final String resPath = getClass().getResource("/yang").getPath();
+        final File sourcesDir = new File(resPath);
         final List<File> sourceFiles = new ArrayList<File>();
         final File[] fileArray = sourcesDir.listFiles();
 
@@ -128,11 +127,15 @@ public class GeneratorJavaFileTest {
                 null, null, null);
 
         List<File> filesList = getJavaFiles(new File(GENERATOR_OUTPUT_PATH));
+        File current = new File(System.getProperty("user.dir"));
+        File parentPath = current.getParentFile().getParentFile();
+        File f = new File(parentPath,"yang/yang-binding/src/main/java/org/opendaylight/controller/yang/binding/DataObject.java"
+        );
+        filesList.add(f);
 
         Iterable<? extends JavaFileObject> compilationUnits = fileManager
                 .getJavaFileObjectsFromFiles(filesList);
-        Iterable<String> options = Arrays.asList(new String[] { "-d",
-                COMPILER_OUTPUT_PATH });
+        Iterable<String> options = Arrays.asList(new String[]{"-d", COMPILER_OUTPUT_PATH});
         boolean compiled = compiler.getTask(null, null, null, options, null,
                 compilationUnits).call();
         assertTrue(compiled);
@@ -158,8 +161,7 @@ public class GeneratorJavaFileTest {
     /**
      * Search recursively given directory for *.java files.
      *
-     * @param directory
-     *            directory to search
+     * @param directory directory to search
      * @return List of java files found
      */
     private List<File> getJavaFiles(File directory) {
@@ -176,5 +178,4 @@ public class GeneratorJavaFileTest {
         }
         return result;
     }
-
 }
index f15d33bd685bc0281f006a017c62f742b411d71a..82d1720714eaeee707a7ebf8b7fe2e809decb653 100644 (file)
@@ -36,7 +36,7 @@ public interface GeneratedType extends Type {
     
     public List<AnnotationType> getAnnotations();
     
-    public List<GeneratedType> getImplements();
+    public List<Type> getImplements();
     
     /**
      * Returns Set of all Enumerator definitions associated with interface.
index 55da97a6eba9a0e52eb0dfd2f174fb0a83c0b163..689e8311e2d30dd4b848fb2ff3f5275e5e8283cf 100644 (file)
@@ -22,7 +22,7 @@ public interface GeneratedTypeBuilder extends Type {
     
     public AnnotationTypeBuilder addAnnotation(final String packageName, final String name);
     
-    public boolean addImplementsType(final GeneratedType genType);
+    public boolean addImplementsType(final Type genType);
     
     public ConstantBuilder addConstant(final Type type, final String name,
             final Object value);
index 37282cc5e817d99ce0e26c37ca3627be09a76dde..93c6a12cd1a52f3fc415b11593bfc392fb6eff11 100644 (file)
@@ -1,12 +1,10 @@
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
        <modelVersion>4.0.0</modelVersion>\r
-       <parent>\r
-               <groupId>org.opendaylight.controller</groupId>\r
-               <artifactId>binding-generator</artifactId>\r
-               <version>0.5-SNAPSHOT</version>\r
-       </parent>\r
+    <groupId>org.opendaylight.controller</groupId>\r
        <artifactId>code-generator-demo</artifactId>\r
+    <version>1.0</version>\r
+    <packaging>jar</packaging>\r
 \r
        <dependencies>\r
                <dependency>\r
index 74cae01ecfa0ce1293306427510177da93065224..ee548876d00f6c547c36f0b2473770ca9249a230 100644 (file)
@@ -21,7 +21,6 @@ import org.opendaylight.controller.sal.binding.model.api.Type;
 import org.opendaylight.controller.sal.java.api.generator.GeneratorJavaFile;
 import org.opendaylight.controller.yang.model.api.Module;
 import org.opendaylight.controller.yang.model.api.SchemaContext;
-import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
 import org.opendaylight.controller.yang.parser.impl.YangParserImpl;
 
 public class Demo {
@@ -46,21 +45,26 @@ public class Demo {
         } else {
             System.err.println("Missing output-folder declaration (-o=)");
         }
-
+        
         File resourceDir = new File(inputFilesDir);
         if (!resourceDir.exists()) {
             throw new IllegalArgumentException(
                     "Specified input-folder does not exists: "
                             + resourceDir.getAbsolutePath());
         }
-
+        
+        final File outputFolder = new File(outputFilesDir);
+        if (!outputFolder.exists()) {
+            outputFolder.mkdirs();
+        }
+        
         String[] dirList = resourceDir.list();
         List<File> inputFiles = new ArrayList<File>();
         for (String fileName : dirList) {
             inputFiles.add(new File(resourceDir, fileName));
         }
 
-        final YangModelParser parser = new YangParserImpl();
+        final YangParserImpl parser = new YangParserImpl();
         final BindingGenerator bindingGenerator = new BindingGeneratorImpl();
         final Set<Module> modulesToBuild = parser.parseYangModels(inputFiles);
 
@@ -83,7 +87,7 @@ public class Demo {
 
         final GeneratorJavaFile generator = new GeneratorJavaFile(typesToGenerate, tosToGenerate);
         
-        generator.generateToFile(outputFilesDir);
+        generator.generateToFile(outputFolder);
         System.out.println("Modules built: " + modulesToBuild.size());
     }
 }
index c9b43d838eb81f1b9b5e44471fb313fedb9828df..dccaf8fd9573328a9eea1a4b7e5f46c0342c206e 100644 (file)
@@ -44,7 +44,7 @@ public class CodeGeneratorImpl implements CodeGenerator {
         }
 
         final GeneratorJavaFile generator = new GeneratorJavaFile(typesToGenerate, tosToGenerate);
-        return generator.generateToFile(outputBaseDir.getAbsolutePath());
+        return generator.generateToFile(outputBaseDir);
     }
 
 }
diff --git a/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/YangToSourcesMojo.java.bak b/opendaylight/sal/yang-prototype/code-generator/maven-yang-plugin/src/main/java/org/opendaylight/controller/yang2sources/plugin/YangToSourcesMojo.java.bak
new file mode 100644 (file)
index 0000000..32ad2ab
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * 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.controller.yang2sources.plugin;
+
+import java.io.File;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.plugins.annotations.LifecyclePhase;
+import org.apache.maven.plugins.annotations.Mojo;
+import org.apache.maven.plugins.annotations.Parameter;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.SchemaContext;
+import org.opendaylight.controller.yang.model.parser.api.YangModelParser;
+import org.opendaylight.controller.yang.model.parser.impl.YangModelParserImpl;
+import org.opendaylight.controller.yang2sources.plugin.ConfigArg.CodeGeneratorArg;
+import org.opendaylight.controller.yang2sources.spi.CodeGenerator;
+
+import com.google.common.annotations.VisibleForTesting;
+import com.google.common.collect.Maps;
+
+/**
+ * Generate sources from yang files using user provided set of
+ * {@link CodeGenerator}s. Steps of this process:
+ * <ol>
+ * <li>List yang files from {@link #yangFilesRootDir}</li>
+ * <li>Process yang files using {@link YangModelParserImpl}</li>
+ * <li>For each {@link CodeGenerator} from {@link #codeGenerators}:</li>
+ * <ol>
+ * <li>Instantiate using default constructor</li>
+ * <li>Call {@link CodeGenerator#generateSources(SchemaContext, File)}</li>
+ * </ol>
+ * </ol>
+ */
+@Mojo(name = "generate-sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES)
+public final class YangToSourcesMojo extends AbstractMojo {
+
+    private static final String LOG_PREFIX = "yang-to-sources:";
+
+    /**
+     * Classes implementing {@link CodeGenerator} interface. An instance will be
+     * created out of every class using default constructor. Method
+     * {@link CodeGenerator#generateSources(SchemaContext, File)} will be called
+     * on every instance.
+     */
+    @Parameter(required = true)
+    private CodeGeneratorArg[] codeGenerators;
+
+    /**
+     * Source directory that will be recursively searched for yang files (ending
+     * with .yang suffix).
+     */
+    @Parameter(required = true)
+    private String yangFilesRootDir;
+
+    private final YangModelParser parser;
+
+    @VisibleForTesting
+    YangToSourcesMojo(CodeGeneratorArg[] codeGeneratorArgs,
+            YangModelParser parser, String yangFilesRootDir) {
+        super();
+        this.codeGenerators = codeGeneratorArgs;
+        this.yangFilesRootDir = yangFilesRootDir;
+        this.parser = parser;
+    }
+
+    public YangToSourcesMojo() {
+        super();
+        parser = new YangModelParserImpl();
+    }
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException {
+        SchemaContext context = processYang();
+        generateSources(context);
+    }
+
+    /**
+     * Generate {@link SchemaContext} with {@link YangModelParserImpl}
+     */
+    private SchemaContext processYang() throws MojoExecutionException {
+        try {
+            String[] yangFiles = Util.listFilesAsArrayOfPaths(yangFilesRootDir);
+
+            if (yangFiles.length == 0)
+                getLog().warn(
+                        Util.message("No %s file found in %s", LOG_PREFIX,
+                                Util.YANG_SUFFIX, yangFilesRootDir));
+            // TODO only warning or throw exception ?
+
+            Set<Module> parsedYang = parser.parseYangModels(yangFiles);
+            SchemaContext resolveSchemaContext = parser
+                    .resolveSchemaContext(parsedYang);
+            getLog().info(
+                    Util.message("%s files parsed from %s", LOG_PREFIX,
+                            Util.YANG_SUFFIX, Arrays.toString(yangFiles)));
+            return resolveSchemaContext;
+
+            // MojoExecutionException is thrown since execution cannot continue
+        } catch (Exception e) {
+            String message = Util.message("Unable to parse %s files from %s",
+                    LOG_PREFIX, Util.YANG_SUFFIX, yangFilesRootDir);
+            getLog().error(message, e);
+            throw new MojoExecutionException(message, e);
+        }
+    }
+
+    /**
+     * Call generate on every generator from plugin configuration
+     */
+    private void generateSources(SchemaContext context)
+            throws MojoFailureException {
+        if (codeGenerators.length == 0) {
+            getLog().warn(
+                    Util.message("No code generators provided", LOG_PREFIX));
+            return;
+        }
+
+        Map<String, String> thrown = Maps.newHashMap();
+
+        for (CodeGeneratorArg codeGenerator : codeGenerators) {
+            try {
+
+                generateSourcesWithOneGenerator(context, codeGenerator);
+
+            } catch (Exception e) {
+                // try other generators, exception will be thrown after
+                getLog().error(
+                        Util.message(
+                                "Unable to generate sources with %s generator",
+                                LOG_PREFIX,
+                                codeGenerator.getCodeGeneratorClass()), e);
+                thrown.put(codeGenerator.getCodeGeneratorClass(), e.getClass()
+                        .getCanonicalName());
+            }
+        }
+
+        if (!thrown.isEmpty()) {
+            String message = Util
+                    .message(
+                            "One or more code generators failed, including failed list(generatorClass=exception) %s",
+                            LOG_PREFIX, thrown.toString());
+            getLog().error(message);
+            throw new MojoFailureException(message);
+        }
+    }
+
+    /**
+     * Instantiate generator from class and call required method
+     */
+    private void generateSourcesWithOneGenerator(SchemaContext context,
+            CodeGeneratorArg codeGenerator) throws ClassNotFoundException,
+            InstantiationException, IllegalAccessException {
+
+        codeGenerator.check();
+
+        CodeGenerator g = Util.getInstance(
+                codeGenerator.getCodeGeneratorClass(), CodeGenerator.class);
+        getLog().info(
+                Util.message("Code generator instantiated from %s", LOG_PREFIX,
+                        codeGenerator.getCodeGeneratorClass()));
+
+        Collection<File> generated = g.generateSources(context,
+                codeGenerator.getOutputBaseDir());
+        getLog().info(
+                Util.message("Sources generated by %s: %s", LOG_PREFIX,
+                        codeGenerator.getCodeGeneratorClass(), generated));
+    }
+
+}
index 7d908c3cd0fb64e5a3632e587183b7d05c7656c9..a8cfdef0f3832d1097b7c6b3b6be9c5362c5ae04 100644 (file)
@@ -8,9 +8,7 @@
                <version>0.5-SNAPSHOT</version>
        </parent>
 
-       <groupId>org.opendaylight.controller</groupId>
        <artifactId>binding-generator</artifactId>
-       <version>0.5-SNAPSHOT</version>
        <packaging>pom</packaging>
        <name>binding-generator</name>
 
                <module>binding-java-api-generator</module>
                <module>maven-sal-api-gen-plugin</module>
        </modules>
-       <dependencies>
-
-               <dependency>
-                       <groupId>junit</groupId>
-                       <artifactId>junit</artifactId>
-                       <scope>test</scope>
-                       <optional>true</optional>
-               </dependency>
-               <dependency>
-                       <groupId>org.slf4j</groupId>
-                       <artifactId>slf4j-api</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.slf4j</groupId>
-                       <artifactId>slf4j-simple</artifactId>
-               </dependency>
-       </dependencies>
        <build>
                <plugins>
                        <plugin>
diff --git a/opendaylight/sal/yang-prototype/code-generator/pom.xml.bak b/opendaylight/sal/yang-prototype/code-generator/pom.xml.bak
new file mode 100644 (file)
index 0000000..0f0d37e
--- /dev/null
@@ -0,0 +1,99 @@
+<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>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>binding-generator</artifactId>
+    <version>0.5-SNAPSHOT</version>
+    <packaging>pom</packaging>
+    <name>binding-generator</name>
+    
+    <properties>
+               <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+       </properties>
+  
+    <modules>
+       <module>../yang</module>
+       <module>../sal/sal-schema-repository-api</module>
+        <module>code-generator-demo</module>
+        <module>yang-model-parser-api</module>
+        <module>yang-model-parser-impl</module>
+        <module>binding-model-api</module>
+        <module>binding-generator-api</module>
+        <module>binding-generator-spi</module>
+        <module>binding-generator-util</module>
+        <module>binding-generator-impl</module>
+        <module>binding-java-api-generator</module>
+        <module>maven-yang</module>
+        <module>yang-maven-plugin</module>
+        <module>yang-maven-plugin-it</module>
+    </modules>
+    <dependencies>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.10</version>
+            <scope>test</scope>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-api</artifactId>
+            <version>1.7.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <version>1.7.2</version>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.0</version>
+                <inherited>true</inherited>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-javadoc-plugin</artifactId>
+                <version>2.8.1</version>
+                <configuration>
+                    <stylesheet>maven</stylesheet>
+                </configuration>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>aggregate</goal>
+                        </goals>
+                        <phase>site</phase>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+    <reporting>
+        <plugins>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>findbugs-maven-plugin</artifactId>
+                <version>2.4.0</version>
+                <configuration>
+                    <effort>Max</effort>
+                    <threshold>Low</threshold>
+                    <goal>site</goal>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.codehaus.mojo</groupId>
+                <artifactId>jdepend-maven-plugin</artifactId>
+                <version>2.0-beta-2</version>
+            </plugin>
+        </plugins>
+    </reporting>
+</project>
index 05981c457868ab24bf31d70e1bcd7b4f3775048e..8ee1bf0f33a51ae643a3829b9eccd1f1f342a2c7 100644 (file)
@@ -31,6 +31,8 @@
                                     </outputBaseDir>
                                 </generator>
                             </codeGenerators>
+                            <resourceProviders>
+                            </resourceProviders>
                         </configuration>
                     </execution>
                 </executions>
@@ -82,7 +84,7 @@
                                                                                yang-maven-plugin
                                                                        </artifactId>
                                                                        <versionRange>
-                                                                               [1.0,)
+                                                                               [0.5,)
                                                                        </versionRange>
                                                                        <goals>
                                                                                <goal>
                </plugins>
         </pluginManagement>
     </build>
+    <dependencies>
+    <dependency>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>yang-binding</artifactId>
+    <version>0.5-SNAPSHOT</version>
+    </dependency>
+    </dependencies>
 </project>
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/src/main/java/Example.java b/opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/src/main/java/Example.java
new file mode 100644 (file)
index 0000000..cc26564
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * 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
+ */
+
+public class Example {
+    
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/src/main/yang/controller-network.yang b/opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/src/main/yang/controller-network.yang
new file mode 100644 (file)
index 0000000..357e6ba
--- /dev/null
@@ -0,0 +1,172 @@
+module controller-network {
+       yang-version 1;
+       namespace "urn:opendaylight:controller:network";
+       prefix "topos";
+       
+       import ietf-inet-types { prefix "inet"; }
+       
+       revision 2013-05-20 {
+          description "Initial demo";
+       }
+       
+
+       
+       
+       typedef topology-id {
+               type string;
+       }
+
+       typedef node-id {
+               type string;
+       }
+
+       typedef link-id {
+               type string;
+       }
+
+       typedef tp-id {
+               type string;
+               description "identifier for termination points on a port";
+       }
+
+       typedef tp-ref {
+               type leafref {
+                       path "/network/topologies/topology/nodes/node/termination-points/termination-point/tp-id";
+               }
+       }
+       typedef topology-ref {
+               type leafref {
+                       path "/network/topologies/topology/topology-id";
+               }
+               description "This type is used for leafs that reference topology identifier instance.";
+               // currently not used
+       }
+
+       typedef node-ref {
+               type leafref {
+                       path "/network/topologies/topology/nodes/node/node-id";
+               }
+               description "This type is used for leafs that reference a node instance.";
+       }
+
+       typedef link-ref {
+               type leafref {
+                       path "/network/topologies/topology/links/link/link-id";
+               }
+               description "This type is used for leafs that reference a link instance.";
+               // currently not used
+       }
+       
+       typedef network-element-ref {
+               type leafref {
+                       path "/network/network-elements/network-element/element-id";
+               }
+       }
+
+
+       typedef element-id {
+               type string;
+       }
+       
+       container network {
+               container topologies {
+                       list 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.
+                               ";
+                               key "topology-id";
+                               leaf topology-id {
+                                       type topology-id; 
+                                       description "
+                                               It is presumed that datastore will contain many topologies. To
+                                               distinguish between topologies it is vital to have UNIQUE
+                                               topology identifier.
+                                       ";
+                               }
+
+                               container types {
+                                       description "
+                                               The container for definition of topology types.
+                                               The augmenting modules should add empty optional leaf 
+                                               to this container to signalize topology type.
+                                       ";
+                               }
+
+                               container nodes {
+                                       list node {
+                                               description "The list of network nodes defined for topology.";
+
+                                               key "node-id";
+                                               leaf node-id {
+                                                       type node-id;
+                                                       description "The Topology identifier of network-node.";
+                                               }
+
+                                               leaf supporting-ne {
+                                                       type network-element-ref;
+                                               }
+                                               
+                                               container termination-points {
+                                                       list termination-point {
+                                                               key "tp-id";
+                                                               leaf tp-id {
+                                                                       type tp-id;
+                                                               }
+                                                       }
+                                               }
+                                       }
+                               }
+               
+                               container links {
+                                       list link {
+                                               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.
+                                               ";
+                                               key "link-id";
+               
+                                               leaf link-id {
+                                                       type link-id;
+                                               }
+                                               container source { 
+                                                       leaf source-node {
+                                                               type node-ref;
+                                                               description "Source node identifier.";
+                                                       }
+                                                       leaf source-tp {
+                                                               type tp-ref;
+                                                       }
+                                               }
+                                               container destination { 
+                                                       leaf dest-node {
+                                                               type node-ref;
+                                                               description "Destination node identifier.";
+                                                       }
+                                                       leaf dest-tp {
+                                                               type tp-ref;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+               container network-elements {
+                       config true;
+                       list network-element {
+                               key "element-id";
+                               leaf element-id {
+                                       type element-id;
+                               }
+                       }
+               }
+       }
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/src/main/yang/controller-openflow.yang b/opendaylight/sal/yang-prototype/code-generator/samples/maven-code-gen-sample/src/main/yang/controller-openflow.yang
new file mode 100644 (file)
index 0000000..62e937e
--- /dev/null
@@ -0,0 +1,79 @@
+module controller-openflow {
+
+    namespace "urn:opendaylight:controller:openflow";
+    prefix "of";
+    import controller-network {prefix cn;}
+    
+    
+    revision 2013-05-20 {
+       description "Initial demo";
+    }
+
+   
+
+
+
+    typedef datapath-id {
+        type string {
+            length 16;
+        }
+    }
+
+
+    augment "/cn:network/cn:topologies/cn:topology/cn:types" {
+        leaf openflow {type string;}
+    }
+
+    augment "/cn:network/cn:topologies/cn:topology/cn:links/cn:link/cn:source" {
+        when "../../../cn:types/of:openflow";
+
+        leaf logical-port {
+            type int32;
+        }
+    }
+
+    augment "/cn:network/cn:topologies/cn:topology/cn:links/cn:link/cn:destination" {
+        when "../../../cn:types/of:openflow";
+
+        leaf logical-port {
+            type int32;
+        }
+    }
+
+    augment "/cn:network/cn:topologies/cn:topology/cn:nodes/cn:node/" {
+        when "../../../cn:types/of:openflow";
+        leaf datapath-id {
+            type datapath-id;
+        }
+    }
+    
+    augment "/cn:network/cn:network-elements/cn:network-element" {
+        leaf datapath-id {
+            type datapath-id;
+        }
+
+        container ports {
+            list port {
+                key "logical-port-id";
+                
+                leaf logical-port-id {
+                    type int32;
+                }
+
+                // Should be replaced with ref to interface
+                leaf physical-name {
+                    type string;
+                }
+            }
+        }
+        container flow-tables {
+            list flow-table {
+                key "flow-table-id";
+                leaf flow-table-id {
+                    type string;
+                }
+
+            }
+        }
+    }
+}
\ No newline at end of file
index 10ba3f2816c4e65778fdad78dae5803ce9f8b045..27ef15e1569cbf7365336184f1bfd63d58904298 100644 (file)
                        <artifactId>antlr4</artifactId>\r
                        <version>4.0</version>\r
                </dependency>\r
-               <dependency>\r
-                       <groupId>org.slf4j</groupId>\r
-                       <artifactId>slf4j-api</artifactId>\r
-                       <version>1.7.2</version>\r
-               </dependency>\r
                <dependency>\r
                        <groupId>org.slf4j</groupId>\r
                        <artifactId>slf4j-simple</artifactId>\r
           <version>14.0.1</version>\r
         </dependency>\r
 \r
+        <dependency>\r
+               <groupId>junit</groupId>\r
+               <artifactId>junit</artifactId>\r
+        </dependency>\r
        </dependencies>\r
        <build>\r
                <plugins>\r
index 569036a1de4886f60de71bc1958d8aa94a061325..41392b0f49fc80195f0064ac349b2ecb94cc81ee 100644 (file)
@@ -123,6 +123,7 @@ public class YangParserImpl implements YangModelParser {
 
     private Map<String, TreeMap<Date, ModuleBuilder>> resolveModuleBuilders(
             final List<InputStream> yangFileStreams) {
+        //Linked Hash Map MUST be used because Linked Hash Map preserves ORDER of items stored in map.
         final Map<String, TreeMap<Date, ModuleBuilder>> modules = new LinkedHashMap<String, TreeMap<Date, ModuleBuilder>>();
         final ParseTreeWalker walker = new ParseTreeWalker();
         final List<ParseTree> trees = parseStreams(yangFileStreams);
@@ -140,7 +141,7 @@ public class YangParserImpl implements YangModelParser {
 
         // module dependency graph sorted
         List<ModuleBuilder> sorted = ModuleDependencySort.sort(builders);
-
+        
         for (ModuleBuilder builder : sorted) {
             final String builderName = builder.getName();
             Date builderRevision = builder.getRevision();
@@ -194,6 +195,8 @@ public class YangParserImpl implements YangModelParser {
         resolveAugments(modules);
 
         // build
+        // Linked Hash Set MUST be used otherwise the Set will not maintain order!
+        // http://docs.oracle.com/javase/6/docs/api/java/util/LinkedHashSet.html
         final Set<Module> result = new LinkedHashSet<Module>();
         for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules
                 .entrySet()) {
@@ -221,7 +224,7 @@ public class YangParserImpl implements YangModelParser {
     /**
      * Search for dirty nodes (node which contains UnknownType) and resolve
      * unknown types.
-     *
+     * 
      * @param modules
      *            all available modules
      * @param module
@@ -543,7 +546,7 @@ public class YangParserImpl implements YangModelParser {
     /**
      * Go through all typedef statements from given module and search for one
      * with given name
-     *
+     * 
      * @param typedefs
      *            typedef statements to search
      * @param name
@@ -572,7 +575,7 @@ public class YangParserImpl implements YangModelParser {
 
     /**
      * Pull restriction from referenced type and add them to given constraints
-     *
+     * 
      * @param referencedType
      * @param constraints
      */
@@ -602,7 +605,7 @@ public class YangParserImpl implements YangModelParser {
     /**
      * Go through all augmentation definitions and resolve them. This method
      * also finds referenced node and add child nodes to it.
-     *
+     * 
      * @param modules
      *            all available modules
      */
@@ -645,7 +648,7 @@ public class YangParserImpl implements YangModelParser {
     }
 
     /**
-     *
+     * 
      * @param modules
      *            all available modules
      * @param module
@@ -727,7 +730,7 @@ public class YangParserImpl implements YangModelParser {
     /**
      * Go through identity statements defined in current module and resolve
      * their 'base' statement if present.
-     *
+     * 
      * @param modules
      *            all modules
      * @param module
@@ -769,7 +772,7 @@ public class YangParserImpl implements YangModelParser {
     /**
      * Go through uses statements defined in current module and resolve their
      * refine statements.
-     *
+     * 
      * @param modules
      *            all modules
      * @param module
@@ -897,7 +900,7 @@ public class YangParserImpl implements YangModelParser {
 
     /**
      * Find original builder of refine node and return copy of this builder.
-     *
+     * 
      * @param groupingPath
      *            path to grouping which contains node to refine
      * @param refine
@@ -943,7 +946,7 @@ public class YangParserImpl implements YangModelParser {
 
     /**
      * Find builder of refine node.
-     *
+     * 
      * @param groupingPath
      *            path to grouping which contains node to refine
      * @param refineNodeName
@@ -1030,7 +1033,7 @@ public class YangParserImpl implements YangModelParser {
 
     /**
      * Find dependent module based on given prefix
-     *
+     * 
      * @param modules
      *            all available modules
      * @param module
index ab64b88b4e01571fb072f8ffc09ac3efe025884b..1ba93ea298e10afed761d20e7f0ce291757d66d8 100644 (file)
                                <artifactId>slf4j-api</artifactId>
                                <version>1.7.2</version>
                        </dependency>
-                       <dependency>
-                               <groupId>org.slf4j</groupId>
-                               <artifactId>slf4j-simple</artifactId>
-                               <version>1.7.2</version>
-                       </dependency>
                </dependencies>
        </dependencyManagement>
        <build>
index 0ac2bbe569b010475810db978d5685de9ebe1d75..4710c9f0e8ccb1e2e9b4c132c870e6a84b4ee014 100644 (file)
@@ -7,9 +7,7 @@
                <version>0.5-SNAPSHOT</version>
        </parent>
 
-       <groupId>org.opendaylight.controller</groupId>
        <artifactId>yang</artifactId>
-       <version>0.5-SNAPSHOT</version>
        <packaging>pom</packaging>
        <modules>
                <module>yang-common</module>
                <module>../code-generator/maven-yang-plugin-it</module>
 
        </modules>
-       <dependencies>
-
-               <dependency>
-                       <groupId>junit</groupId>
-                       <artifactId>junit</artifactId>
-                       <scope>test</scope>
-                       <optional>true</optional>
-               </dependency>
-               <dependency>
-                       <groupId>org.slf4j</groupId>
-                       <artifactId>slf4j-api</artifactId>
-               </dependency>
-               <dependency>
-                       <groupId>org.slf4j</groupId>
-                       <artifactId>slf4j-simple</artifactId>
-               </dependency>
-       </dependencies>
        <build>
                <plugins>
                        <plugin>
diff --git a/opendaylight/sal/yang-prototype/yang/yang-binding/src/main/java/org/opendaylight/controller/yang/binding/Augmentable.java b/opendaylight/sal/yang-prototype/yang/yang-binding/src/main/java/org/opendaylight/controller/yang/binding/Augmentable.java
new file mode 100644 (file)
index 0000000..297e5bc
--- /dev/null
@@ -0,0 +1,6 @@
+package org.opendaylight.controller.yang.binding;
+
+public interface Augmentable<T> {
+
+    <E extends Augmentation<T>> E getAugmentation(Class<E> augmentationType);
+}
diff --git a/opendaylight/sal/yang-prototype/yang/yang-binding/src/main/java/org/opendaylight/controller/yang/binding/Augmentation.java b/opendaylight/sal/yang-prototype/yang/yang-binding/src/main/java/org/opendaylight/controller/yang/binding/Augmentation.java
new file mode 100644 (file)
index 0000000..42574c9
--- /dev/null
@@ -0,0 +1,5 @@
+package org.opendaylight.controller.yang.binding;
+
+public interface Augmentation<T> {
+    
+}
index f296579fcc95936dc0897d1f3254ec2688913480..796c482ddcfe056bd4fa38a664facdeefdfaff9b 100644 (file)
@@ -6,4 +6,11 @@
     <version>0.5-SNAPSHOT</version>\r
   </parent>\r
   <artifactId>yang-common</artifactId>\r
+  <dependencies>\r
+       <dependency>\r
+               <groupId>org.slf4j</groupId>\r
+               <artifactId>slf4j-simple</artifactId>\r
+               <version>1.7.5</version>\r
+       </dependency>\r
+  </dependencies>\r
 </project>
\ No newline at end of file
index b4eaed775c7d6f24f905b51e559888fa9033b674..df111acf0854603d453f1c1bd6cefb40a449d48c 100644 (file)
@@ -15,26 +15,28 @@ import org.opendaylight.controller.yang.model.api.ListSchemaNode;
 public class DataNodeIterator implements Iterator<DataSchemaNode> {
     
     private final DataNodeContainer container;
-    private final List<ListSchemaNode> allLists;
-    private final List<ContainerSchemaNode> allContainers;
-    private final List<LeafSchemaNode> allLeafs;
-    private final List<LeafListSchemaNode> allLeafLists;
-    private final List<DataSchemaNode> allChilds;
+    private List<ListSchemaNode> allLists;
+    private List<ContainerSchemaNode> allContainers;
+    private List<LeafSchemaNode> allLeafs;
+    private List<LeafListSchemaNode> allLeafLists;
+    private List<DataSchemaNode> allChilds;
     
     public DataNodeIterator(final DataNodeContainer container) {
         if (container == null) {
-            throw new IllegalArgumentException("Data Node Container MUST be specified!");
+            throw new IllegalArgumentException("Data Node Container MUST be specified and cannot be NULL!");
         }
         
+        init();
+        this.container = container;
+        traverse(this.container);
+    }
+    
+    private void init() {
         this.allContainers = new ArrayList<ContainerSchemaNode>();
         this.allLists = new ArrayList<ListSchemaNode>();
         this.allLeafs = new ArrayList<LeafSchemaNode>();
         this.allLeafLists = new ArrayList<LeafListSchemaNode>();
         this.allChilds = new ArrayList<DataSchemaNode>();
-        
-        this.container = container;
-        
-        traverse(this.container);
     }
     
     public List<ContainerSchemaNode> allContainers() {
@@ -54,10 +56,10 @@ public class DataNodeIterator implements Iterator<DataSchemaNode> {
     }
     
     private void traverse(final DataNodeContainer dataNode) {
-        if (!containChildDataNodeContainer(dataNode)) {
+        if (dataNode == null) {
             return;
         }
-
+        
         final Set<DataSchemaNode> childs = dataNode.getChildNodes();
         if (childs != null) {
             for (DataSchemaNode childNode : childs) {
@@ -81,33 +83,9 @@ public class DataNodeIterator implements Iterator<DataSchemaNode> {
                     allLeafLists.add(leafList);
                 }
             }
+            return;
         }
     }
-
-    /**
-     * Returns <code>true</code> if and only if the child node contain at least
-     * one child container schema node or child list schema node, otherwise will
-     * always returns <code>false</code>
-     * 
-     * @param container
-     * @return <code>true</code> if and only if the child node contain at least
-     *         one child container schema node or child list schema node,
-     *         otherwise will always returns <code>false</code>
-     */
-    private boolean containChildDataNodeContainer(
-            final DataNodeContainer container) {
-        if (container != null) {
-            final Set<DataSchemaNode> childs = container.getChildNodes();
-            if ((childs != null) && (childs.size() > 0)) {
-                for (final DataSchemaNode childNode : childs) {
-                    if (childNode instanceof DataNodeContainer) {
-                        return true;
-                    }
-                }
-            }
-        }
-        return false;
-    }
     
     @Override
     public boolean hasNext() {
index 8554f682198f73c95f78eb3f5cdf413131e4e2f9..39865a9ddf4e00eb3a9977687dfdfaa6411a7484 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.controller.yang.model.util;
 
+import java.net.URI;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Queue;
@@ -26,42 +27,35 @@ import org.opendaylight.controller.yang.model.api.SchemaPath;
 
 public final class SchemaContextUtil {
 
-    private final SchemaContext context;
+    private SchemaContextUtil() {}
 
-    public SchemaContextUtil(final SchemaContext context) {
-        this.context = context;
-    }
-    
-    public SchemaContext getContext() {
-        return context;
-    }
-    
-    public DataSchemaNode findDataSchemaNode(final SchemaPath schemaPath) {
+    public static DataSchemaNode findDataSchemaNode(final SchemaContext context, final SchemaPath schemaPath) {
         if (schemaPath != null) {
-            final Module module = resolveModuleFromSchemaPath(schemaPath);
-            final Queue<String> prefixedPath = schemaPathToQueuedPath(schemaPath);
-            
+            final Module module = resolveModuleFromSchemaPath(context, schemaPath);
+            final Queue<QName> prefixedPath = new LinkedList<QName>(schemaPath.getPath()); 
+
             if ((module != null) && (prefixedPath != null)) {
-                return findSchemaNodeForGivenPath(module, prefixedPath);
+                return findSchemaNodeForGivenPath(context, module, prefixedPath);
             }
         }
         return null;
     }
-    
-    public DataSchemaNode findDataSchemaNode(final Module module,
+
+    public static DataSchemaNode findDataSchemaNode(final SchemaContext context, final Module module,
             final RevisionAwareXPath nonCondXPath) {
         if (nonCondXPath != null) {
             final String strXPath = nonCondXPath.toString();
 
             if (strXPath != null) {
                 if (strXPath.matches(".*//[.* | .*//].*")) {
-                    // TODO: function to escape conditions in path   
+                    // TODO: function to escape conditions in path
                 }
                 if (nonCondXPath.isAbsolute()) {
-                    final Queue<String> queuedPath = xpathToQueuedPath(strXPath);
-                    if (queuedPath != null) {
-                        final DataSchemaNode dataNode = findSchemaNodeForGivenPath(
-                                module, queuedPath);
+                    final Queue<QName> qnamedPath = xpathToQNamePath(context, module,
+                            strXPath);
+                    if (qnamedPath != null) {
+                        final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context, 
+                                module, qnamedPath);
                         return dataNode;
                     }
                 }
@@ -70,7 +64,7 @@ public final class SchemaContextUtil {
         return null;
     }
 
-    public DataSchemaNode findDataSchemaNodeForRelativeXPath(
+    public static DataSchemaNode findDataSchemaNodeForRelativeXPath(final SchemaContext context, 
             final Module module, final SchemaNode actualSchemaNode,
             final RevisionAwareXPath relativeXPath) {
         if ((actualSchemaNode != null) && (relativeXPath != null)
@@ -78,12 +72,12 @@ public final class SchemaContextUtil {
 
             final SchemaPath actualNodePath = actualSchemaNode.getPath();
             if (actualNodePath != null) {
-                final Queue<String> queuedPath = resolveRelativeXPath(
+                final Queue<QName> qnamePath = resolveRelativeXPath(context, module, 
                         relativeXPath, actualNodePath);
 
-                if (queuedPath != null) {
-                    final DataSchemaNode dataNode = findSchemaNodeForGivenPath(
-                            module, queuedPath);
+                if (qnamePath != null) {
+                    final DataSchemaNode dataNode = findSchemaNodeForGivenPath(context, 
+                            module, qnamePath);
                     return dataNode;
                 }
             }
@@ -91,148 +85,138 @@ public final class SchemaContextUtil {
 
         return null;
     }
-    
-    public Module resolveModuleFromSchemaPath(final SchemaPath schemaPath) {
+
+    public static Module resolveModuleFromSchemaPath(final SchemaContext context, final SchemaPath schemaPath) {
         if ((schemaPath != null) && (schemaPath.getPath() != null)) {
             final QName qname = schemaPath.getPath().get(0);
 
             if ((qname != null) && (qname.getNamespace() != null)) {
-                return context
-                        .findModuleByNamespace(qname.getNamespace());
+                return context.findModuleByNamespace(qname.getNamespace());
             }
         }
         return null;
     }
-    
-    /**
-     * Search which starts from root of Module.
-     * 
-     * @param module
-     * @param prefixedPath
-     * @return
-     */
-    private DataSchemaNode findSchemaNodeForGivenPath(final Module module,
-            final Queue<String> prefixedPath) {
-        if ((module != null) && (prefixedPath != null)) {
-            DataNodeContainer nextContainer = module;
-            final String modulePrefix = module.getPrefix();
 
-            String childNodeName = null;
-            DataSchemaNode schemaNode = null;
-            while ((nextContainer != null) && (prefixedPath.size() > 0)) {
-                childNodeName = prefixedPath.poll();
-                if (childNodeName.contains(":")) {
-                    final String[] prefixedChildNode = childNodeName.split(":");
-                    if ((modulePrefix != null)
-                            && modulePrefix.equals(prefixedChildNode[0])) {
+    public static Module findParentModule(final SchemaContext context, final SchemaNode schemaNode) {
+        if (context == null) {
+            throw new IllegalArgumentException("Schema Context reference cannot be NULL!");
+        }
+        if (schemaNode == null) {
+            throw new IllegalArgumentException("Schema Node cannot be NULL!");
+        }
 
-                        childNodeName = prefixedChildNode[1];
-                    } else {
-                        final Module nextModule = resolveModuleForPrefix(
-                                prefixedChildNode[0], module);
-                        final Queue<String> nextModulePrefixedPath = new LinkedList<String>();
-                        nextModulePrefixedPath.add(childNodeName);
-                        nextModulePrefixedPath.addAll(prefixedPath);
-                        prefixedPath.clear();
+        final SchemaPath schemaPath = schemaNode.getPath();
+        if (schemaPath == null) {
+            throw new IllegalStateException("Schema Path for Schema Node is not " +
+                    "set properly (Schema Path is NULL)");
+        }
+        final List<QName> qnamedPath = schemaPath.getPath();
+        if (qnamedPath == null || qnamedPath.isEmpty()) {
+            throw new IllegalStateException("Schema Path contains invalid state of path parts." +
+                    "The Schema Path MUST contain at least ONE QName which defines namespace and Local name" +
+                    "of path.");
+        }
+        final QName qname = qnamedPath.get(0);
+        return context.findModuleByNamespace(qname.getNamespace());
+    }
 
-                        schemaNode = findSchemaNodeForGivenPath(nextModule,
-                                nextModulePrefixedPath);
+    private static DataSchemaNode findSchemaNodeForGivenPath(final SchemaContext context, final Module module,
+            final Queue<QName> qnamedPath) {
+        if ((module != null) && (module.getNamespace() != null)
+                && (qnamedPath != null)) {
+            DataNodeContainer nextNode = module;
+            final URI moduleNamespace = module.getNamespace();
 
+            QName childNodeQName = null;
+            DataSchemaNode schemaNode = null;
+            while ((nextNode != null) && !qnamedPath.isEmpty()) {
+                childNodeQName = qnamedPath.peek();
+                if (childNodeQName != null) {
+                    final URI childNodeNamespace = childNodeQName.getNamespace();
+                    
+                    schemaNode = nextNode.getDataChildByName(childNodeQName);
+                    if (schemaNode != null) {
+                        if (schemaNode instanceof ContainerSchemaNode) {
+                            nextNode = (ContainerSchemaNode) schemaNode;
+                        } else if (schemaNode instanceof ListSchemaNode) {
+                            nextNode = (ListSchemaNode) schemaNode;
+                        } else {
+                            nextNode = null;
+                        }
+                    } else if (!childNodeNamespace.equals(moduleNamespace)) {
+                        final Module nextModule = context
+                                .findModuleByNamespace(childNodeNamespace);
+                        schemaNode = findSchemaNodeForGivenPath(context, nextModule,
+                                qnamedPath);
                         return schemaNode;
                     }
-                }
-
-                schemaNode = nextContainer.getDataChildByName(childNodeName);
-                if (schemaNode instanceof ContainerSchemaNode) {
-                    nextContainer = (ContainerSchemaNode) schemaNode;
-                } else if (schemaNode instanceof ListSchemaNode) {
-                    nextContainer = (ListSchemaNode) schemaNode;
-                } else {
-                    return schemaNode;
+                    qnamedPath.poll();
                 }
             }
+            return schemaNode;
         }
         return null;
     }
 
-    private Module resolveModuleForPrefix(final String prefix,
-            final Module parent) {
-        if ((prefix != null) && (parent != null)) {
-            final Set<ModuleImport> imports = parent.getImports();
+    private static Queue<QName> xpathToQNamePath(final SchemaContext context, final Module parentModule,
+            final String xpath) {
+        final Queue<QName> path = new LinkedList<QName>();
+        if (xpath != null) {
+            final String[] prefixedPath = xpath.split("/");
 
-            if (imports != null) {
-                for (final ModuleImport impModule : imports) {
-                    final String impModPrefix = impModule.getPrefix();
-                    if ((impModPrefix != null) && prefix.equals(impModPrefix)) {
-                        return resolveModuleFromContext(prefix,
-                                impModule.getModuleName());
-                    }
+            for (int i = 0; i < prefixedPath.length; ++i) {
+                if (!prefixedPath[i].isEmpty()) {
+                    path.add(stringPathPartToQName(context, parentModule, prefixedPath[i]));
                 }
             }
         }
-        return null;
+        return path;
     }
 
-    private Module resolveModuleFromContext(final String prefix,
-            final String moduleName) {
-        final Set<Module> modules = context.getModules();
-
-        if ((prefix != null) && (moduleName != null) && (modules != null)) {
-            for (Module module : modules) {
-                if ((module != null) && prefix.equals(module.getPrefix())
-                        && moduleName.equals(module.getName())) {
-                    return module;
+    private static QName stringPathPartToQName(final SchemaContext context, final Module parentModule,
+            final String prefixedPathPart) {
+        if (parentModule != null && prefixedPathPart != null) {
+            if (prefixedPathPart.contains(":")) {
+                final String[] prefixedName = prefixedPathPart.split(":");
+                final Module module = resolveModuleForPrefix(context, parentModule,
+                        prefixedName[0]);
+                if (module != null) {
+                    return new QName(module.getNamespace(), module
+                            .getRevision(), prefixedName[1]);
                 }
+            } else {
+                return new QName(parentModule.getNamespace(),
+                        parentModule.getRevision(), prefixedPathPart);
             }
         }
         return null;
     }
 
-    private Queue<String> xpathToQueuedPath(final String xpath) {
-        final Queue<String> retQueue = new LinkedList<String>();
-        if ((xpath != null)) {
-            final String[] prefixedPath = xpath.split("/");
-
-            if (prefixedPath != null) {
-                for (int i = 0; i < prefixedPath.length; ++i) {
-                    if (!prefixedPath[i].isEmpty()) {
-                        retQueue.add(prefixedPath[i]);
-                    }
-                }
+    private static Module resolveModuleForPrefix(final SchemaContext context, final Module module,
+            final String prefix) {
+        if ((module != null) && (prefix != null)) {
+            if (prefix.equals(module.getPrefix())) {
+                return module;
             }
-        }
-        return retQueue;
-    }
-    
-    private Queue<String> schemaPathToQueuedPath(final SchemaPath schemaPath) {
-        final Queue<String> retQueue = new LinkedList<String>();
-        if ((schemaPath != null) && (schemaPath.getPath() != null)) {
-            final List<QName> listPath = schemaPath.getPath();
-            
-            for (final QName qname : listPath) {
-                if (qname != null) {
-                    final String prefix = qname.getPrefix();
-                    final String localName = qname.getLocalName();
-                    
-                    final StringBuilder builder = new StringBuilder();
-                    if (prefix != null) {
-                        builder.append(prefix);
-                        builder.append(":");
-                    }
-                    builder.append(localName);
-                    retQueue.add(builder.toString());
+
+            final Set<ModuleImport> imports = module.getImports();
+
+            for (final ModuleImport mi : imports) {
+                if (prefix.equals(mi.getPrefix())) {
+                    return context.findModuleByName(mi.getModuleName(),
+                            mi.getRevision());
                 }
             }
         }
-        return retQueue;
+        return null;
     }
-    
-    private Queue<String> resolveRelativeXPath(
+
+    private static Queue<QName> resolveRelativeXPath(final SchemaContext context, final Module module,
             final RevisionAwareXPath relativeXPath,
             final SchemaPath leafrefSchemaPath) {
-        final Queue<String> absolutePath = new LinkedList<String>();
+        final Queue<QName> absolutePath = new LinkedList<QName>();
 
-        if ((relativeXPath != null) && !relativeXPath.isAbsolute()
+        if ((module != null) && (relativeXPath != null) && !relativeXPath.isAbsolute()
                 && (leafrefSchemaPath != null)) {
             final String strXPath = relativeXPath.toString();
             if (strXPath != null) {
@@ -247,10 +231,10 @@ public final class SchemaContextUtil {
                     if (path != null) {
                         int lenght = path.size() - colCount;
                         for (int i = 0; i < lenght; ++i) {
-                            absolutePath.add(path.get(i).getLocalName());
+                            absolutePath.add(path.get(i));
                         }
                         for (int i = colCount; i < xpaths.length; ++i) {
-                            absolutePath.add(xpaths[i]);
+                            absolutePath.add(stringPathPartToQName(context, module, xpaths[i]));
                         }
                     }
                 }