Merge from development repository. 71/71/2
authorTony Tkacik <ttkacik@cisco.com>
Mon, 25 Mar 2013 13:25:07 +0000 (14:25 +0100)
committerTony Tkacik <ttkacik@cisco.com>
Mon, 25 Mar 2013 14:56:50 +0000 (15:56 +0100)
See commit log bellow for more details.

    commit d3f7ff74377f55c106ca28a43c936ef4d3bcb5e2
    Author: mvitez <mvitez@cisco.com>
    Date:   Mon Mar 25 10:15:36 2013 +0100

        improve some code

    commit a0bec74e277e7afcc0f6867ba2d7527d4e25db60
    Author: mvitez <mvitez@cisco.com>
    Date:   Mon Mar 25 09:26:59 2013 +0100

        added typedef and augment resolving, added tests

    commit 32fff33187321463bb27b5c11b63a71d8dbc104e
    Merge: 562dbeb e6b3057
    Author: lsedlak <lsedlak@cisco.com>
    Date:   Fri Mar 22 15:27:59 2013 +0100

        Merge branch 'binding-api'

    commit e6b30574b2598c289ea90be6588151dc7cb7b0fa
    Author: lsedlak <lsedlak@cisco.com>
    Date:   Fri Mar 22 15:16:12 2013 +0100

        Added Implementation of getPathStatement into Identityref.java;

    commit ef70678b2127fd56d062d99a20a02de401262b29
    Author: lsedlak <lsedlak@cisco.com>
    Date:   Fri Mar 22 15:14:28 2013 +0100

        Added RevisionAwareXPath into interface definition;

    commit 78cb3c64716f7cf2788dfaf61906a07481bcd9df
    Author: mvitez <mvitez@cisco.com>
    Date:   Fri Mar 22 13:40:05 2013 +0100

        added implementation of SchemaContext

    commit 45769c7721eb9832cd43c04a020f1ca7f52172ef
    Author: lsedlak <lsedlak@cisco.com>
    Date:   Fri Mar 22 13:55:26 2013 +0100

        Changed parameter in generateTypes from Module to SchemaContext;
        Implemented changes in generatedTypes in BindingGeneratorImpl.java;
        Implemented changes in GeneratedTypesTest.java;

    commit 562dbebbbbfec341c98885ad80b87f3d8d05c3f7
    Author: mvitez <mvitez@cisco.com>
    Date:   Fri Mar 22 13:40:05 2013 +0100

        added implementation of SchemaContext

    commit c4ea91257946fa1f3cd44a148af7a44e254b661f
    Author: lsedlak <lsedlak@cisco.com>
    Date:   Fri Mar 22 11:09:50 2013 +0100

        Added definition: getExtensions into SchemaContext.java;

    commit 8b239e3fb4a322baa36867d4ce41f2c142a8ef76
    Author: mvitez <mvitez@cisco.com>
    Date:   Fri Mar 22 10:46:27 2013 +0100

        fix Demo, GeneratedTypesTest

    commit 6564270ea304905ccb91718066c7aa65b5430ecb
    Author: mvitez <mvitez@cisco.com>
    Date:   Fri Mar 22 10:33:26 2013 +0100

        rename packages

    commit f3326c65f7de3ce77137b0c972aff32aa5d6f6c6
    Author: mvitez <mvitez@cisco.com>
    Date:   Thu Mar 21 17:45:24 2013 +0100

        renamed YangModelParserImpl-> YangModelParserListenerImpl

    commit 26fa647a676f9c466a010536e9d972486adbb904
    Author: Anton Tkacik <ttkacik@cisco.com>
    Date:   Thu Mar 21 15:49:55 2013 +0100

        Added SAL Binding SPI

    commit e60fb750ef193d8456cb1196b4d13f12f44ad276
    Author: lsedlak <lsedlak@cisco.com>
    Date:   Thu Mar 21 17:27:05 2013 +0100

        Added yang-model-parser-api module into pom definition;

    commit c7023e3f2ae7defeadba319c40011ed4f90bfb4f
    Author: Anton Tkacik <ttkacik@cisco.com>
    Date:   Thu Mar 21 11:22:50 2013 +0100

        Renamed Controller architecture to OpenDayLightController SAL

    commit 985d3e66977876be83db6cba92753ef3ade3edf2
    Merge: 9c9c027 39c8c01
    Author: mvitez <mvitez@cisco.com>
    Date:   Thu Mar 21 15:31:53 2013 +0100

        more progress on yang java model

    commit 9c9c0271a4b7b35177164e94e1677dabecd88ca8
    Author: mvitez <mvitez@cisco.com>
    Date:   Thu Mar 21 13:58:59 2013 +0100

        more progress on yang java model

    commit 5609186d6b22a89f8d0568962bb8d0657818cee4
    Merge: c26cf1d 5adfb70
    Author: mvitez <mvitez@cisco.com>
    Date:   Wed Mar 20 18:14:34 2013 +0100

        getExtensionSchemaNodes changed to getUnknownSchemaNodes;
        Whole package org.opendaylight.controller.model.parser.builder
        refactored accordingly;

    commit 820716ed377f4a7878a1f6373095053eb4ababd0
    Author: mvitez <mvitez@cisco.com>
    Date:   Thu Mar 21 10:04:44 2013 +0100

        added equals, hashCode

    commit c26cf1d917811ab0d5473342d253314f62d6e0a1
    Author: mvitez <mvitez@cisco.com>
    Date:   Wed Mar 20 18:13:56 2013 +0100

        more progress on yang java model

    commit 32e3b9dbef20ab6d8e40d9eded3c452a7f23fdc2
    Author: mvitez <mvitez@cisco.com>
    Date:   Wed Mar 20 15:44:10 2013 +0100

        Changed getLengthConstraint to getLengthConstraints and
        changed return value from LengthConstraint to Set of LengthConstraints;
        Updated BinaryType implementation accordingly;

    commit e8419305c2b7b3197734c8d89d77be25f2d78440
    Author: mvitez <mvitez@cisco.com>
    Date:   Wed Mar 20 15:44:10 2013 +0100

        more progress on yang java model

    commit 6b0283f178366831306456d59431b5747f6c038b
    Author: mvitez <mvitez@cisco.com>
    Date:   Wed Mar 20 12:08:31 2013 +0100

        Added method definitions for RevisionAwareXPath interface;

    commit 463884e9e9e21ff03a3b89b590d0b08d9dd2d9b7
    Author: mvitez <mvitez@cisco.com>
    Date:   Wed Mar 20 12:08:31 2013 +0100

        rework augment parsing

    commit b2fe0c91d7cf184252e2516ad15cdd50e01130a7
    Author: mvitez <mvitez@cisco.com>
    Date:   Tue Mar 19 18:18:28 2013 +0100

        fix test

    commit cd388c2f7fd0460ca068270035ab0acdaa9e5e79
    Author: mvitez <mvitez@cisco.com>
    Date:   Tue Mar 19 18:16:33 2013 +0100

        more progress on yang java model

    commit 638c43548ca83c739131118a404c7b1d454055db
    Merge: 2b0fb2c 36f2f95
    Author: mvitez <mvitez@cisco.com>
    Date:   Tue Mar 19 15:21:27 2013 +0100

        GeneratedType changed to Type in return value of
        generateTypes method;
        Implemented composite key resolving through GeneratedTOBuilder;
        Added test cases for composite key generation;
        Added list-composite-key.yang file for testing purposes;

Change-Id: I9145a87945cc4638ff454f268eb37dd1bf8b3142
Signed-off-by: Tony Tkacik <ttkacik@cisco.com>
122 files changed:
opendaylight/sal/yang-prototype/code-generator/binding-generator-api/src/main/java/org/opendaylight/controller/sal/binding/generator/api/BindingGenerator.java
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/test/java/org/opendaylight/controller/sal/binding/yang/types/test/GeneratedTypesTest.java
opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/list-composite-key.yang [new file with mode: 0644]
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/type/builder/MethodSignatureBuilder.java
opendaylight/sal/yang-prototype/code-generator/binding-model-api/src/main/java/org/opendaylight/controller/sal/binding/model/api/type/builder/package-info.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/Demo.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-api/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-api/src/main/java/org/opendaylight/controller/yang/model/parser/api/YangModelParser.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-api/src/main/java/org/opendaylight/controller/yang/model/parser/api/package-info.java [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/antlrv4/code/gen/YangLexer.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/antlrv4/code/gen/YangParser.java
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/AugmentationSchemaBuilderImpl.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/ContainerSchemaNodeBuilder.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/DeviationBuilder.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/FeatureBuilder.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/GroupingBuilderImpl.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/LeafListSchemaNodeBuilder.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/LeafSchemaNodeBuilder.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/ListSchemaNodeBuilder.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/ModuleBuilder.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/MustDefinitionBuilder.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/NotificationBuilder.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/TypedefBuilder.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/UsesNodeBuilderImpl.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/YangModelBuilder.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/util/YangModelBuilderHelper.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/AbstractChildNodeBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/AbstractChildNodeBuilder.java with 92% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/AugmentationSchemaBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/AugmentationSchemaBuilder.java with 82% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/AugmentationTargetBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/AugmentationTargetBuilder.java with 89% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/Builder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/Builder.java with 86% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/ChildNodeBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/ChildNodeBuilder.java with 85% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/DataSchemaNodeBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/DataSchemaNodeBuilder.java with 58% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/GroupingBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/GroupingBuilder.java with 88% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/SchemaNodeBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/SchemaNodeBuilder.java with 90% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/TypeAwareBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/TypeAwareBuilder.java with 89% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/TypeDefinitionAwareBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/TypeDefinitionAwareBuilder.java with 89% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/TypeDefinitionBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/TypeDefinitionBuilder.java with 86% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/api/UsesNodeBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/api/UsesNodeBuilder.java with 75% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/AugmentationSchemaBuilderImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ConstraintsBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ContainerSchemaNodeBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/DeviationBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ExtensionBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/FeatureBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/GroupingBuilderImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafListSchemaNodeBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafSchemaNodeBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ListSchemaNodeBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ModuleBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/NotificationBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/RpcDefinitionBuilder.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/RpcDefinitionBuilder.java with 61% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/TypedefBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UnknownSchemaNodeBuilder.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UsesNodeBuilderImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserListenerImpl.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/impl/YangModelParserImpl.java with 63% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/YangModelBuilderUtil.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/builder/ContainerSchemaNodeBuilderTest.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/builder/LeafListSchemaNodeBuilderTest.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/builder/ListSchemaNodeBuilderTest.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/impl/YangModelParserTest.java [deleted file]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/ContainerSchemaNodeBuilderTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafListSchemaNodeBuilderTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafSchemaNodeBuilderTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/ListSchemaNodeBuilderTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/TestUtils.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/builder/TestUtils.java with 53% similarity]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/YangModelBuilderTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserListenerTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserTest.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile1.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile2.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/test-model.yang [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/pom.xml
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareBroker.java
opendaylight/sal/yang-prototype/sal/sal-binding-api/src/main/java/org/opendaylight/controller/sal/binding/api/BindingAwareProvider.java
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/pom.xml
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingBrokerImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationInvoker.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationModule.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/package-info.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-spi/pom.xml [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/Mapper.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/MappingProvider.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/SALBindingModule.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/sal/sal-broker-impl/src/main/java/org/opendaylight/controller/sal/core/impl/ConsumerSessionImpl.java
opendaylight/sal/yang-prototype/sal/sal-broker-impl/src/main/java/org/opendaylight/controller/sal/core/impl/rpc/RpcModule.java
opendaylight/sal/yang-prototype/sal/sal-core-api/src/main/java/org/opendaylight/controller/sal/core/api/Broker.java
opendaylight/sal/yang-prototype/sal/sal-core-demo/pom.xml
opendaylight/sal/yang-prototype/yang/yang-binding/src/main/java/org/opendaylight/controller/yang/binding/DataObject.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/yang/yang-binding/src/main/java/org/opendaylight/controller/yang/binding/Notification.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/model/api/type/BinaryTypeDefinition.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/model/api/type/IdentityrefTypeDefinition.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/ContainerSchemaNode.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/Deviation.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/LeafListSchemaNode.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/LeafSchemaNode.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/Module.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/RevisionAwareXPath.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/SchemaContext.java [moved from opendaylight/sal/yang-prototype/sal/sal-schema-repository-api/src/main/java/org/opendaylight/controller/sal/schema/api/SchemaContext.java with 61% similarity]
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/SchemaNode.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/Status.java
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/UnknownSchemaNode.java [moved from opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/MustAwareBuilder.java with 51% similarity]
opendaylight/sal/yang-prototype/yang/yang-model-api/src/main/java/org/opendaylight/controller/yang/model/api/UsesNode.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/AbstractInteger.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BinaryType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BitsType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/BooleanType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Decimal64.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/EnumerationType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/ExtendedType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/IdentityType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Identityref.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/InstanceIdentifier.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/Leafref.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/RevisionAwareXPathImpl.java [new file with mode: 0644]
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/StringType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/UnknownType.java
opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/YangTypesConverter.java

index 686f36413241f5d0800933384b7644a0a8b91140..bed7989074c7da7cff666b55d4afbb54f620e910 100644 (file)
@@ -9,11 +9,11 @@ package org.opendaylight.controller.sal.binding.generator.api;
 \r
 import java.util.List;\r
 \r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedType;\r
-import org.opendaylight.controller.yang.model.api.Module;\r
+import org.opendaylight.controller.sal.binding.model.api.Type;\r
+import org.opendaylight.controller.yang.model.api.SchemaContext;\r
 \r
 public interface BindingGenerator {\r
 \r
-    public List<GeneratedType> generateTypes(final Module module);\r
+    public List<Type> generateTypes(final SchemaContext context);\r
 \r
 }\r
index d346352350cf86c8db14e82c384f8ce132f827f5..343d9ef0e597f53e7de27065d17b05b1cf9f423b 100644 (file)
@@ -8,8 +8,6 @@
 package org.opendaylight.controller.sal.binding.generator.impl;
 
 import java.net.URI;
-import java.text.DateFormat;
-import java.text.SimpleDateFormat;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.GregorianCalendar;
@@ -22,8 +20,11 @@ import org.opendaylight.controller.binding.generator.util.CodeGeneratorHelper;
 import org.opendaylight.controller.binding.generator.util.Types;
 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
 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.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.yang.types.TypeProviderImpl;
@@ -35,15 +36,13 @@ 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.SchemaContext;
 import org.opendaylight.controller.yang.model.api.SchemaPath;
 import org.opendaylight.controller.yang.model.api.TypeDefinition;
 
 public class BindingGeneratorImpl implements BindingGenerator {
 
-    private static DateFormat simpleDateFormat = new SimpleDateFormat(
-            "yyyy-MM-dd");
     private static Calendar calendar = new GregorianCalendar();
-
     private final Map<String, Map<String, GeneratedTypeBuilder>> genTypeBuilders;
     private final List<ContainerSchemaNode> schemaContainers;
     private final List<ListSchemaNode> schemaLists;
@@ -63,22 +62,30 @@ public class BindingGeneratorImpl implements BindingGenerator {
     }
 
     @Override
-    public List<GeneratedType> generateTypes(final Module module) {
-        final List<GeneratedType> genTypes = new ArrayList<GeneratedType>();
-
-        basePackageName = resolveBasePackageName(module.getNamespace(),
-                module.getYangVersion());
-
-        traverseModule(module);
-        if (schemaContainers.size() > 0) {
-            for (final ContainerSchemaNode container : schemaContainers) {
-                genTypes.add(containerToGenType(container));
-            }
-        }
+    public List<Type> generateTypes(final SchemaContext context) {
+        final List<Type> genTypes = new ArrayList<Type>();
+        
+        if (context != null) {
+            final Set<Module> modules = context.getModules();
+            
+            if (modules != null) {
+                for (final Module module : modules) {
+                    basePackageName = resolveBasePackageName(module.getNamespace(),
+                            module.getYangVersion());
+
+                    traverseModule(module);
+                    if (schemaContainers.size() > 0) {
+                        for (final ContainerSchemaNode container : schemaContainers) {
+                            genTypes.add(containerToGenType(container));
+                        }
+                    }
 
-        if (schemaLists.size() > 0) {
-            for (final ListSchemaNode list : schemaLists) {
-                genTypes.add(listToGenType(list));
+                    if (schemaLists.size() > 0) {
+                        for (final ListSchemaNode list : schemaLists) {
+                            genTypes.addAll(listToGenType(list));
+                        }
+                    }
+                }
             }
         }
 
@@ -113,7 +120,8 @@ public class BindingGeneratorImpl implements BindingGenerator {
 
         for (final DataSchemaNode node : schemaNodes) {
             if (node instanceof LeafSchemaNode) {
-                resolveLeafSchemaNode(typeBuilder, (LeafSchemaNode) node);
+                resolveLeafSchemaNodeAsMethod(typeBuilder,
+                        (LeafSchemaNode) node);
             } else if (node instanceof LeafListSchemaNode) {
                 resolveLeafListSchemaNode(typeBuilder,
                         (LeafListSchemaNode) node);
@@ -128,23 +136,23 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return typeBuilder.toInstance();
     }
 
-    private boolean resolveLeafSchemaNode(
-            final GeneratedTypeBuilder typeBuilder, final LeafSchemaNode node) {
-        if ((node != null) && (typeBuilder != null)) {
-            final String nodeName = node.getQName().getLocalName();
-            String nodeDesc = node.getDescription();
-            if (nodeDesc == null) {
-                nodeDesc = "";
+    private boolean resolveLeafSchemaNodeAsMethod(
+            final GeneratedTypeBuilder typeBuilder, final LeafSchemaNode leaf) {
+        if ((leaf != null) && (typeBuilder != null)) {
+            final String leafName = leaf.getQName().getLocalName();
+            String leafDesc = leaf.getDescription();
+            if (leafDesc == null) {
+                leafDesc = "";
             }
 
-            if (nodeName != null) {
-                final TypeDefinition<?> typeDef = node.getType();
+            if (leafName != null) {
+                final TypeDefinition<?> typeDef = leaf.getType();
                 final Type javaType = typeProvider
                         .javaTypeForSchemaDefinitionType(typeDef);
 
-                constructGetter(typeBuilder, nodeName, nodeDesc, javaType);
-                if (!node.isConfiguration()) {
-                    constructSetter(typeBuilder, nodeName, nodeDesc, javaType);
+                constructGetter(typeBuilder, leafName, leafDesc, javaType);
+                if (!leaf.isConfiguration()) {
+                    constructSetter(typeBuilder, leafName, leafDesc, javaType);
                 }
                 return true;
             }
@@ -152,6 +160,39 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return false;
     }
 
+    private boolean resolveLeafSchemaNodeAsProperty(
+            final GeneratedTOBuilder toBuilder, final LeafSchemaNode leaf,
+            boolean isReadOnly) {
+        if ((leaf != null) && (toBuilder != null)) {
+            final String leafName = leaf.getQName().getLocalName();
+            String leafDesc = leaf.getDescription();
+            if (leafDesc == null) {
+                leafDesc = "";
+            }
+
+            if (leafName != null) {
+                final TypeDefinition<?> typeDef = leaf.getType();
+                final Type javaType = typeProvider
+                        .javaTypeForSchemaDefinitionType(typeDef);
+
+                final GeneratedPropertyBuilder propBuilder = toBuilder
+                        .addProperty(CodeGeneratorHelper
+                                .parseToClassName(leafName));
+
+                propBuilder.setReadOnly(isReadOnly);
+                propBuilder.addReturnType(javaType);
+                propBuilder.addComment(leafDesc);
+
+                toBuilder.addEqualsIdentity(propBuilder);
+                toBuilder.addHashIdentity(propBuilder);
+                toBuilder.addToStringProperty(propBuilder);
+
+                return true;
+            }
+        }
+        return false;
+    }
+
     private boolean resolveLeafListSchemaNode(
             final GeneratedTypeBuilder typeBuilder,
             final LeafListSchemaNode node) {
@@ -316,16 +357,27 @@ public class BindingGeneratorImpl implements BindingGenerator {
         return packageNameBuilder.toString();
     }
 
-    private GeneratedType listToGenType(ListSchemaNode list) {
+    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);
+        }
 
         final Set<DataSchemaNode> schemaNodes = list.getChildNodes();
         for (final DataSchemaNode node : schemaNodes) {
+
             if (node instanceof LeafSchemaNode) {
-                resolveLeafSchemaNode(typeBuilder, (LeafSchemaNode) node);
+                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);
@@ -336,7 +388,59 @@ public class BindingGeneratorImpl implements BindingGenerator {
                 resolveListSchemaNode(typeBuilder, (ListSchemaNode) node);
             }
         }
-        return typeBuilder.toInstance();
+
+        final List<Type> genTypes = new ArrayList<Type>();
+        if (genTOBuilder != null) {
+            final GeneratedTransferObject genTO = genTOBuilder.toInstance();
+            constructGetter(typeBuilder, genTO.getName(), "Returns Primary Key of Yang List Type", genTO);
+            genTypes.add(genTO);
+        }
+        genTypes.add(typeBuilder.toInstance());
+        return genTypes;
+    }
+
+    /**
+     * @param list
+     * @return
+     */
+    private GeneratedTOBuilder resolveListKey(final ListSchemaNode list) {
+        final String packageName = resolveGeneratedTypePackageName(list
+                .getPath());
+        final String listName = list.getQName().getLocalName() + "Key";
+
+        if ((packageName != null) && (list != null) && (listName != null)) {
+            final String genTOName = CodeGeneratorHelper
+                    .parseToClassName(listName);
+            final GeneratedTOBuilder newType = new GeneratedTOBuilderImpl(
+                    packageName, genTOName);
+
+            return newType;
+        }
+        return null;
+    }
+
+    private boolean isPartOfListKey(final LeafSchemaNode leaf,
+            final List<String> keys) {
+        if ((leaf != null) && (keys != null) && (leaf.getQName() != null)) {
+            final String leafName = leaf.getQName().getLocalName();
+            if (keys.contains(leafName)) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private List<String> listKeys(final ListSchemaNode list) {
+        final List<String> listKeys = new ArrayList<String>();
+
+        if (list.getKeyDefinition() != null) {
+            final List<QName> keyDefinitions = list.getKeyDefinition();
+            
+            for (final QName keyDefinition : keyDefinitions) {
+                listKeys.add(keyDefinition.getLocalName());
+            }
+        }
+        return listKeys;
     }
 
     private GeneratedTypeBuilder resolveListTypeBuilder(
index 049f8d98a130a6897ebd00c9fe568daa9d96edb4..095208d9779ec10ee38411f14de89dd555507e16 100644 (file)
@@ -10,73 +10,51 @@ package org.opendaylight.controller.sal.binding.yang.types.test;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 
-import java.io.IOException;
-import java.io.InputStream;
 import java.util.List;
+import java.util.Set;
 
-import org.antlr.v4.runtime.ANTLRInputStream;
-import org.antlr.v4.runtime.CommonTokenStream;
-import org.antlr.v4.runtime.tree.ParseTree;
-import org.antlr.v4.runtime.tree.ParseTreeWalker;
 import org.junit.Test;
-import org.opendaylight.controller.antlrv4.code.gen.YangLexer;
-import org.opendaylight.controller.antlrv4.code.gen.YangParser;
-import org.opendaylight.controller.model.parser.builder.ModuleBuilder;
-import org.opendaylight.controller.model.parser.impl.YangModelParserImpl;
 import org.opendaylight.controller.sal.binding.generator.api.BindingGenerator;
 import org.opendaylight.controller.sal.binding.generator.impl.BindingGeneratorImpl;
+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.model.parser.impl.YangModelParserImpl;
 
 public class GeneratedTypesTest {
 
-    private Module resolveModuleFromFile(final String filePath) {
-        try {
-            final InputStream inStream = getClass().getResourceAsStream(
-                    filePath);
-            if (inStream != null) {
-                ANTLRInputStream input = new ANTLRInputStream(inStream);
-                final YangLexer lexer = new YangLexer(input);
-                final CommonTokenStream tokens = new CommonTokenStream(lexer);
-                final YangParser parser = new YangParser(tokens);
+    private SchemaContext resolveSchemaContextFromFiles(
+            final String... yangFiles) {
+        final YangModelParser parser = new YangModelParserImpl();
+        final Set<Module> modules = parser.parseYangModels(yangFiles);
 
-                final ParseTree tree = parser.yang();
-                final ParseTreeWalker walker = new ParseTreeWalker();
-
-                final YangModelParserImpl modelParser = new YangModelParserImpl();
-                walker.walk(modelParser, tree);
-
-                final ModuleBuilder genModule = modelParser.getModuleBuilder();
-                final Module module = genModule.build();
-
-                return module;
-            }
-        } catch (IOException e) {
-            e.printStackTrace();
-        }
-        return null;
+        return parser.resolveSchemaContext(modules);
     }
 
     @Test
     public void testContainerResolving() {
-        final Module module = resolveModuleFromFile("/simple-container-demo.yang");
-        assertTrue(module != null);
+        final String filePath = getClass().getResource("/simple-container-demo.yang").getPath();
+        final SchemaContext context = resolveSchemaContextFromFiles(filePath);
+        assertTrue(context != null);
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
-        final List<GeneratedType> genTypes = bindingGen.generateTypes(module);
+        final List<Type> genTypes = bindingGen.generateTypes(context);
 
         assertTrue(genTypes != null);
-        assertEquals(genTypes.size(), 2);
-
-        final GeneratedType simpleContainer = genTypes.get(0);
-        final GeneratedType nestedContainer = genTypes.get(1);
+        assertEquals(2, genTypes.size());
 
-        assertEquals(simpleContainer.getName(), "SimpleContainer");
-        assertEquals(nestedContainer.getName(), "NestedContainer");
+        final GeneratedType simpleContainer = (GeneratedType) genTypes.get(0);
+        final GeneratedType nestedContainer = (GeneratedType) genTypes.get(1);
 
-        assertEquals(simpleContainer.getMethodDefinitions().size(), 4);
-        assertEquals(nestedContainer.getMethodDefinitions().size(), 4);
+        assertEquals("SimpleContainer", simpleContainer.getName());
+        assertEquals("NestedContainer", nestedContainer.getName());
+        assertEquals(4, simpleContainer.getMethodDefinitions().size());
+        assertEquals(4, nestedContainer.getMethodDefinitions().size());
 
         int methodsCount = 0;
         for (final MethodSignature method : simpleContainer
@@ -90,8 +68,8 @@ public class GeneratedTypesTest {
                 methodsCount++;
                 final MethodSignature.Parameter param = method.getParameters()
                         .get(0);
-                assertEquals(param.getName(), "foo");
-                assertEquals(param.getType().getName(), "Integer");
+                assertEquals("foo", param.getName());
+                assertEquals("Integer", param.getType().getName());
             }
 
             if (method.getName().equals("getBar")) {
@@ -104,7 +82,7 @@ public class GeneratedTypesTest {
                 methodsCount++;
             }
         }
-        assertEquals(methodsCount, 4);
+        assertEquals(4, methodsCount);
 
         methodsCount = 0;
         for (final MethodSignature method : nestedContainer
@@ -118,8 +96,8 @@ public class GeneratedTypesTest {
                 methodsCount++;
                 final MethodSignature.Parameter param = method.getParameters()
                         .get(0);
-                assertEquals(param.getName(), "foo");
-                assertEquals(param.getType().getName(), "Short");
+                assertEquals("foo", param.getName());
+                assertEquals("Short", param.getType().getName());
             }
 
             if (method.getName().equals("getBar")) {
@@ -132,30 +110,28 @@ public class GeneratedTypesTest {
                 methodsCount++;
             }
         }
-        assertEquals(methodsCount, 4);
+        assertEquals(4, methodsCount);
     }
 
     @Test
     public void testLeafListResolving() {
-        final Module module = resolveModuleFromFile("/simple-leaf-list-demo.yang");
-        assertTrue(module != null);
+        final String filePath = getClass().getResource("/simple-leaf-list-demo.yang").getPath();
+        final SchemaContext context = resolveSchemaContextFromFiles(filePath);
+        assertTrue(context != null);
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
-        final List<GeneratedType> genTypes = bindingGen.generateTypes(module);
+        final List<Type> genTypes = bindingGen.generateTypes(context);
 
         assertTrue(genTypes != null);
-        assertEquals(genTypes.size(), 2);
+        assertEquals(2, genTypes.size());
 
-        final GeneratedType simpleContainer = genTypes.get(0);
-        final GeneratedType nestedContainer = genTypes.get(1);
+        final GeneratedType simpleContainer = (GeneratedType) genTypes.get(0);
+        final GeneratedType nestedContainer = (GeneratedType) genTypes.get(1);
 
-        assertEquals(simpleContainer.getName(), "SimpleContainer");
-        assertEquals(nestedContainer.getName(), "NestedContainer");
-
-        // FIXME: uncomment after fix in DOM tree parser - LeafSchemaNode bad
-        // isConfig resolving
-        assertEquals(simpleContainer.getMethodDefinitions().size(), 4);
-        assertEquals(nestedContainer.getMethodDefinitions().size(), 3);
+        assertEquals("SimpleContainer", simpleContainer.getName());
+        assertEquals("NestedContainer", nestedContainer.getName());
+        assertEquals(4, simpleContainer.getMethodDefinitions().size());
+        assertEquals(3, nestedContainer.getMethodDefinitions().size());
 
         int methodsCount = 0;
         for (final MethodSignature method : simpleContainer
@@ -169,8 +145,8 @@ public class GeneratedTypesTest {
                 methodsCount++;
                 final MethodSignature.Parameter param = method.getParameters()
                         .get(0);
-                assertEquals(param.getName(), "foo");
-                assertEquals(param.getType().getName(), "List");
+                assertEquals("foo", param.getName());
+                assertEquals("List", param.getType().getName());
             }
 
             if (method.getName().equals("getBar")) {
@@ -183,7 +159,7 @@ public class GeneratedTypesTest {
                 methodsCount++;
             }
         }
-        assertEquals(methodsCount, 4);
+        assertEquals(4, methodsCount);
 
         methodsCount = 0;
         for (final MethodSignature method : nestedContainer
@@ -197,8 +173,8 @@ public class GeneratedTypesTest {
                 methodsCount++;
                 final MethodSignature.Parameter param = method.getParameters()
                         .get(0);
-                assertEquals(param.getName(), "foo");
-                assertEquals(param.getType().getName(), "Short");
+                assertEquals("foo", param.getName());
+                assertEquals("Short", param.getType().getName());
             }
 
             if (method.getName().equals("getBar")) {
@@ -206,30 +182,160 @@ public class GeneratedTypesTest {
                 methodsCount++;
             }
         }
-        assertEquals(methodsCount, 3);
+        assertEquals(3, methodsCount);
     }
 
     @Test
     public void testListResolving() {
-        final Module module = resolveModuleFromFile("/simple-list-demo.yang");
-        assertTrue(module != null);
+        final String filePath = getClass().getResource("/simple-list-demo.yang").getPath();
+        final SchemaContext context = resolveSchemaContextFromFiles(filePath);
+        assertTrue(context != null);
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
-        final List<GeneratedType> genTypes = bindingGen.generateTypes(module);
+        final List<Type> genTypes = bindingGen.generateTypes(context);
 
         assertTrue(genTypes != null);
-        assertEquals(genTypes.size(), 3);
+        assertEquals(4, genTypes.size());
+
+        int genTypesCount = 0;
+        int genTOsCount = 0;
+        for (final Type type : genTypes) {
+            if (type instanceof GeneratedType) {
+                final GeneratedType genType = (GeneratedType) type;
+                if (genType.getName().equals("ListParentContainer")) {
+                    assertEquals(2, genType.getMethodDefinitions().size());
+                    genTypesCount++;
+                } else if (genType.getName().equals("SimpleList")) {
+                    assertEquals(7, genType.getMethodDefinitions().size());
+                    final List<MethodSignature> methods = genType
+                            .getMethodDefinitions();
+                    int methodsCount = 0;
+                    for (final MethodSignature method : methods) {
+                        if (method.getName().equals("getSimpleListKey")) {
+                            assertEquals("SimpleListKey", method
+                                    .getReturnType().getName());
+                            methodsCount++;
+                        } else if (method.getName().equals(
+                                "getListChildContainer")) {
+                            assertEquals("ListChildContainer", method
+                                    .getReturnType().getName());
+                            methodsCount++;
+                        } else if (method.getName().equals("getFoo")) {
+                            methodsCount++;
+                        } else if (method.getName().equals("setFoo")) {
+                            methodsCount++;
+                        } else if (method.getName().equals("getSimpleLeafList")) {
+                            methodsCount++;
+                        } else if (method.getName().equals("setSimpleLeafList")) {
+                            methodsCount++;
+                        } else if (method.getName().equals("getBar")) {
+                            methodsCount++;
+                        }
+                    }
+                    assertEquals(7, methodsCount);
+                    genTypesCount++;
+                } else if (genType.getName().equals("ListChildContainer")) {
+                    assertEquals(2, genType.getMethodDefinitions().size());
+                    genTypesCount++;
+                }
+            } else if (type instanceof GeneratedTransferObject) {
+                genTOsCount++;
+                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
+                final List<GeneratedProperty> properties = genTO
+                        .getProperties();
+                final List<GeneratedProperty> hashProps = genTO
+                        .getHashCodeIdentifiers();
+                final List<GeneratedProperty> equalProps = genTO
+                        .getEqualsIdentifiers();
+
+                assertEquals(1, properties.size());
+                assertEquals("ListKey", properties.get(0).getName());
+                assertEquals("Byte", properties.get(0).getReturnType()
+                        .getName());
+                assertEquals(true, properties.get(0).isReadOnly());
+                assertEquals(1, hashProps.size());
+                assertEquals("ListKey", hashProps.get(0).getName());
+                assertEquals("Byte", hashProps.get(0).getReturnType().getName());
+                assertEquals(1, equalProps.size());
+                assertEquals("ListKey", equalProps.get(0).getName());
+                assertEquals("Byte", equalProps.get(0).getReturnType()
+                        .getName());
+            }
+        }
+        assertEquals(3, genTypesCount);
+        assertEquals(1, genTOsCount);
+    }
+
+    @Test
+    public void testListCompositeKeyResolving() {
+        final String filePath = getClass().getResource("/list-composite-key.yang").getPath();
+        final SchemaContext context = resolveSchemaContextFromFiles(filePath);
+
+        assertTrue(context != null);
+
+        final BindingGenerator bindingGen = new BindingGeneratorImpl();
+        final List<Type> genTypes = bindingGen.generateTypes(context);
+
+        assertTrue(genTypes != null);
+        assertEquals(6, genTypes.size());
+
+        int genTypesCount = 0;
+        int genTOsCount = 0;
+        for (final Type type : genTypes) {
+            if (type instanceof GeneratedType) {
+                genTypesCount++;
+            } else if (type instanceof GeneratedTransferObject) {
+                final GeneratedTransferObject genTO = (GeneratedTransferObject) type;
+
+                if (genTO.getName().equals("CompositeKeyListKey")) {
+                    final List<GeneratedProperty> properties = genTO
+                            .getProperties();
+                    int propertyCount = 0;
+                    for (final GeneratedProperty prop : properties) {
+                        if (prop.getName().equals("Key1")) {
+                            propertyCount++;
+                        } else if (prop.getName().equals("Key2")) {
+                            propertyCount++;
+                        }
+                    }
+                    assertEquals(2, propertyCount);
+                    genTOsCount++;
+                } else if (genTO.getName().equals("InnerListKey")) {
+                    final List<GeneratedProperty> properties = genTO
+                            .getProperties();
+                    assertEquals(1, properties.size());
+                    genTOsCount++;
+                }
+            }
+        }
+
+        assertEquals(4, genTypesCount);
+        assertEquals(2, genTOsCount);
     }
 
     @Test
     public void testGeneratedTypes() {
-        final Module module = resolveModuleFromFile("/demo-topology.yang");
-        assertTrue(module != null);
+        final String filePath = getClass().getResource("/demo-topology.yang").getPath();
+        final SchemaContext context = resolveSchemaContextFromFiles(filePath);
+        assertTrue(context != null);
 
         final BindingGenerator bindingGen = new BindingGeneratorImpl();
-        final List<GeneratedType> genTypes = bindingGen.generateTypes(module);
+        final List<Type> genTypes = bindingGen.generateTypes(context);
 
         assertTrue(genTypes != null);
-        assertEquals(genTypes.size(), 10);
+        assertEquals(13, genTypes.size());
+
+        int genTypesCount = 0;
+        int genTOsCount = 0;
+        for (final Type type : genTypes) {
+            if (type instanceof GeneratedType) {
+                genTypesCount++;
+            } else if (type instanceof GeneratedTransferObject) {
+                genTOsCount++;
+            }
+        }
+
+        assertEquals(10, genTypesCount);
+        assertEquals(3, genTOsCount);
     }
 }
diff --git a/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/list-composite-key.yang b/opendaylight/sal/yang-prototype/code-generator/binding-generator-impl/src/test/resources/list-composite-key.yang
new file mode 100644 (file)
index 0000000..333c8bf
--- /dev/null
@@ -0,0 +1,63 @@
+module list-composite-key {
+    yang-version 1;
+    namespace "urn:composite.key";
+    prefix "scd";
+
+    organization "Cisco";
+
+    contact "WILL-BE-DEFINED-LATER";
+
+    description "
+        This module contains the definitions of elements that creates network 
+        topology i.e. definition of network nodes and links. This module is
+        not designed to be used solely for network representation. This module
+        SHOULD be used as base module in defining the network topology.
+    ";
+
+    revision "2013-02-27" {
+        reference " WILL BE DEFINED LATER";
+    }
+
+    container list-parent-container {
+
+        list composite-key-list {
+            key "key1 key2";
+
+            leaf key1 {
+                type int8;
+            }
+            
+            leaf key2 {
+                type string;
+            }
+            
+            list inner-list {
+                key "key1";
+                
+                leaf key1 {
+                    type uint16;
+                }
+                
+                leaf foo {
+                    type int32;
+                }
+            }
+            
+            leaf foo {
+                type int32;
+            }
+        }
+        
+        list no-key-list {
+            leaf foo {
+                type int32;
+            }
+            
+            leaf bar {
+                type decimal64 {
+                    fraction-digits 2;
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
index 36d0fbc28c22af1f189b1e8ff0b13003f2b37d70..9df281fcd3229c3cc3625871f577704fced5d3b7 100644 (file)
@@ -57,8 +57,7 @@ public class GeneratorJavaFileTest {
         generator.generateToFile(PATH);\r
 \r
         // path: test-dir/com/cisco/yang\r
-        String[] files = new File(PATH + FS + "com" + FS + "cisco" + FS\r
-                + "yang").list();\r
+        String[] files = new File(PATH + FS + "org" + FS + "opendaylight" + FS + "controller" + FS + "gen").list();\r
         List<String> filesList = Arrays.asList(files);\r
 \r
         assertEquals(3, files.length);\r
index 4abdc99b916f9fbefb2ff2aa10ea90bec02f57d8..349a34271071afd9519ba6c250f660a99b5ed3b5 100644 (file)
@@ -1,11 +1,11 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved. \r
+/**\r
+\r
+ *\r
+ * March 2013\r
  *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ * Copyright (c) 2013 by Cisco Systems, Inc.\r
+ * All rights reserved.\r
  */\r
-\r
 package org.opendaylight.controller.sal.binding.model.api.type.builder;\r
 \r
 import org.opendaylight.controller.sal.binding.model.api.MethodSignature;\r
index 2a462a131a4a24597d652f8b506e9fbf6e712db7..ff2c06e7570575e10d6a7d2602eaa43e73667872 100644 (file)
@@ -1,9 +1,9 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved. \r
+/**\r
+\r
+ *\r
+ * March 2013\r
  *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
+ * Copyright (c) 2013 by Cisco Systems, Inc.\r
+ * All rights reserved.\r
  */\r
-\r
 package org.opendaylight.controller.sal.binding.model.api.type.builder;
\ No newline at end of file
index dfa23fae72b15cf3a8deabb8f0af7a87a2d5668a..58608354d1d0cdec771cbbc8cd324863e703277c 100644 (file)
           <artifactId>binding-generator-impl</artifactId>\r
           <version>1.0</version>\r
       </dependency>\r
-      <dependency>\r
-          <groupId>org.opendaylight.controller</groupId>\r
-          <artifactId>yang-model-parser-impl</artifactId>\r
-          <version>1.0</version>\r
-      </dependency>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>binding-java-api-generator</artifactId>\r
index 6628966489969ba87f0582756c112545d55119d4..2d38c7db516ac6f5abb5ddbcb69b96d09ffecb4d 100644 (file)
@@ -1,50 +1,50 @@
 /*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved. \r
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
  *\r
  * This program and the accompanying materials are made available under the\r
  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
  */\r
-\r
 package org.opendaylight.controller;\r
 \r
 import java.io.File;\r
-import java.util.Map;\r
-\r
-import org.opendaylight.controller.model.parser.builder.YangModelBuilder;\r
-\r
+import java.util.Set;\r
 \r
+import org.opendaylight.controller.yang.model.api.Module;\r
+import org.opendaylight.controller.yang.model.parser.impl.YangModelParserImpl;\r
 \r
 public class Demo {\r
 \r
-       public static void main(String[] args) throws Exception {\r
-\r
-               String yangFilesDir;\r
-               if(args.length > 0) {\r
-                       yangFilesDir = args[0];\r
-               } else {\r
-                       yangFilesDir = "src/main/resources";\r
-               }\r
-\r
-               File resourceDir = new File(yangFilesDir);\r
-               if(!resourceDir.exists()) {\r
-                       throw new IllegalArgumentException("Specified resource directory does not exists: "+ resourceDir.getAbsolutePath());\r
-               }\r
-\r
-               String[] dirList = resourceDir.list();\r
-               String[] absFiles = new String[dirList.length];\r
-\r
-               int i = 0;\r
-               for(String fileName : dirList) {\r
-                       File f = new File(fileName);\r
-                       absFiles[i] = f.getAbsolutePath();\r
-                       i++;\r
-               }\r
-\r
-        YangModelBuilder builder = new YangModelBuilder(absFiles);\r
-        Map<String, org.opendaylight.controller.yang.model.api.Module> builtModules = builder.build();\r
-\r
-        System.out.println("Modules built: "+ builtModules.size());\r
-       }\r
+    public static void main(String[] args) throws Exception {\r
+\r
+        String yangFilesDir;\r
+        if (args.length > 0) {\r
+            yangFilesDir = args[0];\r
+        } else {\r
+            yangFilesDir = "src/main/resources/demo";\r
+        }\r
+\r
+        File resourceDir = new File(yangFilesDir);\r
+        if (!resourceDir.exists()) {\r
+            throw new IllegalArgumentException(\r
+                    "Specified resource directory does not exists: "\r
+                            + resourceDir.getAbsolutePath());\r
+        }\r
+\r
+        String[] dirList = resourceDir.list();\r
+        String[] absFiles = new String[dirList.length];\r
+\r
+        int i = 0;\r
+        for (String fileName : dirList) {\r
+            File abs = new File(resourceDir, fileName);\r
+            absFiles[i] = abs.getAbsolutePath();\r
+            i++;\r
+        }\r
+\r
+        YangModelParserImpl parser = new YangModelParserImpl();\r
+        Set<Module> builtModules = parser.parseYangModels(absFiles);\r
+\r
+        System.out.println("Modules built: " + builtModules.size());\r
+    }\r
 \r
 }\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-api/pom.xml b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-api/pom.xml
new file mode 100644 (file)
index 0000000..5bfd19d
--- /dev/null
@@ -0,0 +1,17 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>binding-generator</artifactId>
+    <version>1.0</version>
+  </parent>
+  <artifactId>yang-model-parser-api</artifactId>
+  
+  <dependencies>
+      <dependency>
+          <groupId>org.opendaylight.controller</groupId>
+          <artifactId>yang-model-api</artifactId>
+          <version>1.0</version>
+      </dependency>
+  </dependencies>
+</project>
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-api/src/main/java/org/opendaylight/controller/yang/model/parser/api/YangModelParser.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-api/src/main/java/org/opendaylight/controller/yang/model/parser/api/YangModelParser.java
new file mode 100644 (file)
index 0000000..8faf73e
--- /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.yang.model.parser.api;
+
+import java.util.Set;
+
+import org.opendaylight.controller.model.api.type.UnknownTypeDefinition;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.SchemaContext;
+
+/**
+ * Yang Model Parser interface is designed for parsing yang models and 
+ * convert the information to Data Schema Tree.
+ * 
+ */
+public interface YangModelParser {
+
+    /**
+     * Parse single Yang model file and return the schema definition of Yang
+     * module defined in *.Yang file.
+     * 
+     * @param yangFile
+     *            yang file to parse
+     * @return the schema definition of Yang module defined in .Yang file.
+     */
+    public Module parseYangModel(final String yangFile);
+
+    /**
+     * Parse one or more Yang model files and return the definitions of Yang
+     * modules defined in *.Yang files;
+     * <br>
+     * This method SHOULD be used if user need to parse multiple yang models
+     * that are referenced either through import or include statements.
+     * 
+     * @param yangFiles yang files to parse
+     * @return Set of Yang Modules
+     */
+    public Set<Module> parseYangModels(final String... yangFiles);
+
+    /**
+     * Creates {@link SchemaContext} from specified Modules. The modules SHOULD
+     * not contain any unresolved Schema Nodes or Type Definitions. By
+     * unresolved Schema Nodes or Type Definitions we mean that the Module
+     * should not contain ANY Schema Nodes that contains
+     * {@link UnknownTypeDefinition} and all dependencies although via import or
+     * include definitions are resolved.
+     * 
+     * @param modules
+     *            Set of Yang Modules
+     * @return Schema Context instance constructed from whole Set of Modules.
+     */
+    public SchemaContext resolveSchemaContext(final Set<Module> modules);
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-api/src/main/java/org/opendaylight/controller/yang/model/parser/api/package-info.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-api/src/main/java/org/opendaylight/controller/yang/model/parser/api/package-info.java
new file mode 100644 (file)
index 0000000..2e8a029
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+ * 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.yang.model.parser.api;
\ No newline at end of file
index 184abf03ee146361b4cb01c9120471465a78162a..e04cb701ee3875be3d229337c299966cee2477cd 100644 (file)
           <artifactId>yang-model-api</artifactId>\r
           <version>1.0</version>\r
       </dependency>\r
+      <dependency>\r
+          <groupId>org.opendaylight.controller</groupId>\r
+          <artifactId>yang-model-parser-api</artifactId>\r
+          <version>1.0</version>\r
+      </dependency>\r
       <dependency>\r
           <groupId>org.opendaylight.controller</groupId>\r
           <artifactId>yang-model-util</artifactId>\r
@@ -50,5 +55,5 @@
           <version>1.8.4</version>\r
       </dependency>\r
   </dependencies>\r
-  \r
-</project>
\ No newline at end of file
+\r
+</project>\r
index 0fbfc1c6bdb6a42c020cb0cc707f6c75f0d81ac7..4f7769eaf9bfb3679cd4cf1a8641b026133cd2ec 100644 (file)
@@ -7,21 +7,21 @@
  */\r
 package org.opendaylight.controller.antlrv4.code.gen;\r
 \r
-import org.antlr.v4.runtime.CharStream;\r
 import org.antlr.v4.runtime.Lexer;\r
-import org.antlr.v4.runtime.RuleContext;\r
-import org.antlr.v4.runtime.atn.ATN;\r
-import org.antlr.v4.runtime.atn.ATNSimulator;\r
-import org.antlr.v4.runtime.atn.LexerATNSimulator;\r
-import org.antlr.v4.runtime.atn.PredictionContextCache;\r
+import org.antlr.v4.runtime.CharStream;\r
+import org.antlr.v4.runtime.Token;\r
+import org.antlr.v4.runtime.TokenStream;\r
+import org.antlr.v4.runtime.*;\r
+import org.antlr.v4.runtime.atn.*;\r
 import org.antlr.v4.runtime.dfa.DFA;\r
+import org.antlr.v4.runtime.misc.*;\r
 \r
 @SuppressWarnings({ "all", "warnings", "unchecked", "unused", "cast" })\r
 public class YangLexer extends Lexer {\r
     protected static final DFA[] _decisionToDFA;\r
     protected static final PredictionContextCache _sharedContextCache = new PredictionContextCache();\r
     public static final int SEMICOLON = 1, LEFT_BRACE = 2, RIGHT_BRACE = 3,\r
-            PLUS = 4, WS = 5, LINE_COMMENT = 6, BLOCK_COMMENT = 7,\r
+            PLUS = 4, WS = 5, LINE_COMMENT = 6, START_BLOCK_COMMENT = 7,\r
             YIN_ELEMENT_KEYWORD = 8, YANG_VERSION_KEYWORD = 9,\r
             WHEN_KEYWORD = 10, VALUE_KEYWORD = 11, USES_KEYWORD = 12,\r
             UNITS_KEYWORD = 13, UNIQUE_KEYWORD = 14, TYPEDEF_KEYWORD = 15,\r
@@ -48,12 +48,14 @@ public class YangLexer extends Lexer {
             CHOICE_KEYWORD = 65, CASE_KEYWORD = 66, BIT_KEYWORD = 67,\r
             BELONGS_TO_KEYWORD = 68, BASE_KEYWORD = 69, AUGMENT_KEYWORD = 70,\r
             ARGUMENT_KEYWORD = 71, ANYXML_KEYWORD = 72, IDENTIFIER = 73,\r
-            STRING = 74, S = 75;\r
+            STRING = 74, S = 75, END_BLOCK_COMMENT = 76;\r
     public static final int VALUE_MODE = 1;\r
-    public static String[] modeNames = { "DEFAULT_MODE", "VALUE_MODE" };\r
+    public static final int BLOCK_COMMENT_MODE = 2;\r
+    public static String[] modeNames = { "DEFAULT_MODE", "VALUE_MODE",\r
+            "BLOCK_COMMENT_MODE" };\r
 \r
     public static final String[] tokenNames = { "<INVALID>", "SEMICOLON",\r
-            "LEFT_BRACE", "'}'", "'+'", "WS", "LINE_COMMENT", "BLOCK_COMMENT",\r
+            "LEFT_BRACE", "'}'", "'+'", "WS", "LINE_COMMENT", "'/*'",\r
             "'yin-element'", "'yang-version'", "'when'", "'value'", "'uses'",\r
             "'units'", "'unique'", "'typedef'", "'type'", "'submodule'",\r
             "'status'", "'rpc'", "'revision-date'", "'revision'",\r
@@ -69,9 +71,9 @@ public class YangLexer extends Lexer {
             "'description'", "'default'", "'container'", "'contact'",\r
             "'config'", "'choice'", "'case'", "'bit'", "'belongs-to'",\r
             "'base'", "'augment'", "'argument'", "'anyxml'", "IDENTIFIER",\r
-            "STRING", "S" };\r
+            "STRING", "S", "'*/'" };\r
     public static final String[] ruleNames = { "PLUS", "WS", "LINE_COMMENT",\r
-            "BLOCK_COMMENT", "SEMICOLON", "LEFT_BRACE", "RIGHT_BRACE",\r
+            "START_BLOCK_COMMENT", "SEMICOLON", "LEFT_BRACE", "RIGHT_BRACE",\r
             "YIN_ELEMENT_KEYWORD", "YANG_VERSION_KEYWORD", "WHEN_KEYWORD",\r
             "VALUE_KEYWORD", "USES_KEYWORD", "UNITS_KEYWORD", "UNIQUE_KEYWORD",\r
             "TYPEDEF_KEYWORD", "TYPE_KEYWORD", "SUBMODULE_KEYWORD",\r
@@ -95,7 +97,7 @@ public class YangLexer extends Lexer {
             "BASE_KEYWORD", "AUGMENT_KEYWORD", "ARGUMENT_KEYWORD",\r
             "ANYXML_KEYWORD", "IDENTIFIER", "ESC", "UNICODE", "HEX",\r
             "END_IDENTIFIER_SEMICOLON", "END_IDENTIFIER_LEFT_BRACE",\r
-            "SUB_STRING", "STRING", "S" };\r
+            "SUB_STRING", "STRING", "S", "END_BLOCK_COMMENT", "BLOCK_COMMENT" };\r
 \r
     public YangLexer(CharStream input) {\r
         super(input);\r
@@ -144,7 +146,7 @@ public class YangLexer extends Lexer {
             break;\r
 \r
         case 3:\r
-            BLOCK_COMMENT_action((RuleContext) _localctx, actionIndex);\r
+            START_BLOCK_COMMENT_action((RuleContext) _localctx, actionIndex);\r
             break;\r
 \r
         case 4:\r
@@ -433,6 +435,14 @@ public class YangLexer extends Lexer {
         case 80:\r
             S_action((RuleContext) _localctx, actionIndex);\r
             break;\r
+\r
+        case 81:\r
+            END_BLOCK_COMMENT_action((RuleContext) _localctx, actionIndex);\r
+            break;\r
+\r
+        case 82:\r
+            BLOCK_COMMENT_action((RuleContext) _localctx, actionIndex);\r
+            break;\r
         }\r
     }\r
 \r
@@ -667,7 +677,8 @@ public class YangLexer extends Lexer {
 \r
     private void BLOCK_COMMENT_action(RuleContext _localctx, int actionIndex) {\r
         switch (actionIndex) {\r
-        case 3:\r
+        case 76:\r
+            more();\r
             skip();\r
             break;\r
         }\r
@@ -856,6 +867,16 @@ public class YangLexer extends Lexer {
         }\r
     }\r
 \r
+    private void START_BLOCK_COMMENT_action(RuleContext _localctx,\r
+            int actionIndex) {\r
+        switch (actionIndex) {\r
+        case 3:\r
+            pushMode(BLOCK_COMMENT_MODE);\r
+            skip();\r
+            break;\r
+        }\r
+    }\r
+\r
     private void WS_action(RuleContext _localctx, int actionIndex) {\r
         switch (actionIndex) {\r
         case 1:\r
@@ -1006,6 +1027,15 @@ public class YangLexer extends Lexer {
         }\r
     }\r
 \r
+    private void END_BLOCK_COMMENT_action(RuleContext _localctx, int actionIndex) {\r
+        switch (actionIndex) {\r
+        case 75:\r
+            popMode();\r
+            skip();\r
+            break;\r
+        }\r
+    }\r
+\r
     private void BASE_KEYWORD_action(RuleContext _localctx, int actionIndex) {\r
         switch (actionIndex) {\r
         case 66:\r
@@ -1055,322 +1085,323 @@ public class YangLexer extends Lexer {
         }\r
     }\r
 \r
-    public static final String _serializedATN = "\2\4M\u03bf\b\1\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4"\r
-            + "\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4"\r
-            + "\20\t\20\4\21\t\21\4\22\t\22\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4"\r
-            + "\27\t\27\4\30\t\30\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4"\r
-            + "\36\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'"\r
-            + "\4(\t(\4)\t)\4*\t*\4+\t+\4,\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4"\r
-            + "\62\t\62\4\63\t\63\4\64\t\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t"\r
-            + "9\4:\t:\4;\t;\4<\t<\4=\t=\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4"\r
-            + "E\tE\4F\tF\4G\tG\4H\tH\4I\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\t"\r
-            + "P\4Q\tQ\4R\tR\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\7\4\u00b3"\r
-            + "\n\4\f\4\16\4\u00b6\13\4\3\4\3\4\3\5\3\5\3\5\3\5\7\5\u00be\n\5\f\5\16"\r
-            + "\5\u00c1\13\5\3\5\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\b"\r
-            + "\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3"\r
-            + "\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3"\r
-            + "\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3"\r
-            + "\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\17\3\17\3\17"\r
-            + "\3\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20"\r
-            + "\3\20\3\20\3\21\3\21\3\21\3\21\3\21\3\21\3\21\3\22\3\22\3\22\3\22\3\22"\r
-            + "\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\23\3\23\3\23\3\23"\r
-            + "\3\23\3\23\3\24\3\24\3\24\3\24\3\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25"\r
-            + "\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3\26\3\26"\r
-            + "\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\27\3\27\3\27\3\27\3\27\3\27\3\27"\r
-            + "\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\30\3\30"\r
-            + "\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\31\3\31\3\31\3\31\3\31\3\31\3\31"\r
-            + "\3\31\3\31\3\31\3\31\3\31\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\32\3\33"\r
-            + "\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34"\r
-            + "\3\34\3\34\3\34\3\34\3\34\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35"\r
-            + "\3\35\3\35\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37"\r
-            + "\3\37\3\37\3\37\3\37\3\37\3 \3 \3 \3 \3 \3 \3 \3!\3!\3!\3!\3!\3!\3!\3"\r
-            + "!\3!\3!\3!\3!\3!\3!\3!\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3\""\r
-            + "\3\"\3#\3#\3#\3#\3#\3#\3#\3#\3#\3#\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3$\3"\r
-            + "$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\3&\3\'\3"\r
-            + "\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3(\3(\3(\3(\3("\r
-            + "\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3*"\r
-            + "\3*\3*\3*\3*\3*\3*\3+\3+\3+\3+\3+\3+\3+\3+\3+\3,\3,\3,\3,\3,\3,\3,\3,"\r
-            + "\3,\3,\3,\3,\3-\3-\3-\3-\3-\3-\3-\3.\3.\3.\3.\3.\3.\3/\3/\3/\3/\3/\3/"\r
-            + "\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\60\3\61\3\61\3\61\3\61"\r
-            + "\3\61\3\61\3\61\3\61\3\61\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\62"\r
-            + "\3\62\3\62\3\62\3\62\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\63"\r
-            + "\3\63\3\64\3\64\3\64\3\64\3\64\3\64\3\64\3\64\3\64\3\64\3\64\3\65\3\65"\r
-            + "\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\65"\r
-            + "\3\65\3\65\3\66\3\66\3\66\3\66\3\66\3\66\3\66\3\66\3\66\3\66\3\67\3\67"\r
-            + "\3\67\3\67\3\67\3\67\3\67\3\67\3\67\3\67\38\38\38\38\38\38\38\38\38\3"\r
-            + "8\38\38\39\39\39\39\39\39\39\39\39\39\39\39\3:\3:\3:\3:\3:\3:\3:\3:\3"\r
-            + ":\3:\3:\3:\3:\3:\3:\3:\3;\3;\3;\3;\3;\3;\3;\3;\3;\3;\3;\3;\3;\3;\3;\3"\r
-            + ";\3<\3<\3<\3<\3<\3<\3<\3=\3=\3=\3=\3=\3=\3=\3=\3=\3=\3=\3=\3=\3=\3>\3"\r
-            + ">\3>\3>\3>\3>\3>\3>\3>\3>\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3@\3@\3"\r
-            + "@\3@\3@\3@\3@\3@\3@\3@\3A\3A\3A\3A\3A\3A\3A\3A\3A\3B\3B\3B\3B\3B\3B\3"\r
-            + "B\3B\3B\3C\3C\3C\3C\3C\3C\3C\3D\3D\3D\3D\3D\3D\3E\3E\3E\3E\3E\3E\3E\3"\r
-            + "E\3E\3E\3E\3E\3E\3F\3F\3F\3F\3F\3F\3F\3G\3G\3G\3G\3G\3G\3G\3G\3G\3G\3"\r
-            + "H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3I\3I\3I\3I\3I\3I\3I\3I\3I\3J\3J\7J\u0382"\r
-            + "\nJ\fJ\16J\u0385\13J\3J\3J\3K\3K\3K\5K\u038c\nK\3L\3L\3L\3L\3L\3L\3M\3"\r
-            + "M\3N\3N\3N\3N\3O\3O\3O\3O\3P\3P\3P\7P\u03a1\nP\fP\16P\u03a4\13P\3P\3P"\r
-            + "\3P\3P\7P\u03aa\nP\fP\16P\u03ad\13P\3P\5P\u03b0\nP\3Q\3Q\6Q\u03b4\nQ\r"\r
-            + "Q\16Q\u03b5\5Q\u03b8\nQ\3Q\3Q\3R\3R\3R\3R\2S\4\6\2\6\7\3\b\b\4\n\t\5\f"\r
-            + "\3\6\16\4\7\20\5\b\22\n\t\24\13\n\26\f\13\30\r\f\32\16\r\34\17\16\36\20"\r
-            + "\17 \21\20\"\22\21$\23\22&\24\23(\25\24*\26\25,\27\26.\30\27\60\31\30"\r
-            + "\62\32\31\64\33\32\66\34\338\35\34:\36\35<\37\36> \37@!\1B\" D#!F$\"H"\r
-            + "%#J&$L\'%N(&P)\'R*(T+)V,*X-+Z.,\\/-^\60\1`\61.b\62/d\63\60f\64\61h\65"\r
-            + "\62j\66\63l\67\64n8\65p9\66r:\67t;8v<9x=:z>;|?<~@=\u0080A>\u0082B?\u0084"\r
-            + "C@\u0086DA\u0088EB\u008aFC\u008cGD\u008eHE\u0090IF\u0092JG\u0094KH\u0096"\r
-            + "\2\1\u0098\2\1\u009a\2\1\u009c\2I\u009e\2J\u00a0\2\1\u00a2LK\u00a4ML\4"\r
-            + "\2\3\r\5\13\f\17\17\"\"\4\f\f\17\17\2\6/;C\\aac|\7/\60\62<C\\aac|\n$$"\r
-            + "\61\61^^ddhhppttvv\5\62;CHch\3$$\3))\7\f\f\17\17\"\"==}}\5\13\f\17\17"\r
-            + "\"\"\u03c4\2\4\3\2\2\2\2\6\3\2\2\2\2\b\3\2\2\2\2\n\3\2\2\2\2\f\3\2\2\2"\r
-            + "\2\16\3\2\2\2\2\20\3\2\2\2\2\22\3\2\2\2\2\24\3\2\2\2\2\26\3\2\2\2\2\30"\r
-            + "\3\2\2\2\2\32\3\2\2\2\2\34\3\2\2\2\2\36\3\2\2\2\2 \3\2\2\2\2\"\3\2\2\2"\r
-            + "\2$\3\2\2\2\2&\3\2\2\2\2(\3\2\2\2\2*\3\2\2\2\2,\3\2\2\2\2.\3\2\2\2\2\60"\r
-            + "\3\2\2\2\2\62\3\2\2\2\2\64\3\2\2\2\2\66\3\2\2\2\28\3\2\2\2\2:\3\2\2\2"\r
-            + "\2<\3\2\2\2\2>\3\2\2\2\2@\3\2\2\2\2B\3\2\2\2\2D\3\2\2\2\2F\3\2\2\2\2H"\r
-            + "\3\2\2\2\2J\3\2\2\2\2L\3\2\2\2\2N\3\2\2\2\2P\3\2\2\2\2R\3\2\2\2\2T\3\2"\r
-            + "\2\2\2V\3\2\2\2\2X\3\2\2\2\2Z\3\2\2\2\2\\\3\2\2\2\2^\3\2\2\2\2`\3\2\2"\r
-            + "\2\2b\3\2\2\2\2d\3\2\2\2\2f\3\2\2\2\2h\3\2\2\2\2j\3\2\2\2\2l\3\2\2\2\2"\r
-            + "n\3\2\2\2\2p\3\2\2\2\2r\3\2\2\2\2t\3\2\2\2\2v\3\2\2\2\2x\3\2\2\2\2z\3"\r
-            + "\2\2\2\2|\3\2\2\2\2~\3\2\2\2\2\u0080\3\2\2\2\2\u0082\3\2\2\2\2\u0084\3"\r
-            + "\2\2\2\2\u0086\3\2\2\2\2\u0088\3\2\2\2\2\u008a\3\2\2\2\2\u008c\3\2\2\2"\r
-            + "\2\u008e\3\2\2\2\2\u0090\3\2\2\2\2\u0092\3\2\2\2\2\u0094\3\2\2\2\3\u009c"\r
-            + "\3\2\2\2\3\u009e\3\2\2\2\3\u00a2\3\2\2\2\3\u00a4\3\2\2\2\4\u00a6\3\2\2"\r
-            + "\2\6\u00aa\3\2\2\2\b\u00ae\3\2\2\2\n\u00b9\3\2\2\2\f\u00c7\3\2\2\2\16"\r
-            + "\u00cb\3\2\2\2\20\u00cf\3\2\2\2\22\u00d3\3\2\2\2\24\u00e1\3\2\2\2\26\u00f0"\r
-            + "\3\2\2\2\30\u00f7\3\2\2\2\32\u00ff\3\2\2\2\34\u0106\3\2\2\2\36\u010e\3"\r
-            + "\2\2\2 \u0117\3\2\2\2\"\u0121\3\2\2\2$\u0128\3\2\2\2&\u0134\3\2\2\2(\u013d"\r
-            + "\3\2\2\2*\u0143\3\2\2\2,\u0153\3\2\2\2.\u015e\3\2\2\2\60\u0171\3\2\2\2"\r
-            + "\62\u017a\3\2\2\2\64\u0186\3\2\2\2\66\u018e\3\2\2\28\u0199\3\2\2\2:\u01a2"\r
-            + "\3\2\2\2<\u01ad\3\2\2\2>\u01b7\3\2\2\2@\u01be\3\2\2\2B\u01c5\3\2\2\2D"\r
-            + "\u01d4\3\2\2\2F\u01e1\3\2\2\2H\u01f0\3\2\2\2J\u01fc\3\2\2\2L\u0203\3\2"\r
-            + "\2\2N\u020c\3\2\2\2P\u021b\3\2\2\2R\u022a\3\2\2\2T\u0236\3\2\2\2V\u023d"\r
-            + "\3\2\2\2X\u0246\3\2\2\2Z\u0252\3\2\2\2\\\u0259\3\2\2\2^\u025f\3\2\2\2"\r
-            + "`\u0265\3\2\2\2b\u026f\3\2\2\2d\u0278\3\2\2\2f\u0285\3\2\2\2h\u0290\3"\r
-            + "\2\2\2j\u029b\3\2\2\2l\u02ad\3\2\2\2n\u02b7\3\2\2\2p\u02c1\3\2\2\2r\u02cd"\r
-            + "\3\2\2\2t\u02d9\3\2\2\2v\u02e9\3\2\2\2x\u02f9\3\2\2\2z\u0300\3\2\2\2|"\r
-            + "\u030e\3\2\2\2~\u0318\3\2\2\2\u0080\u0324\3\2\2\2\u0082\u032e\3\2\2\2"\r
-            + "\u0084\u0337\3\2\2\2\u0086\u0340\3\2\2\2\u0088\u0347\3\2\2\2\u008a\u034d"\r
-            + "\3\2\2\2\u008c\u035a\3\2\2\2\u008e\u0361\3\2\2\2\u0090\u036b\3\2\2\2\u0092"\r
-            + "\u0376\3\2\2\2\u0094\u037f\3\2\2\2\u0096\u0388\3\2\2\2\u0098\u038d\3\2"\r
-            + "\2\2\u009a\u0393\3\2\2\2\u009c\u0395\3\2\2\2\u009e\u0399\3\2\2\2\u00a0"\r
-            + "\u03af\3\2\2\2\u00a2\u03b7\3\2\2\2\u00a4\u03bb\3\2\2\2\u00a6\u00a7\7-"\r
-            + "\2\2\u00a7\u00a8\3\2\2\2\u00a8\u00a9\b\2\2\2\u00a9\5\3\2\2\2\u00aa\u00ab"\r
-            + "\t\2\2\2\u00ab\u00ac\3\2\2\2\u00ac\u00ad\b\3\3\2\u00ad\7\3\2\2\2\u00ae"\r
-            + "\u00af\7\61\2\2\u00af\u00b0\7\61\2\2\u00b0\u00b4\3\2\2\2\u00b1\u00b3\n"\r
-            + "\3\2\2\u00b2\u00b1\3\2\2\2\u00b3\u00b6\3\2\2\2\u00b4\u00b2\3\2\2\2\u00b4"\r
-            + "\u00b5\3\2\2\2\u00b5\u00b7\3\2\2\2\u00b6\u00b4\3\2\2\2\u00b7\u00b8\b\4"\r
-            + "\4\2\u00b8\t\3\2\2\2\u00b9\u00ba\7\61\2\2\u00ba\u00bb\7,\2\2\u00bb\u00bf"\r
-            + "\3\2\2\2\u00bc\u00be\n\4\2\2\u00bd\u00bc\3\2\2\2\u00be\u00c1\3\2\2\2\u00bf"\r
-            + "\u00bd\3\2\2\2\u00bf\u00c0\3\2\2\2\u00c0\u00c2\3\2\2\2\u00c1\u00bf\3\2"\r
-            + "\2\2\u00c2\u00c3\7,\2\2\u00c3\u00c4\7\61\2\2\u00c4\u00c5\3\2\2\2\u00c5"\r
-            + "\u00c6\b\5\5\2\u00c6\13\3\2\2\2\u00c7\u00c8\7=\2\2\u00c8\u00c9\3\2\2\2"\r
-            + "\u00c9\u00ca\b\6\6\2\u00ca\r\3\2\2\2\u00cb\u00cc\7}\2\2\u00cc\u00cd\3"\r
-            + "\2\2\2\u00cd\u00ce\b\7\7\2\u00ce\17\3\2\2\2\u00cf\u00d0\7\177\2\2\u00d0"\r
-            + "\u00d1\3\2\2\2\u00d1\u00d2\b\b\b\2\u00d2\21\3\2\2\2\u00d3\u00d4\7{\2\2"\r
-            + "\u00d4\u00d5\7k\2\2\u00d5\u00d6\7p\2\2\u00d6\u00d7\7/\2\2\u00d7\u00d8"\r
-            + "\7g\2\2\u00d8\u00d9\7n\2\2\u00d9\u00da\7g\2\2\u00da\u00db\7o\2\2\u00db"\r
-            + "\u00dc\7g\2\2\u00dc\u00dd\7p\2\2\u00dd\u00de\7v\2\2\u00de\u00df\3\2\2"\r
-            + "\2\u00df\u00e0\b\t\t\2\u00e0\23\3\2\2\2\u00e1\u00e2\7{\2\2\u00e2\u00e3"\r
-            + "\7c\2\2\u00e3\u00e4\7p\2\2\u00e4\u00e5\7i\2\2\u00e5\u00e6\7/\2\2\u00e6"\r
-            + "\u00e7\7x\2\2\u00e7\u00e8\7g\2\2\u00e8\u00e9\7t\2\2\u00e9\u00ea\7u\2\2"\r
-            + "\u00ea\u00eb\7k\2\2\u00eb\u00ec\7q\2\2\u00ec\u00ed\7p\2\2\u00ed\u00ee"\r
-            + "\3\2\2\2\u00ee\u00ef\b\n\n\2\u00ef\25\3\2\2\2\u00f0\u00f1\7y\2\2\u00f1"\r
-            + "\u00f2\7j\2\2\u00f2\u00f3\7g\2\2\u00f3\u00f4\7p\2\2\u00f4\u00f5\3\2\2"\r
-            + "\2\u00f5\u00f6\b\13\13\2\u00f6\27\3\2\2\2\u00f7\u00f8\7x\2\2\u00f8\u00f9"\r
-            + "\7c\2\2\u00f9\u00fa\7n\2\2\u00fa\u00fb\7w\2\2\u00fb\u00fc\7g\2\2\u00fc"\r
-            + "\u00fd\3\2\2\2\u00fd\u00fe\b\f\f\2\u00fe\31\3\2\2\2\u00ff\u0100\7w\2\2"\r
-            + "\u0100\u0101\7u\2\2\u0101\u0102\7g\2\2\u0102\u0103\7u\2\2\u0103\u0104"\r
-            + "\3\2\2\2\u0104\u0105\b\r\r\2\u0105\33\3\2\2\2\u0106\u0107\7w\2\2\u0107"\r
-            + "\u0108\7p\2\2\u0108\u0109\7k\2\2\u0109\u010a\7v\2\2\u010a\u010b\7u\2\2"\r
-            + "\u010b\u010c\3\2\2\2\u010c\u010d\b\16\16\2\u010d\35\3\2\2\2\u010e\u010f"\r
-            + "\7w\2\2\u010f\u0110\7p\2\2\u0110\u0111\7k\2\2\u0111\u0112\7s\2\2\u0112"\r
-            + "\u0113\7w\2\2\u0113\u0114\7g\2\2\u0114\u0115\3\2\2\2\u0115\u0116\b\17"\r
-            + "\17\2\u0116\37\3\2\2\2\u0117\u0118\7v\2\2\u0118\u0119\7{\2\2\u0119\u011a"\r
-            + "\7r\2\2\u011a\u011b\7g\2\2\u011b\u011c\7f\2\2\u011c\u011d\7g\2\2\u011d"\r
-            + "\u011e\7h\2\2\u011e\u011f\3\2\2\2\u011f\u0120\b\20\20\2\u0120!\3\2\2\2"\r
-            + "\u0121\u0122\7v\2\2\u0122\u0123\7{\2\2\u0123\u0124\7r\2\2\u0124\u0125"\r
-            + "\7g\2\2\u0125\u0126\3\2\2\2\u0126\u0127\b\21\21\2\u0127#\3\2\2\2\u0128"\r
-            + "\u0129\7u\2\2\u0129\u012a\7w\2\2\u012a\u012b\7d\2\2\u012b\u012c\7o\2\2"\r
-            + "\u012c\u012d\7q\2\2\u012d\u012e\7f\2\2\u012e\u012f\7w\2\2\u012f\u0130"\r
-            + "\7n\2\2\u0130\u0131\7g\2\2\u0131\u0132\3\2\2\2\u0132\u0133\b\22\22\2\u0133"\r
-            + "%\3\2\2\2\u0134\u0135\7u\2\2\u0135\u0136\7v\2\2\u0136\u0137\7c\2\2\u0137"\r
-            + "\u0138\7v\2\2\u0138\u0139\7w\2\2\u0139\u013a\7u\2\2\u013a\u013b\3\2\2"\r
-            + "\2\u013b\u013c\b\23\23\2\u013c\'\3\2\2\2\u013d\u013e\7t\2\2\u013e\u013f"\r
-            + "\7r\2\2\u013f\u0140\7e\2\2\u0140\u0141\3\2\2\2\u0141\u0142\b\24\24\2\u0142"\r
-            + ")\3\2\2\2\u0143\u0144\7t\2\2\u0144\u0145\7g\2\2\u0145\u0146\7x\2\2\u0146"\r
-            + "\u0147\7k\2\2\u0147\u0148\7u\2\2\u0148\u0149\7k\2\2\u0149\u014a\7q\2\2"\r
-            + "\u014a\u014b\7p\2\2\u014b\u014c\7/\2\2\u014c\u014d\7f\2\2\u014d\u014e"\r
-            + "\7c\2\2\u014e\u014f\7v\2\2\u014f\u0150\7g\2\2\u0150\u0151\3\2\2\2\u0151"\r
-            + "\u0152\b\25\25\2\u0152+\3\2\2\2\u0153\u0154\7t\2\2\u0154\u0155\7g\2\2"\r
-            + "\u0155\u0156\7x\2\2\u0156\u0157\7k\2\2\u0157\u0158\7u\2\2\u0158\u0159"\r
-            + "\7k\2\2\u0159\u015a\7q\2\2\u015a\u015b\7p\2\2\u015b\u015c\3\2\2\2\u015c"\r
-            + "\u015d\b\26\26\2\u015d-\3\2\2\2\u015e\u015f\7t\2\2\u015f\u0160\7g\2\2"\r
-            + "\u0160\u0161\7s\2\2\u0161\u0162\7w\2\2\u0162\u0163\7k\2\2\u0163\u0164"\r
-            + "\7t\2\2\u0164\u0165\7g\2\2\u0165\u0166\7/\2\2\u0166\u0167\7k\2\2\u0167"\r
-            + "\u0168\7p\2\2\u0168\u0169\7u\2\2\u0169\u016a\7v\2\2\u016a\u016b\7c\2\2"\r
-            + "\u016b\u016c\7p\2\2\u016c\u016d\7e\2\2\u016d\u016e\7g\2\2\u016e\u016f"\r
-            + "\3\2\2\2\u016f\u0170\b\27\27\2\u0170/\3\2\2\2\u0171\u0172\7t\2\2\u0172"\r
-            + "\u0173\7g\2\2\u0173\u0174\7h\2\2\u0174\u0175\7k\2\2\u0175\u0176\7p\2\2"\r
-            + "\u0176\u0177\7g\2\2\u0177\u0178\3\2\2\2\u0178\u0179\b\30\30\2\u0179\61"\r
-            + "\3\2\2\2\u017a\u017b\7t\2\2\u017b\u017c\7g\2\2\u017c\u017d\7h\2\2\u017d"\r
-            + "\u017e\7g\2\2\u017e\u017f\7t\2\2\u017f\u0180\7g\2\2\u0180\u0181\7p\2\2"\r
-            + "\u0181\u0182\7e\2\2\u0182\u0183\7g\2\2\u0183\u0184\3\2\2\2\u0184\u0185"\r
-            + "\b\31\31\2\u0185\63\3\2\2\2\u0186\u0187\7t\2\2\u0187\u0188\7c\2\2\u0188"\r
-            + "\u0189\7p\2\2\u0189\u018a\7i\2\2\u018a\u018b\7g\2\2\u018b\u018c\3\2\2"\r
-            + "\2\u018c\u018d\b\32\32\2\u018d\65\3\2\2\2\u018e\u018f\7r\2\2\u018f\u0190"\r
-            + "\7t\2\2\u0190\u0191\7g\2\2\u0191\u0192\7u\2\2\u0192\u0193\7g\2\2\u0193"\r
-            + "\u0194\7p\2\2\u0194\u0195\7e\2\2\u0195\u0196\7g\2\2\u0196\u0197\3\2\2"\r
-            + "\2\u0197\u0198\b\33\33\2\u0198\67\3\2\2\2\u0199\u019a\7r\2\2\u019a\u019b"\r
-            + "\7t\2\2\u019b\u019c\7g\2\2\u019c\u019d\7h\2\2\u019d\u019e\7k\2\2\u019e"\r
-            + "\u019f\7z\2\2\u019f\u01a0\3\2\2\2\u01a0\u01a1\b\34\34\2\u01a19\3\2\2\2"\r
-            + "\u01a2\u01a3\7r\2\2\u01a3\u01a4\7q\2\2\u01a4\u01a5\7u\2\2\u01a5\u01a6"\r
-            + "\7k\2\2\u01a6\u01a7\7v\2\2\u01a7\u01a8\7k\2\2\u01a8\u01a9\7q\2\2\u01a9"\r
-            + "\u01aa\7p\2\2\u01aa\u01ab\3\2\2\2\u01ab\u01ac\b\35\35\2\u01ac;\3\2\2\2"\r
-            + "\u01ad\u01ae\7r\2\2\u01ae\u01af\7c\2\2\u01af\u01b0\7v\2\2\u01b0\u01b1"\r
-            + "\7v\2\2\u01b1\u01b2\7g\2\2\u01b2\u01b3\7t\2\2\u01b3\u01b4\7p\2\2\u01b4"\r
-            + "\u01b5\3\2\2\2\u01b5\u01b6\b\36\36\2\u01b6=\3\2\2\2\u01b7\u01b8\7r\2\2"\r
-            + "\u01b8\u01b9\7c\2\2\u01b9\u01ba\7v\2\2\u01ba\u01bb\7j\2\2\u01bb\u01bc"\r
-            + "\3\2\2\2\u01bc\u01bd\b\37\37\2\u01bd?\3\2\2\2\u01be\u01bf\7q\2\2\u01bf"\r
-            + "\u01c0\7w\2\2\u01c0\u01c1\7v\2\2\u01c1\u01c2\7r\2\2\u01c2\u01c3\7w\2\2"\r
-            + "\u01c3\u01c4\7v\2\2\u01c4A\3\2\2\2\u01c5\u01c6\7q\2\2\u01c6\u01c7\7t\2"\r
-            + "\2\u01c7\u01c8\7i\2\2\u01c8\u01c9\7c\2\2\u01c9\u01ca\7p\2\2\u01ca\u01cb"\r
-            + "\7k\2\2\u01cb\u01cc\7|\2\2\u01cc\u01cd\7c\2\2\u01cd\u01ce\7v\2\2\u01ce"\r
-            + "\u01cf\7k\2\2\u01cf\u01d0\7q\2\2\u01d0\u01d1\7p\2\2\u01d1\u01d2\3\2\2"\r
-            + "\2\u01d2\u01d3\b! \2\u01d3C\3\2\2\2\u01d4\u01d5\7q\2\2\u01d5\u01d6\7t"\r
-            + "\2\2\u01d6\u01d7\7f\2\2\u01d7\u01d8\7g\2\2\u01d8\u01d9\7t\2\2\u01d9\u01da"\r
-            + "\7g\2\2\u01da\u01db\7f\2\2\u01db\u01dc\7/\2\2\u01dc\u01dd\7d\2\2\u01dd"\r
-            + "\u01de\7{\2\2\u01de\u01df\3\2\2\2\u01df\u01e0\b\"!\2\u01e0E\3\2\2\2\u01e1"\r
-            + "\u01e2\7p\2\2\u01e2\u01e3\7q\2\2\u01e3\u01e4\7v\2\2\u01e4\u01e5\7k\2\2"\r
-            + "\u01e5\u01e6\7h\2\2\u01e6\u01e7\7k\2\2\u01e7\u01e8\7e\2\2\u01e8\u01e9"\r
-            + "\7c\2\2\u01e9\u01ea\7v\2\2\u01ea\u01eb\7k\2\2\u01eb\u01ec\7q\2\2\u01ec"\r
-            + "\u01ed\7p\2\2\u01ed\u01ee\3\2\2\2\u01ee\u01ef\b#\"\2\u01efG\3\2\2\2\u01f0"\r
-            + "\u01f1\7p\2\2\u01f1\u01f2\7c\2\2\u01f2\u01f3\7o\2\2\u01f3\u01f4\7g\2\2"\r
-            + "\u01f4\u01f5\7u\2\2\u01f5\u01f6\7r\2\2\u01f6\u01f7\7c\2\2\u01f7\u01f8"\r
-            + "\7e\2\2\u01f8\u01f9\7g\2\2\u01f9\u01fa\3\2\2\2\u01fa\u01fb\b$#\2\u01fb"\r
-            + "I\3\2\2\2\u01fc\u01fd\7o\2\2\u01fd\u01fe\7w\2\2\u01fe\u01ff\7u\2\2\u01ff"\r
-            + "\u0200\7v\2\2\u0200\u0201\3\2\2\2\u0201\u0202\b%$\2\u0202K\3\2\2\2\u0203"\r
-            + "\u0204\7o\2\2\u0204\u0205\7q\2\2\u0205\u0206\7f\2\2\u0206\u0207\7w\2\2"\r
-            + "\u0207\u0208\7n\2\2\u0208\u0209\7g\2\2\u0209\u020a\3\2\2\2\u020a\u020b"\r
-            + "\b&%\2\u020bM\3\2\2\2\u020c\u020d\7o\2\2\u020d\u020e\7k\2\2\u020e\u020f"\r
-            + "\7p\2\2\u020f\u0210\7/\2\2\u0210\u0211\7g\2\2\u0211\u0212\7n\2\2\u0212"\r
-            + "\u0213\7g\2\2\u0213\u0214\7o\2\2\u0214\u0215\7g\2\2\u0215\u0216\7p\2\2"\r
-            + "\u0216\u0217\7v\2\2\u0217\u0218\7u\2\2\u0218\u0219\3\2\2\2\u0219\u021a"\r
-            + "\b\'&\2\u021aO\3\2\2\2\u021b\u021c\7o\2\2\u021c\u021d\7c\2\2\u021d\u021e"\r
-            + "\7z\2\2\u021e\u021f\7/\2\2\u021f\u0220\7g\2\2\u0220\u0221\7n\2\2\u0221"\r
-            + "\u0222\7g\2\2\u0222\u0223\7o\2\2\u0223\u0224\7g\2\2\u0224\u0225\7p\2\2"\r
-            + "\u0225\u0226\7v\2\2\u0226\u0227\7u\2\2\u0227\u0228\3\2\2\2\u0228\u0229"\r
-            + "\b(\'\2\u0229Q\3\2\2\2\u022a\u022b\7o\2\2\u022b\u022c\7c\2\2\u022c\u022d"\r
-            + "\7p\2\2\u022d\u022e\7f\2\2\u022e\u022f\7c\2\2\u022f\u0230\7v\2\2\u0230"\r
-            + "\u0231\7q\2\2\u0231\u0232\7t\2\2\u0232\u0233\7{\2\2\u0233\u0234\3\2\2"\r
-            + "\2\u0234\u0235\b)(\2\u0235S\3\2\2\2\u0236\u0237\7n\2\2\u0237\u0238\7k"\r
-            + "\2\2\u0238\u0239\7u\2\2\u0239\u023a\7v\2\2\u023a\u023b\3\2\2\2\u023b\u023c"\r
-            + "\b*)\2\u023cU\3\2\2\2\u023d\u023e\7n\2\2\u023e\u023f\7g\2\2\u023f\u0240"\r
-            + "\7p\2\2\u0240\u0241\7i\2\2\u0241\u0242\7v\2\2\u0242\u0243\7j\2\2\u0243"\r
-            + "\u0244\3\2\2\2\u0244\u0245\b+*\2\u0245W\3\2\2\2\u0246\u0247\7n\2\2\u0247"\r
-            + "\u0248\7g\2\2\u0248\u0249\7c\2\2\u0249\u024a\7h\2\2\u024a\u024b\7/\2\2"\r
-            + "\u024b\u024c\7n\2\2\u024c\u024d\7k\2\2\u024d\u024e\7u\2\2\u024e\u024f"\r
-            + "\7v\2\2\u024f\u0250\3\2\2\2\u0250\u0251\b,+\2\u0251Y\3\2\2\2\u0252\u0253"\r
-            + "\7n\2\2\u0253\u0254\7g\2\2\u0254\u0255\7c\2\2\u0255\u0256\7h\2\2\u0256"\r
-            + "\u0257\3\2\2\2\u0257\u0258\b-,\2\u0258[\3\2\2\2\u0259\u025a\7m\2\2\u025a"\r
-            + "\u025b\7g\2\2\u025b\u025c\7{\2\2\u025c\u025d\3\2\2\2\u025d\u025e\b.-\2"\r
-            + "\u025e]\3\2\2\2\u025f\u0260\7k\2\2\u0260\u0261\7p\2\2\u0261\u0262\7r\2"\r
-            + "\2\u0262\u0263\7w\2\2\u0263\u0264\7v\2\2\u0264_\3\2\2\2\u0265\u0266\7"\r
-            + "k\2\2\u0266\u0267\7p\2\2\u0267\u0268\7e\2\2\u0268\u0269\7n\2\2\u0269\u026a"\r
-            + "\7w\2\2\u026a\u026b\7f\2\2\u026b\u026c\7g\2\2\u026c\u026d\3\2\2\2\u026d"\r
-            + "\u026e\b\60.\2\u026ea\3\2\2\2\u026f\u0270\7k\2\2\u0270\u0271\7o\2\2\u0271"\r
-            + "\u0272\7r\2\2\u0272\u0273\7q\2\2\u0273\u0274\7t\2\2\u0274\u0275\7v\2\2"\r
-            + "\u0275\u0276\3\2\2\2\u0276\u0277\b\61/\2\u0277c\3\2\2\2\u0278\u0279\7"\r
-            + "k\2\2\u0279\u027a\7h\2\2\u027a\u027b\7/\2\2\u027b\u027c\7h\2\2\u027c\u027d"\r
-            + "\7g\2\2\u027d\u027e\7c\2\2\u027e\u027f\7v\2\2\u027f\u0280\7w\2\2\u0280"\r
-            + "\u0281\7t\2\2\u0281\u0282\7g\2\2\u0282\u0283\3\2\2\2\u0283\u0284\b\62"\r
-            + "\60\2\u0284e\3\2\2\2\u0285\u0286\7k\2\2\u0286\u0287\7f\2\2\u0287\u0288"\r
-            + "\7g\2\2\u0288\u0289\7p\2\2\u0289\u028a\7v\2\2\u028a\u028b\7k\2\2\u028b"\r
-            + "\u028c\7v\2\2\u028c\u028d\7{\2\2\u028d\u028e\3\2\2\2\u028e\u028f\b\63"\r
-            + "\61\2\u028fg\3\2\2\2\u0290\u0291\7i\2\2\u0291\u0292\7t\2\2\u0292\u0293"\r
-            + "\7q\2\2\u0293\u0294\7w\2\2\u0294\u0295\7r\2\2\u0295\u0296\7k\2\2\u0296"\r
-            + "\u0297\7p\2\2\u0297\u0298\7i\2\2\u0298\u0299\3\2\2\2\u0299\u029a\b\64"\r
-            + "\62\2\u029ai\3\2\2\2\u029b\u029c\7h\2\2\u029c\u029d\7t\2\2\u029d\u029e"\r
-            + "\7c\2\2\u029e\u029f\7e\2\2\u029f\u02a0\7v\2\2\u02a0\u02a1\7k\2\2\u02a1"\r
-            + "\u02a2\7q\2\2\u02a2\u02a3\7p\2\2\u02a3\u02a4\7/\2\2\u02a4\u02a5\7f\2\2"\r
-            + "\u02a5\u02a6\7k\2\2\u02a6\u02a7\7i\2\2\u02a7\u02a8\7k\2\2\u02a8\u02a9"\r
-            + "\7v\2\2\u02a9\u02aa\7u\2\2\u02aa\u02ab\3\2\2\2\u02ab\u02ac\b\65\63\2\u02ac"\r
-            + "k\3\2\2\2\u02ad\u02ae\7h\2\2\u02ae\u02af\7g\2\2\u02af\u02b0\7c\2\2\u02b0"\r
-            + "\u02b1\7v\2\2\u02b1\u02b2\7w\2\2\u02b2\u02b3\7t\2\2\u02b3\u02b4\7g\2\2"\r
-            + "\u02b4\u02b5\3\2\2\2\u02b5\u02b6\b\66\64\2\u02b6m\3\2\2\2\u02b7\u02b8"\r
-            + "\7f\2\2\u02b8\u02b9\7g\2\2\u02b9\u02ba\7x\2\2\u02ba\u02bb\7k\2\2\u02bb"\r
-            + "\u02bc\7c\2\2\u02bc\u02bd\7v\2\2\u02bd\u02be\7g\2\2\u02be\u02bf\3\2\2"\r
-            + "\2\u02bf\u02c0\b\67\65\2\u02c0o\3\2\2\2\u02c1\u02c2\7f\2\2\u02c2\u02c3"\r
-            + "\7g\2\2\u02c3\u02c4\7x\2\2\u02c4\u02c5\7k\2\2\u02c5\u02c6\7c\2\2\u02c6"\r
-            + "\u02c7\7v\2\2\u02c7\u02c8\7k\2\2\u02c8\u02c9\7q\2\2\u02c9\u02ca\7p\2\2"\r
-            + "\u02ca\u02cb\3\2\2\2\u02cb\u02cc\b8\66\2\u02ccq\3\2\2\2\u02cd\u02ce\7"\r
-            + "g\2\2\u02ce\u02cf\7z\2\2\u02cf\u02d0\7v\2\2\u02d0\u02d1\7g\2\2\u02d1\u02d2"\r
-            + "\7p\2\2\u02d2\u02d3\7u\2\2\u02d3\u02d4\7k\2\2\u02d4\u02d5\7q\2\2\u02d5"\r
-            + "\u02d6\7p\2\2\u02d6\u02d7\3\2\2\2\u02d7\u02d8\b9\67\2\u02d8s\3\2\2\2\u02d9"\r
-            + "\u02da\7g\2\2\u02da\u02db\7t\2\2\u02db\u02dc\7t\2\2\u02dc\u02dd\7q\2\2"\r
-            + "\u02dd\u02de\7t\2\2\u02de\u02df\7/\2\2\u02df\u02e0\7o\2\2\u02e0\u02e1"\r
-            + "\7g\2\2\u02e1\u02e2\7u\2\2\u02e2\u02e3\7u\2\2\u02e3\u02e4\7c\2\2\u02e4"\r
-            + "\u02e5\7i\2\2\u02e5\u02e6\7g\2\2\u02e6\u02e7\3\2\2\2\u02e7\u02e8\b:8\2"\r
-            + "\u02e8u\3\2\2\2\u02e9\u02ea\7g\2\2\u02ea\u02eb\7t\2\2\u02eb\u02ec\7t\2"\r
-            + "\2\u02ec\u02ed\7q\2\2\u02ed\u02ee\7t\2\2\u02ee\u02ef\7/\2\2\u02ef\u02f0"\r
-            + "\7c\2\2\u02f0\u02f1\7r\2\2\u02f1\u02f2\7r\2\2\u02f2\u02f3\7/\2\2\u02f3"\r
-            + "\u02f4\7v\2\2\u02f4\u02f5\7c\2\2\u02f5\u02f6\7i\2\2\u02f6\u02f7\3\2\2"\r
-            + "\2\u02f7\u02f8\b;9\2\u02f8w\3\2\2\2\u02f9\u02fa\7g\2\2\u02fa\u02fb\7p"\r
-            + "\2\2\u02fb\u02fc\7w\2\2\u02fc\u02fd\7o\2\2\u02fd\u02fe\3\2\2\2\u02fe\u02ff"\r
-            + "\b<:\2\u02ffy\3\2\2\2\u0300\u0301\7f\2\2\u0301\u0302\7g\2\2\u0302\u0303"\r
-            + "\7u\2\2\u0303\u0304\7e\2\2\u0304\u0305\7t\2\2\u0305\u0306\7k\2\2\u0306"\r
-            + "\u0307\7r\2\2\u0307\u0308\7v\2\2\u0308\u0309\7k\2\2\u0309\u030a\7q\2\2"\r
-            + "\u030a\u030b\7p\2\2\u030b\u030c\3\2\2\2\u030c\u030d\b=;\2\u030d{\3\2\2"\r
-            + "\2\u030e\u030f\7f\2\2\u030f\u0310\7g\2\2\u0310\u0311\7h\2\2\u0311\u0312"\r
-            + "\7c\2\2\u0312\u0313\7w\2\2\u0313\u0314\7n\2\2\u0314\u0315\7v\2\2\u0315"\r
-            + "\u0316\3\2\2\2\u0316\u0317\b><\2\u0317}\3\2\2\2\u0318\u0319\7e\2\2\u0319"\r
-            + "\u031a\7q\2\2\u031a\u031b\7p\2\2\u031b\u031c\7v\2\2\u031c\u031d\7c\2\2"\r
-            + "\u031d\u031e\7k\2\2\u031e\u031f\7p\2\2\u031f\u0320\7g\2\2\u0320\u0321"\r
-            + "\7t\2\2\u0321\u0322\3\2\2\2\u0322\u0323\b?=\2\u0323\177\3\2\2\2\u0324"\r
-            + "\u0325\7e\2\2\u0325\u0326\7q\2\2\u0326\u0327\7p\2\2\u0327\u0328\7v\2\2"\r
-            + "\u0328\u0329\7c\2\2\u0329\u032a\7e\2\2\u032a\u032b\7v\2\2\u032b\u032c"\r
-            + "\3\2\2\2\u032c\u032d\b@>\2\u032d\u0081\3\2\2\2\u032e\u032f\7e\2\2\u032f"\r
-            + "\u0330\7q\2\2\u0330\u0331\7p\2\2\u0331\u0332\7h\2\2\u0332\u0333\7k\2\2"\r
-            + "\u0333\u0334\7i\2\2\u0334\u0335\3\2\2\2\u0335\u0336\bA?\2\u0336\u0083"\r
-            + "\3\2\2\2\u0337\u0338\7e\2\2\u0338\u0339\7j\2\2\u0339\u033a\7q\2\2\u033a"\r
-            + "\u033b\7k\2\2\u033b\u033c\7e\2\2\u033c\u033d\7g\2\2\u033d\u033e\3\2\2"\r
-            + "\2\u033e\u033f\bB@\2\u033f\u0085\3\2\2\2\u0340\u0341\7e\2\2\u0341\u0342"\r
-            + "\7c\2\2\u0342\u0343\7u\2\2\u0343\u0344\7g\2\2\u0344\u0345\3\2\2\2\u0345"\r
-            + "\u0346\bCA\2\u0346\u0087\3\2\2\2\u0347\u0348\7d\2\2\u0348\u0349\7k\2\2"\r
-            + "\u0349\u034a\7v\2\2\u034a\u034b\3\2\2\2\u034b\u034c\bDB\2\u034c\u0089"\r
-            + "\3\2\2\2\u034d\u034e\7d\2\2\u034e\u034f\7g\2\2\u034f\u0350\7n\2\2\u0350"\r
-            + "\u0351\7q\2\2\u0351\u0352\7p\2\2\u0352\u0353\7i\2\2\u0353\u0354\7u\2\2"\r
-            + "\u0354\u0355\7/\2\2\u0355\u0356\7v\2\2\u0356\u0357\7q\2\2\u0357\u0358"\r
-            + "\3\2\2\2\u0358\u0359\bEC\2\u0359\u008b\3\2\2\2\u035a\u035b\7d\2\2\u035b"\r
-            + "\u035c\7c\2\2\u035c\u035d\7u\2\2\u035d\u035e\7g\2\2\u035e\u035f\3\2\2"\r
-            + "\2\u035f\u0360\bFD\2\u0360\u008d\3\2\2\2\u0361\u0362\7c\2\2\u0362\u0363"\r
-            + "\7w\2\2\u0363\u0364\7i\2\2\u0364\u0365\7o\2\2\u0365\u0366\7g\2\2\u0366"\r
-            + "\u0367\7p\2\2\u0367\u0368\7v\2\2\u0368\u0369\3\2\2\2\u0369\u036a\bGE\2"\r
-            + "\u036a\u008f\3\2\2\2\u036b\u036c\7c\2\2\u036c\u036d\7t\2\2\u036d\u036e"\r
-            + "\7i\2\2\u036e\u036f\7w\2\2\u036f\u0370\7o\2\2\u0370\u0371\7g\2\2\u0371"\r
-            + "\u0372\7p\2\2\u0372\u0373\7v\2\2\u0373\u0374\3\2\2\2\u0374\u0375\bHF\2"\r
-            + "\u0375\u0091\3\2\2\2\u0376\u0377\7c\2\2\u0377\u0378\7p\2\2\u0378\u0379"\r
-            + "\7{\2\2\u0379\u037a\7z\2\2\u037a\u037b\7o\2\2\u037b\u037c\7n\2\2\u037c"\r
-            + "\u037d\3\2\2\2\u037d\u037e\bIG\2\u037e\u0093\3\2\2\2\u037f\u0383\t\5\2"\r
-            + "\2\u0380\u0382\t\6\2\2\u0381\u0380\3\2\2\2\u0382\u0385\3\2\2\2\u0383\u0381"\r
-            + "\3\2\2\2\u0383\u0384\3\2\2\2\u0384\u0386\3\2\2\2\u0385\u0383\3\2\2\2\u0386"\r
-            + "\u0387\bJH\2\u0387\u0095\3\2\2\2\u0388\u038b\7^\2\2\u0389\u038c\t\7\2"\r
-            + "\2\u038a\u038c\5\u0098L\2\u038b\u0389\3\2\2\2\u038b\u038a\3\2\2\2\u038c"\r
-            + "\u0097\3\2\2\2\u038d\u038e\7w\2\2\u038e\u038f\5\u009aM\2\u038f\u0390\5"\r
-            + "\u009aM\2\u0390\u0391\5\u009aM\2\u0391\u0392\5\u009aM\2\u0392\u0099\3"\r
-            + "\2\2\2\u0393\u0394\t\b\2\2\u0394\u009b\3\2\2\2\u0395\u0396\7=\2\2\u0396"\r
-            + "\u0397\3\2\2\2\u0397\u0398\bNI\2\u0398\u009d\3\2\2\2\u0399\u039a\7}\2"\r
-            + "\2\u039a\u039b\3\2\2\2\u039b\u039c\bOJ\2\u039c\u009f\3\2\2\2\u039d\u03a2"\r
-            + "\7$\2\2\u039e\u03a1\5\u0096K\2\u039f\u03a1\n\t\2\2\u03a0\u039e\3\2\2\2"\r
-            + "\u03a0\u039f\3\2\2\2\u03a1\u03a4\3\2\2\2\u03a2\u03a0\3\2\2\2\u03a2\u03a3"\r
-            + "\3\2\2\2\u03a3\u03a5\3\2\2\2\u03a4\u03a2\3\2\2\2\u03a5\u03b0\7$\2\2\u03a6"\r
-            + "\u03ab\7)\2\2\u03a7\u03aa\5\u0096K\2\u03a8\u03aa\n\n\2\2\u03a9\u03a7\3"\r
-            + "\2\2\2\u03a9\u03a8\3\2\2\2\u03aa\u03ad\3\2\2\2\u03ab\u03a9\3\2\2\2\u03ab"\r
-            + "\u03ac\3\2\2\2\u03ac\u03ae\3\2\2\2\u03ad\u03ab\3\2\2\2\u03ae\u03b0\7)"\r
-            + "\2\2\u03af\u039d\3\2\2\2\u03af\u03a6\3\2\2\2\u03b0\u00a1\3\2\2\2\u03b1"\r
-            + "\u03b8\5\u00a0P\2\u03b2\u03b4\n\13\2\2\u03b3\u03b2\3\2\2\2\u03b4\u03b5"\r
-            + "\3\2\2\2\u03b5\u03b3\3\2\2\2\u03b5\u03b6\3\2\2\2\u03b6\u03b8\3\2\2\2\u03b7"\r
-            + "\u03b1\3\2\2\2\u03b7\u03b3\3\2\2\2\u03b8\u03b9\3\2\2\2\u03b9\u03ba\bQ"\r
-            + "K\2\u03ba\u00a3\3\2\2\2\u03bb\u03bc\t\f\2\2\u03bc\u03bd\3\2\2\2\u03bd"\r
-            + "\u03be\bRL\2\u03be\u00a5\3\2\2\2\17\2\3\u00b4\u00bf\u0383\u038b\u03a0"\r
-            + "\u03a2\u03a9\u03ab\u03af\u03b5\u03b7";\r
+    public static final String _serializedATN = "\2\4N\u03c4\b\1\b\1\b\1\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t"\r
+            + "\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t"\r
+            + "\17\4\20\t\20\4\21\t\21\4\22\t\22\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t"\r
+            + "\26\4\27\t\27\4\30\t\30\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t"\r
+            + "\35\4\36\t\36\4\37\t\37\4 \t \4!\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4"\r
+            + "\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4,\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61"\r
+            + "\t\61\4\62\t\62\4\63\t\63\4\64\t\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t"\r
+            + "8\49\t9\4:\t:\4;\t;\4<\t<\4=\t=\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4"\r
+            + "D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\t"\r
+            + "O\4P\tP\4Q\tQ\4R\tR\4S\tS\4T\tT\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\4\3"\r
+            + "\4\3\4\3\4\7\4\u00b8\n\4\f\4\16\4\u00bb\13\4\3\4\3\4\3\5\3\5\3\5\3\5\3"\r
+            + "\5\3\6\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t"\r
+            + "\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3\n\3"\r
+            + "\n\3\n\3\n\3\n\3\n\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f"\r
+            + "\3\f\3\f\3\f\3\f\3\f\3\f\3\r\3\r\3\r\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3"\r
+            + "\16\3\16\3\16\3\16\3\16\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3\17\3"\r
+            + "\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3\21\3"\r
+            + "\21\3\21\3\21\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3"\r
+            + "\22\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\23\3\24\3\24\3\24\3\24\3"\r
+            + "\24\3\24\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3\25\3"\r
+            + "\25\3\25\3\25\3\25\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3\26\3"\r
+            + "\26\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3\27\3"\r
+            + "\27\3\27\3\27\3\27\3\27\3\27\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3\30\3"\r
+            + "\30\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3\31\3\32\3"\r
+            + "\32\3\32\3\32\3\32\3\32\3\32\3\32\3\33\3\33\3\33\3\33\3\33\3\33\3\33\3"\r
+            + "\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34\3\34\3\34\3\34\3\34\3\34\3\35\3"\r
+            + "\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\35\3\36\3\36\3\36\3\36\3"\r
+            + "\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37\3\37\3\37\3\37\3\37\3\37\3 \3 "\r
+            + "\3 \3 \3 \3 \3 \3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3!\3\"\3\"\3"\r
+            + "\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3\"\3#\3#\3#\3#\3#\3#\3#\3#\3#"\r
+            + "\3#\3#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3$\3$\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%"\r
+            + "\3%\3%\3&\3&\3&\3&\3&\3&\3&\3&\3&\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'\3\'"\r
+            + "\3\'\3\'\3\'\3\'\3\'\3\'\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3(\3("\r
+            + "\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3)\3*\3*\3*\3*\3*\3*\3*\3+\3+\3+\3+"\r
+            + "\3+\3+\3+\3+\3+\3,\3,\3,\3,\3,\3,\3,\3,\3,\3,\3,\3,\3-\3-\3-\3-\3-\3-"\r
+            + "\3-\3.\3.\3.\3.\3.\3.\3/\3/\3/\3/\3/\3/\3\60\3\60\3\60\3\60\3\60\3\60"\r
+            + "\3\60\3\60\3\60\3\60\3\61\3\61\3\61\3\61\3\61\3\61\3\61\3\61\3\61\3\62"\r
+            + "\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\62\3\63\3\63"\r
+            + "\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\63\3\64\3\64\3\64\3\64\3\64"\r
+            + "\3\64\3\64\3\64\3\64\3\64\3\64\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\65"\r
+            + "\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\65\3\66\3\66\3\66\3\66"\r
+            + "\3\66\3\66\3\66\3\66\3\66\3\66\3\67\3\67\3\67\3\67\3\67\3\67\3\67\3\67"\r
+            + "\3\67\3\67\38\38\38\38\38\38\38\38\38\38\38\38\39\39\39\39\39\39\39\3"\r
+            + "9\39\39\39\39\3:\3:\3:\3:\3:\3:\3:\3:\3:\3:\3:\3:\3:\3:\3:\3:\3;\3;\3"\r
+            + ";\3;\3;\3;\3;\3;\3;\3;\3;\3;\3;\3;\3;\3;\3<\3<\3<\3<\3<\3<\3<\3=\3=\3"\r
+            + "=\3=\3=\3=\3=\3=\3=\3=\3=\3=\3=\3=\3>\3>\3>\3>\3>\3>\3>\3>\3>\3>\3?\3"\r
+            + "?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3?\3@\3@\3@\3@\3@\3@\3@\3@\3@\3@\3A\3A\3"\r
+            + "A\3A\3A\3A\3A\3A\3A\3B\3B\3B\3B\3B\3B\3B\3B\3B\3C\3C\3C\3C\3C\3C\3C\3"\r
+            + "D\3D\3D\3D\3D\3D\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3E\3F\3F\3F\3F\3"\r
+            + "F\3F\3F\3G\3G\3G\3G\3G\3G\3G\3G\3G\3G\3H\3H\3H\3H\3H\3H\3H\3H\3H\3H\3"\r
+            + "H\3I\3I\3I\3I\3I\3I\3I\3I\3I\3J\3J\7J\u037e\nJ\fJ\16J\u0381\13J\3J\3J"\r
+            + "\3K\3K\3K\5K\u0388\nK\3L\3L\3L\3L\3L\3L\3M\3M\3N\3N\3N\3N\3O\3O\3O\3O"\r
+            + "\3P\3P\3P\7P\u039d\nP\fP\16P\u03a0\13P\3P\3P\3P\3P\7P\u03a6\nP\fP\16P"\r
+            + "\u03a9\13P\3P\5P\u03ac\nP\3Q\3Q\6Q\u03b0\nQ\rQ\16Q\u03b1\5Q\u03b4\nQ\3"\r
+            + "Q\3Q\3R\3R\3R\3R\3S\3S\3S\3S\3S\3T\3T\3T\3T\2U\5\6\2\7\7\3\t\b\4\13\t"\r
+            + "\5\r\3\6\17\4\7\21\5\b\23\n\t\25\13\n\27\f\13\31\r\f\33\16\r\35\17\16"\r
+            + "\37\20\17!\21\20#\22\21%\23\22\'\24\23)\25\24+\26\25-\27\26/\30\27\61"\r
+            + "\31\30\63\32\31\65\33\32\67\34\339\35\34;\36\35=\37\36? \37A!\1C\" E#"\r
+            + "!G$\"I%#K&$M\'%O(&Q)\'S*(U+)W,*Y-+[.,]/-_\60\1a\61.c\62/e\63\60g\64\61"\r
+            + "i\65\62k\66\63m\67\64o8\65q9\66s:\67u;8w<9y=:{>;}?<\177@=\u0081A>\u0083"\r
+            + "B?\u0085C@\u0087DA\u0089EB\u008bFC\u008dGD\u008fHE\u0091IF\u0093JG\u0095"\r
+            + "KH\u0097\2\1\u0099\2\1\u009b\2\1\u009d\2I\u009f\2J\u00a1\2\1\u00a3LK\u00a5"\r
+            + "ML\u00a7NM\u00a9\2N\5\2\3\4\f\5\13\f\17\17\"\"\4\f\f\17\17\6/;C\\aac|"\r
+            + "\7/\60\62<C\\aac|\n$$\61\61^^ddhhppttvv\5\62;CHch\3$$\3))\7\f\f\17\17"\r
+            + "\"\"==}}\5\13\f\17\17\"\"\u03c7\2\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2"\r
+            + "\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3"\r
+            + "\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2"\r
+            + "\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2"\r
+            + "\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2"\r
+            + "\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2"\r
+            + "\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q"\r
+            + "\3\2\2\2\2S\3\2\2\2\2U\3\2\2\2\2W\3\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2"\r
+            + "\2\2\2_\3\2\2\2\2a\3\2\2\2\2c\3\2\2\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2"\r
+            + "\2k\3\2\2\2\2m\3\2\2\2\2o\3\2\2\2\2q\3\2\2\2\2s\3\2\2\2\2u\3\2\2\2\2w"\r
+            + "\3\2\2\2\2y\3\2\2\2\2{\3\2\2\2\2}\3\2\2\2\2\177\3\2\2\2\2\u0081\3\2\2"\r
+            + "\2\2\u0083\3\2\2\2\2\u0085\3\2\2\2\2\u0087\3\2\2\2\2\u0089\3\2\2\2\2\u008b"\r
+            + "\3\2\2\2\2\u008d\3\2\2\2\2\u008f\3\2\2\2\2\u0091\3\2\2\2\2\u0093\3\2\2"\r
+            + "\2\2\u0095\3\2\2\2\3\u009d\3\2\2\2\3\u009f\3\2\2\2\3\u00a3\3\2\2\2\3\u00a5"\r
+            + "\3\2\2\2\4\u00a7\3\2\2\2\4\u00a9\3\2\2\2\5\u00ab\3\2\2\2\7\u00af\3\2\2"\r
+            + "\2\t\u00b3\3\2\2\2\13\u00be\3\2\2\2\r\u00c3\3\2\2\2\17\u00c7\3\2\2\2\21"\r
+            + "\u00cb\3\2\2\2\23\u00cf\3\2\2\2\25\u00dd\3\2\2\2\27\u00ec\3\2\2\2\31\u00f3"\r
+            + "\3\2\2\2\33\u00fb\3\2\2\2\35\u0102\3\2\2\2\37\u010a\3\2\2\2!\u0113\3\2"\r
+            + "\2\2#\u011d\3\2\2\2%\u0124\3\2\2\2\'\u0130\3\2\2\2)\u0139\3\2\2\2+\u013f"\r
+            + "\3\2\2\2-\u014f\3\2\2\2/\u015a\3\2\2\2\61\u016d\3\2\2\2\63\u0176\3\2\2"\r
+            + "\2\65\u0182\3\2\2\2\67\u018a\3\2\2\29\u0195\3\2\2\2;\u019e\3\2\2\2=\u01a9"\r
+            + "\3\2\2\2?\u01b3\3\2\2\2A\u01ba\3\2\2\2C\u01c1\3\2\2\2E\u01d0\3\2\2\2G"\r
+            + "\u01dd\3\2\2\2I\u01ec\3\2\2\2K\u01f8\3\2\2\2M\u01ff\3\2\2\2O\u0208\3\2"\r
+            + "\2\2Q\u0217\3\2\2\2S\u0226\3\2\2\2U\u0232\3\2\2\2W\u0239\3\2\2\2Y\u0242"\r
+            + "\3\2\2\2[\u024e\3\2\2\2]\u0255\3\2\2\2_\u025b\3\2\2\2a\u0261\3\2\2\2c"\r
+            + "\u026b\3\2\2\2e\u0274\3\2\2\2g\u0281\3\2\2\2i\u028c\3\2\2\2k\u0297\3\2"\r
+            + "\2\2m\u02a9\3\2\2\2o\u02b3\3\2\2\2q\u02bd\3\2\2\2s\u02c9\3\2\2\2u\u02d5"\r
+            + "\3\2\2\2w\u02e5\3\2\2\2y\u02f5\3\2\2\2{\u02fc\3\2\2\2}\u030a\3\2\2\2\177"\r
+            + "\u0314\3\2\2\2\u0081\u0320\3\2\2\2\u0083\u032a\3\2\2\2\u0085\u0333\3\2"\r
+            + "\2\2\u0087\u033c\3\2\2\2\u0089\u0343\3\2\2\2\u008b\u0349\3\2\2\2\u008d"\r
+            + "\u0356\3\2\2\2\u008f\u035d\3\2\2\2\u0091\u0367\3\2\2\2\u0093\u0372\3\2"\r
+            + "\2\2\u0095\u037b\3\2\2\2\u0097\u0384\3\2\2\2\u0099\u0389\3\2\2\2\u009b"\r
+            + "\u038f\3\2\2\2\u009d\u0391\3\2\2\2\u009f\u0395\3\2\2\2\u00a1\u03ab\3\2"\r
+            + "\2\2\u00a3\u03b3\3\2\2\2\u00a5\u03b7\3\2\2\2\u00a7\u03bb\3\2\2\2\u00a9"\r
+            + "\u03c0\3\2\2\2\u00ab\u00ac\7-\2\2\u00ac\u00ad\3\2\2\2\u00ad\u00ae\b\2"\r
+            + "\2\2\u00ae\6\3\2\2\2\u00af\u00b0\t\2\2\2\u00b0\u00b1\3\2\2\2\u00b1\u00b2"\r
+            + "\b\3\3\2\u00b2\b\3\2\2\2\u00b3\u00b4\7\61\2\2\u00b4\u00b5\7\61\2\2\u00b5"\r
+            + "\u00b9\3\2\2\2\u00b6\u00b8\n\3\2\2\u00b7\u00b6\3\2\2\2\u00b8\u00bb\3\2"\r
+            + "\2\2\u00b9\u00b7\3\2\2\2\u00b9\u00ba\3\2\2\2\u00ba\u00bc\3\2\2\2\u00bb"\r
+            + "\u00b9\3\2\2\2\u00bc\u00bd\b\4\4\2\u00bd\n\3\2\2\2\u00be\u00bf\7\61\2"\r
+            + "\2\u00bf\u00c0\7,\2\2\u00c0\u00c1\3\2\2\2\u00c1\u00c2\b\5\5\2\u00c2\f"\r
+            + "\3\2\2\2\u00c3\u00c4\7=\2\2\u00c4\u00c5\3\2\2\2\u00c5\u00c6\b\6\6\2\u00c6"\r
+            + "\16\3\2\2\2\u00c7\u00c8\7}\2\2\u00c8\u00c9\3\2\2\2\u00c9\u00ca\b\7\7\2"\r
+            + "\u00ca\20\3\2\2\2\u00cb\u00cc\7\177\2\2\u00cc\u00cd\3\2\2\2\u00cd\u00ce"\r
+            + "\b\b\b\2\u00ce\22\3\2\2\2\u00cf\u00d0\7{\2\2\u00d0\u00d1\7k\2\2\u00d1"\r
+            + "\u00d2\7p\2\2\u00d2\u00d3\7/\2\2\u00d3\u00d4\7g\2\2\u00d4\u00d5\7n\2\2"\r
+            + "\u00d5\u00d6\7g\2\2\u00d6\u00d7\7o\2\2\u00d7\u00d8\7g\2\2\u00d8\u00d9"\r
+            + "\7p\2\2\u00d9\u00da\7v\2\2\u00da\u00db\3\2\2\2\u00db\u00dc\b\t\t\2\u00dc"\r
+            + "\24\3\2\2\2\u00dd\u00de\7{\2\2\u00de\u00df\7c\2\2\u00df\u00e0\7p\2\2\u00e0"\r
+            + "\u00e1\7i\2\2\u00e1\u00e2\7/\2\2\u00e2\u00e3\7x\2\2\u00e3\u00e4\7g\2\2"\r
+            + "\u00e4\u00e5\7t\2\2\u00e5\u00e6\7u\2\2\u00e6\u00e7\7k\2\2\u00e7\u00e8"\r
+            + "\7q\2\2\u00e8\u00e9\7p\2\2\u00e9\u00ea\3\2\2\2\u00ea\u00eb\b\n\n\2\u00eb"\r
+            + "\26\3\2\2\2\u00ec\u00ed\7y\2\2\u00ed\u00ee\7j\2\2\u00ee\u00ef\7g\2\2\u00ef"\r
+            + "\u00f0\7p\2\2\u00f0\u00f1\3\2\2\2\u00f1\u00f2\b\13\13\2\u00f2\30\3\2\2"\r
+            + "\2\u00f3\u00f4\7x\2\2\u00f4\u00f5\7c\2\2\u00f5\u00f6\7n\2\2\u00f6\u00f7"\r
+            + "\7w\2\2\u00f7\u00f8\7g\2\2\u00f8\u00f9\3\2\2\2\u00f9\u00fa\b\f\f\2\u00fa"\r
+            + "\32\3\2\2\2\u00fb\u00fc\7w\2\2\u00fc\u00fd\7u\2\2\u00fd\u00fe\7g\2\2\u00fe"\r
+            + "\u00ff\7u\2\2\u00ff\u0100\3\2\2\2\u0100\u0101\b\r\r\2\u0101\34\3\2\2\2"\r
+            + "\u0102\u0103\7w\2\2\u0103\u0104\7p\2\2\u0104\u0105\7k\2\2\u0105\u0106"\r
+            + "\7v\2\2\u0106\u0107\7u\2\2\u0107\u0108\3\2\2\2\u0108\u0109\b\16\16\2\u0109"\r
+            + "\36\3\2\2\2\u010a\u010b\7w\2\2\u010b\u010c\7p\2\2\u010c\u010d\7k\2\2\u010d"\r
+            + "\u010e\7s\2\2\u010e\u010f\7w\2\2\u010f\u0110\7g\2\2\u0110\u0111\3\2\2"\r
+            + "\2\u0111\u0112\b\17\17\2\u0112 \3\2\2\2\u0113\u0114\7v\2\2\u0114\u0115"\r
+            + "\7{\2\2\u0115\u0116\7r\2\2\u0116\u0117\7g\2\2\u0117\u0118\7f\2\2\u0118"\r
+            + "\u0119\7g\2\2\u0119\u011a\7h\2\2\u011a\u011b\3\2\2\2\u011b\u011c\b\20"\r
+            + "\20\2\u011c\"\3\2\2\2\u011d\u011e\7v\2\2\u011e\u011f\7{\2\2\u011f\u0120"\r
+            + "\7r\2\2\u0120\u0121\7g\2\2\u0121\u0122\3\2\2\2\u0122\u0123\b\21\21\2\u0123"\r
+            + "$\3\2\2\2\u0124\u0125\7u\2\2\u0125\u0126\7w\2\2\u0126\u0127\7d\2\2\u0127"\r
+            + "\u0128\7o\2\2\u0128\u0129\7q\2\2\u0129\u012a\7f\2\2\u012a\u012b\7w\2\2"\r
+            + "\u012b\u012c\7n\2\2\u012c\u012d\7g\2\2\u012d\u012e\3\2\2\2\u012e\u012f"\r
+            + "\b\22\22\2\u012f&\3\2\2\2\u0130\u0131\7u\2\2\u0131\u0132\7v\2\2\u0132"\r
+            + "\u0133\7c\2\2\u0133\u0134\7v\2\2\u0134\u0135\7w\2\2\u0135\u0136\7u\2\2"\r
+            + "\u0136\u0137\3\2\2\2\u0137\u0138\b\23\23\2\u0138(\3\2\2\2\u0139\u013a"\r
+            + "\7t\2\2\u013a\u013b\7r\2\2\u013b\u013c\7e\2\2\u013c\u013d\3\2\2\2\u013d"\r
+            + "\u013e\b\24\24\2\u013e*\3\2\2\2\u013f\u0140\7t\2\2\u0140\u0141\7g\2\2"\r
+            + "\u0141\u0142\7x\2\2\u0142\u0143\7k\2\2\u0143\u0144\7u\2\2\u0144\u0145"\r
+            + "\7k\2\2\u0145\u0146\7q\2\2\u0146\u0147\7p\2\2\u0147\u0148\7/\2\2\u0148"\r
+            + "\u0149\7f\2\2\u0149\u014a\7c\2\2\u014a\u014b\7v\2\2\u014b\u014c\7g\2\2"\r
+            + "\u014c\u014d\3\2\2\2\u014d\u014e\b\25\25\2\u014e,\3\2\2\2\u014f\u0150"\r
+            + "\7t\2\2\u0150\u0151\7g\2\2\u0151\u0152\7x\2\2\u0152\u0153\7k\2\2\u0153"\r
+            + "\u0154\7u\2\2\u0154\u0155\7k\2\2\u0155\u0156\7q\2\2\u0156\u0157\7p\2\2"\r
+            + "\u0157\u0158\3\2\2\2\u0158\u0159\b\26\26\2\u0159.\3\2\2\2\u015a\u015b"\r
+            + "\7t\2\2\u015b\u015c\7g\2\2\u015c\u015d\7s\2\2\u015d\u015e\7w\2\2\u015e"\r
+            + "\u015f\7k\2\2\u015f\u0160\7t\2\2\u0160\u0161\7g\2\2\u0161\u0162\7/\2\2"\r
+            + "\u0162\u0163\7k\2\2\u0163\u0164\7p\2\2\u0164\u0165\7u\2\2\u0165\u0166"\r
+            + "\7v\2\2\u0166\u0167\7c\2\2\u0167\u0168\7p\2\2\u0168\u0169\7e\2\2\u0169"\r
+            + "\u016a\7g\2\2\u016a\u016b\3\2\2\2\u016b\u016c\b\27\27\2\u016c\60\3\2\2"\r
+            + "\2\u016d\u016e\7t\2\2\u016e\u016f\7g\2\2\u016f\u0170\7h\2\2\u0170\u0171"\r
+            + "\7k\2\2\u0171\u0172\7p\2\2\u0172\u0173\7g\2\2\u0173\u0174\3\2\2\2\u0174"\r
+            + "\u0175\b\30\30\2\u0175\62\3\2\2\2\u0176\u0177\7t\2\2\u0177\u0178\7g\2"\r
+            + "\2\u0178\u0179\7h\2\2\u0179\u017a\7g\2\2\u017a\u017b\7t\2\2\u017b\u017c"\r
+            + "\7g\2\2\u017c\u017d\7p\2\2\u017d\u017e\7e\2\2\u017e\u017f\7g\2\2\u017f"\r
+            + "\u0180\3\2\2\2\u0180\u0181\b\31\31\2\u0181\64\3\2\2\2\u0182\u0183\7t\2"\r
+            + "\2\u0183\u0184\7c\2\2\u0184\u0185\7p\2\2\u0185\u0186\7i\2\2\u0186\u0187"\r
+            + "\7g\2\2\u0187\u0188\3\2\2\2\u0188\u0189\b\32\32\2\u0189\66\3\2\2\2\u018a"\r
+            + "\u018b\7r\2\2\u018b\u018c\7t\2\2\u018c\u018d\7g\2\2\u018d\u018e\7u\2\2"\r
+            + "\u018e\u018f\7g\2\2\u018f\u0190\7p\2\2\u0190\u0191\7e\2\2\u0191\u0192"\r
+            + "\7g\2\2\u0192\u0193\3\2\2\2\u0193\u0194\b\33\33\2\u01948\3\2\2\2\u0195"\r
+            + "\u0196\7r\2\2\u0196\u0197\7t\2\2\u0197\u0198\7g\2\2\u0198\u0199\7h\2\2"\r
+            + "\u0199\u019a\7k\2\2\u019a\u019b\7z\2\2\u019b\u019c\3\2\2\2\u019c\u019d"\r
+            + "\b\34\34\2\u019d:\3\2\2\2\u019e\u019f\7r\2\2\u019f\u01a0\7q\2\2\u01a0"\r
+            + "\u01a1\7u\2\2\u01a1\u01a2\7k\2\2\u01a2\u01a3\7v\2\2\u01a3\u01a4\7k\2\2"\r
+            + "\u01a4\u01a5\7q\2\2\u01a5\u01a6\7p\2\2\u01a6\u01a7\3\2\2\2\u01a7\u01a8"\r
+            + "\b\35\35\2\u01a8<\3\2\2\2\u01a9\u01aa\7r\2\2\u01aa\u01ab\7c\2\2\u01ab"\r
+            + "\u01ac\7v\2\2\u01ac\u01ad\7v\2\2\u01ad\u01ae\7g\2\2\u01ae\u01af\7t\2\2"\r
+            + "\u01af\u01b0\7p\2\2\u01b0\u01b1\3\2\2\2\u01b1\u01b2\b\36\36\2\u01b2>\3"\r
+            + "\2\2\2\u01b3\u01b4\7r\2\2\u01b4\u01b5\7c\2\2\u01b5\u01b6\7v\2\2\u01b6"\r
+            + "\u01b7\7j\2\2\u01b7\u01b8\3\2\2\2\u01b8\u01b9\b\37\37\2\u01b9@\3\2\2\2"\r
+            + "\u01ba\u01bb\7q\2\2\u01bb\u01bc\7w\2\2\u01bc\u01bd\7v\2\2\u01bd\u01be"\r
+            + "\7r\2\2\u01be\u01bf\7w\2\2\u01bf\u01c0\7v\2\2\u01c0B\3\2\2\2\u01c1\u01c2"\r
+            + "\7q\2\2\u01c2\u01c3\7t\2\2\u01c3\u01c4\7i\2\2\u01c4\u01c5\7c\2\2\u01c5"\r
+            + "\u01c6\7p\2\2\u01c6\u01c7\7k\2\2\u01c7\u01c8\7|\2\2\u01c8\u01c9\7c\2\2"\r
+            + "\u01c9\u01ca\7v\2\2\u01ca\u01cb\7k\2\2\u01cb\u01cc\7q\2\2\u01cc\u01cd"\r
+            + "\7p\2\2\u01cd\u01ce\3\2\2\2\u01ce\u01cf\b! \2\u01cfD\3\2\2\2\u01d0\u01d1"\r
+            + "\7q\2\2\u01d1\u01d2\7t\2\2\u01d2\u01d3\7f\2\2\u01d3\u01d4\7g\2\2\u01d4"\r
+            + "\u01d5\7t\2\2\u01d5\u01d6\7g\2\2\u01d6\u01d7\7f\2\2\u01d7\u01d8\7/\2\2"\r
+            + "\u01d8\u01d9\7d\2\2\u01d9\u01da\7{\2\2\u01da\u01db\3\2\2\2\u01db\u01dc"\r
+            + "\b\"!\2\u01dcF\3\2\2\2\u01dd\u01de\7p\2\2\u01de\u01df\7q\2\2\u01df\u01e0"\r
+            + "\7v\2\2\u01e0\u01e1\7k\2\2\u01e1\u01e2\7h\2\2\u01e2\u01e3\7k\2\2\u01e3"\r
+            + "\u01e4\7e\2\2\u01e4\u01e5\7c\2\2\u01e5\u01e6\7v\2\2\u01e6\u01e7\7k\2\2"\r
+            + "\u01e7\u01e8\7q\2\2\u01e8\u01e9\7p\2\2\u01e9\u01ea\3\2\2\2\u01ea\u01eb"\r
+            + "\b#\"\2\u01ebH\3\2\2\2\u01ec\u01ed\7p\2\2\u01ed\u01ee\7c\2\2\u01ee\u01ef"\r
+            + "\7o\2\2\u01ef\u01f0\7g\2\2\u01f0\u01f1\7u\2\2\u01f1\u01f2\7r\2\2\u01f2"\r
+            + "\u01f3\7c\2\2\u01f3\u01f4\7e\2\2\u01f4\u01f5\7g\2\2\u01f5\u01f6\3\2\2"\r
+            + "\2\u01f6\u01f7\b$#\2\u01f7J\3\2\2\2\u01f8\u01f9\7o\2\2\u01f9\u01fa\7w"\r
+            + "\2\2\u01fa\u01fb\7u\2\2\u01fb\u01fc\7v\2\2\u01fc\u01fd\3\2\2\2\u01fd\u01fe"\r
+            + "\b%$\2\u01feL\3\2\2\2\u01ff\u0200\7o\2\2\u0200\u0201\7q\2\2\u0201\u0202"\r
+            + "\7f\2\2\u0202\u0203\7w\2\2\u0203\u0204\7n\2\2\u0204\u0205\7g\2\2\u0205"\r
+            + "\u0206\3\2\2\2\u0206\u0207\b&%\2\u0207N\3\2\2\2\u0208\u0209\7o\2\2\u0209"\r
+            + "\u020a\7k\2\2\u020a\u020b\7p\2\2\u020b\u020c\7/\2\2\u020c\u020d\7g\2\2"\r
+            + "\u020d\u020e\7n\2\2\u020e\u020f\7g\2\2\u020f\u0210\7o\2\2\u0210\u0211"\r
+            + "\7g\2\2\u0211\u0212\7p\2\2\u0212\u0213\7v\2\2\u0213\u0214\7u\2\2\u0214"\r
+            + "\u0215\3\2\2\2\u0215\u0216\b\'&\2\u0216P\3\2\2\2\u0217\u0218\7o\2\2\u0218"\r
+            + "\u0219\7c\2\2\u0219\u021a\7z\2\2\u021a\u021b\7/\2\2\u021b\u021c\7g\2\2"\r
+            + "\u021c\u021d\7n\2\2\u021d\u021e\7g\2\2\u021e\u021f\7o\2\2\u021f\u0220"\r
+            + "\7g\2\2\u0220\u0221\7p\2\2\u0221\u0222\7v\2\2\u0222\u0223\7u\2\2\u0223"\r
+            + "\u0224\3\2\2\2\u0224\u0225\b(\'\2\u0225R\3\2\2\2\u0226\u0227\7o\2\2\u0227"\r
+            + "\u0228\7c\2\2\u0228\u0229\7p\2\2\u0229\u022a\7f\2\2\u022a\u022b\7c\2\2"\r
+            + "\u022b\u022c\7v\2\2\u022c\u022d\7q\2\2\u022d\u022e\7t\2\2\u022e\u022f"\r
+            + "\7{\2\2\u022f\u0230\3\2\2\2\u0230\u0231\b)(\2\u0231T\3\2\2\2\u0232\u0233"\r
+            + "\7n\2\2\u0233\u0234\7k\2\2\u0234\u0235\7u\2\2\u0235\u0236\7v\2\2\u0236"\r
+            + "\u0237\3\2\2\2\u0237\u0238\b*)\2\u0238V\3\2\2\2\u0239\u023a\7n\2\2\u023a"\r
+            + "\u023b\7g\2\2\u023b\u023c\7p\2\2\u023c\u023d\7i\2\2\u023d\u023e\7v\2\2"\r
+            + "\u023e\u023f\7j\2\2\u023f\u0240\3\2\2\2\u0240\u0241\b+*\2\u0241X\3\2\2"\r
+            + "\2\u0242\u0243\7n\2\2\u0243\u0244\7g\2\2\u0244\u0245\7c\2\2\u0245\u0246"\r
+            + "\7h\2\2\u0246\u0247\7/\2\2\u0247\u0248\7n\2\2\u0248\u0249\7k\2\2\u0249"\r
+            + "\u024a\7u\2\2\u024a\u024b\7v\2\2\u024b\u024c\3\2\2\2\u024c\u024d\b,+\2"\r
+            + "\u024dZ\3\2\2\2\u024e\u024f\7n\2\2\u024f\u0250\7g\2\2\u0250\u0251\7c\2"\r
+            + "\2\u0251\u0252\7h\2\2\u0252\u0253\3\2\2\2\u0253\u0254\b-,\2\u0254\\\3"\r
+            + "\2\2\2\u0255\u0256\7m\2\2\u0256\u0257\7g\2\2\u0257\u0258\7{\2\2\u0258"\r
+            + "\u0259\3\2\2\2\u0259\u025a\b.-\2\u025a^\3\2\2\2\u025b\u025c\7k\2\2\u025c"\r
+            + "\u025d\7p\2\2\u025d\u025e\7r\2\2\u025e\u025f\7w\2\2\u025f\u0260\7v\2\2"\r
+            + "\u0260`\3\2\2\2\u0261\u0262\7k\2\2\u0262\u0263\7p\2\2\u0263\u0264\7e\2"\r
+            + "\2\u0264\u0265\7n\2\2\u0265\u0266\7w\2\2\u0266\u0267\7f\2\2\u0267\u0268"\r
+            + "\7g\2\2\u0268\u0269\3\2\2\2\u0269\u026a\b\60.\2\u026ab\3\2\2\2\u026b\u026c"\r
+            + "\7k\2\2\u026c\u026d\7o\2\2\u026d\u026e\7r\2\2\u026e\u026f\7q\2\2\u026f"\r
+            + "\u0270\7t\2\2\u0270\u0271\7v\2\2\u0271\u0272\3\2\2\2\u0272\u0273\b\61"\r
+            + "/\2\u0273d\3\2\2\2\u0274\u0275\7k\2\2\u0275\u0276\7h\2\2\u0276\u0277\7"\r
+            + "/\2\2\u0277\u0278\7h\2\2\u0278\u0279\7g\2\2\u0279\u027a\7c\2\2\u027a\u027b"\r
+            + "\7v\2\2\u027b\u027c\7w\2\2\u027c\u027d\7t\2\2\u027d\u027e\7g\2\2\u027e"\r
+            + "\u027f\3\2\2\2\u027f\u0280\b\62\60\2\u0280f\3\2\2\2\u0281\u0282\7k\2\2"\r
+            + "\u0282\u0283\7f\2\2\u0283\u0284\7g\2\2\u0284\u0285\7p\2\2\u0285\u0286"\r
+            + "\7v\2\2\u0286\u0287\7k\2\2\u0287\u0288\7v\2\2\u0288\u0289\7{\2\2\u0289"\r
+            + "\u028a\3\2\2\2\u028a\u028b\b\63\61\2\u028bh\3\2\2\2\u028c\u028d\7i\2\2"\r
+            + "\u028d\u028e\7t\2\2\u028e\u028f\7q\2\2\u028f\u0290\7w\2\2\u0290\u0291"\r
+            + "\7r\2\2\u0291\u0292\7k\2\2\u0292\u0293\7p\2\2\u0293\u0294\7i\2\2\u0294"\r
+            + "\u0295\3\2\2\2\u0295\u0296\b\64\62\2\u0296j\3\2\2\2\u0297\u0298\7h\2\2"\r
+            + "\u0298\u0299\7t\2\2\u0299\u029a\7c\2\2\u029a\u029b\7e\2\2\u029b\u029c"\r
+            + "\7v\2\2\u029c\u029d\7k\2\2\u029d\u029e\7q\2\2\u029e\u029f\7p\2\2\u029f"\r
+            + "\u02a0\7/\2\2\u02a0\u02a1\7f\2\2\u02a1\u02a2\7k\2\2\u02a2\u02a3\7i\2\2"\r
+            + "\u02a3\u02a4\7k\2\2\u02a4\u02a5\7v\2\2\u02a5\u02a6\7u\2\2\u02a6\u02a7"\r
+            + "\3\2\2\2\u02a7\u02a8\b\65\63\2\u02a8l\3\2\2\2\u02a9\u02aa\7h\2\2\u02aa"\r
+            + "\u02ab\7g\2\2\u02ab\u02ac\7c\2\2\u02ac\u02ad\7v\2\2\u02ad\u02ae\7w\2\2"\r
+            + "\u02ae\u02af\7t\2\2\u02af\u02b0\7g\2\2\u02b0\u02b1\3\2\2\2\u02b1\u02b2"\r
+            + "\b\66\64\2\u02b2n\3\2\2\2\u02b3\u02b4\7f\2\2\u02b4\u02b5\7g\2\2\u02b5"\r
+            + "\u02b6\7x\2\2\u02b6\u02b7\7k\2\2\u02b7\u02b8\7c\2\2\u02b8\u02b9\7v\2\2"\r
+            + "\u02b9\u02ba\7g\2\2\u02ba\u02bb\3\2\2\2\u02bb\u02bc\b\67\65\2\u02bcp\3"\r
+            + "\2\2\2\u02bd\u02be\7f\2\2\u02be\u02bf\7g\2\2\u02bf\u02c0\7x\2\2\u02c0"\r
+            + "\u02c1\7k\2\2\u02c1\u02c2\7c\2\2\u02c2\u02c3\7v\2\2\u02c3\u02c4\7k\2\2"\r
+            + "\u02c4\u02c5\7q\2\2\u02c5\u02c6\7p\2\2\u02c6\u02c7\3\2\2\2\u02c7\u02c8"\r
+            + "\b8\66\2\u02c8r\3\2\2\2\u02c9\u02ca\7g\2\2\u02ca\u02cb\7z\2\2\u02cb\u02cc"\r
+            + "\7v\2\2\u02cc\u02cd\7g\2\2\u02cd\u02ce\7p\2\2\u02ce\u02cf\7u\2\2\u02cf"\r
+            + "\u02d0\7k\2\2\u02d0\u02d1\7q\2\2\u02d1\u02d2\7p\2\2\u02d2\u02d3\3\2\2"\r
+            + "\2\u02d3\u02d4\b9\67\2\u02d4t\3\2\2\2\u02d5\u02d6\7g\2\2\u02d6\u02d7\7"\r
+            + "t\2\2\u02d7\u02d8\7t\2\2\u02d8\u02d9\7q\2\2\u02d9\u02da\7t\2\2\u02da\u02db"\r
+            + "\7/\2\2\u02db\u02dc\7o\2\2\u02dc\u02dd\7g\2\2\u02dd\u02de\7u\2\2\u02de"\r
+            + "\u02df\7u\2\2\u02df\u02e0\7c\2\2\u02e0\u02e1\7i\2\2\u02e1\u02e2\7g\2\2"\r
+            + "\u02e2\u02e3\3\2\2\2\u02e3\u02e4\b:8\2\u02e4v\3\2\2\2\u02e5\u02e6\7g\2"\r
+            + "\2\u02e6\u02e7\7t\2\2\u02e7\u02e8\7t\2\2\u02e8\u02e9\7q\2\2\u02e9\u02ea"\r
+            + "\7t\2\2\u02ea\u02eb\7/\2\2\u02eb\u02ec\7c\2\2\u02ec\u02ed\7r\2\2\u02ed"\r
+            + "\u02ee\7r\2\2\u02ee\u02ef\7/\2\2\u02ef\u02f0\7v\2\2\u02f0\u02f1\7c\2\2"\r
+            + "\u02f1\u02f2\7i\2\2\u02f2\u02f3\3\2\2\2\u02f3\u02f4\b;9\2\u02f4x\3\2\2"\r
+            + "\2\u02f5\u02f6\7g\2\2\u02f6\u02f7\7p\2\2\u02f7\u02f8\7w\2\2\u02f8\u02f9"\r
+            + "\7o\2\2\u02f9\u02fa\3\2\2\2\u02fa\u02fb\b<:\2\u02fbz\3\2\2\2\u02fc\u02fd"\r
+            + "\7f\2\2\u02fd\u02fe\7g\2\2\u02fe\u02ff\7u\2\2\u02ff\u0300\7e\2\2\u0300"\r
+            + "\u0301\7t\2\2\u0301\u0302\7k\2\2\u0302\u0303\7r\2\2\u0303\u0304\7v\2\2"\r
+            + "\u0304\u0305\7k\2\2\u0305\u0306\7q\2\2\u0306\u0307\7p\2\2\u0307\u0308"\r
+            + "\3\2\2\2\u0308\u0309\b=;\2\u0309|\3\2\2\2\u030a\u030b\7f\2\2\u030b\u030c"\r
+            + "\7g\2\2\u030c\u030d\7h\2\2\u030d\u030e\7c\2\2\u030e\u030f\7w\2\2\u030f"\r
+            + "\u0310\7n\2\2\u0310\u0311\7v\2\2\u0311\u0312\3\2\2\2\u0312\u0313\b><\2"\r
+            + "\u0313~\3\2\2\2\u0314\u0315\7e\2\2\u0315\u0316\7q\2\2\u0316\u0317\7p\2"\r
+            + "\2\u0317\u0318\7v\2\2\u0318\u0319\7c\2\2\u0319\u031a\7k\2\2\u031a\u031b"\r
+            + "\7p\2\2\u031b\u031c\7g\2\2\u031c\u031d\7t\2\2\u031d\u031e\3\2\2\2\u031e"\r
+            + "\u031f\b?=\2\u031f\u0080\3\2\2\2\u0320\u0321\7e\2\2\u0321\u0322\7q\2\2"\r
+            + "\u0322\u0323\7p\2\2\u0323\u0324\7v\2\2\u0324\u0325\7c\2\2\u0325\u0326"\r
+            + "\7e\2\2\u0326\u0327\7v\2\2\u0327\u0328\3\2\2\2\u0328\u0329\b@>\2\u0329"\r
+            + "\u0082\3\2\2\2\u032a\u032b\7e\2\2\u032b\u032c\7q\2\2\u032c\u032d\7p\2"\r
+            + "\2\u032d\u032e\7h\2\2\u032e\u032f\7k\2\2\u032f\u0330\7i\2\2\u0330\u0331"\r
+            + "\3\2\2\2\u0331\u0332\bA?\2\u0332\u0084\3\2\2\2\u0333\u0334\7e\2\2\u0334"\r
+            + "\u0335\7j\2\2\u0335\u0336\7q\2\2\u0336\u0337\7k\2\2\u0337\u0338\7e\2\2"\r
+            + "\u0338\u0339\7g\2\2\u0339\u033a\3\2\2\2\u033a\u033b\bB@\2\u033b\u0086"\r
+            + "\3\2\2\2\u033c\u033d\7e\2\2\u033d\u033e\7c\2\2\u033e\u033f\7u\2\2\u033f"\r
+            + "\u0340\7g\2\2\u0340\u0341\3\2\2\2\u0341\u0342\bCA\2\u0342\u0088\3\2\2"\r
+            + "\2\u0343\u0344\7d\2\2\u0344\u0345\7k\2\2\u0345\u0346\7v\2\2\u0346\u0347"\r
+            + "\3\2\2\2\u0347\u0348\bDB\2\u0348\u008a\3\2\2\2\u0349\u034a\7d\2\2\u034a"\r
+            + "\u034b\7g\2\2\u034b\u034c\7n\2\2\u034c\u034d\7q\2\2\u034d\u034e\7p\2\2"\r
+            + "\u034e\u034f\7i\2\2\u034f\u0350\7u\2\2\u0350\u0351\7/\2\2\u0351\u0352"\r
+            + "\7v\2\2\u0352\u0353\7q\2\2\u0353\u0354\3\2\2\2\u0354\u0355\bEC\2\u0355"\r
+            + "\u008c\3\2\2\2\u0356\u0357\7d\2\2\u0357\u0358\7c\2\2\u0358\u0359\7u\2"\r
+            + "\2\u0359\u035a\7g\2\2\u035a\u035b\3\2\2\2\u035b\u035c\bFD\2\u035c\u008e"\r
+            + "\3\2\2\2\u035d\u035e\7c\2\2\u035e\u035f\7w\2\2\u035f\u0360\7i\2\2\u0360"\r
+            + "\u0361\7o\2\2\u0361\u0362\7g\2\2\u0362\u0363\7p\2\2\u0363\u0364\7v\2\2"\r
+            + "\u0364\u0365\3\2\2\2\u0365\u0366\bGE\2\u0366\u0090\3\2\2\2\u0367\u0368"\r
+            + "\7c\2\2\u0368\u0369\7t\2\2\u0369\u036a\7i\2\2\u036a\u036b\7w\2\2\u036b"\r
+            + "\u036c\7o\2\2\u036c\u036d\7g\2\2\u036d\u036e\7p\2\2\u036e\u036f\7v\2\2"\r
+            + "\u036f\u0370\3\2\2\2\u0370\u0371\bHF\2\u0371\u0092\3\2\2\2\u0372\u0373"\r
+            + "\7c\2\2\u0373\u0374\7p\2\2\u0374\u0375\7{\2\2\u0375\u0376\7z\2\2\u0376"\r
+            + "\u0377\7o\2\2\u0377\u0378\7n\2\2\u0378\u0379\3\2\2\2\u0379\u037a\bIG\2"\r
+            + "\u037a\u0094\3\2\2\2\u037b\u037f\t\4\2\2\u037c\u037e\t\5\2\2\u037d\u037c"\r
+            + "\3\2\2\2\u037e\u0381\3\2\2\2\u037f\u037d\3\2\2\2\u037f\u0380\3\2\2\2\u0380"\r
+            + "\u0382\3\2\2\2\u0381\u037f\3\2\2\2\u0382\u0383\bJH\2\u0383\u0096\3\2\2"\r
+            + "\2\u0384\u0387\7^\2\2\u0385\u0388\t\6\2\2\u0386\u0388\5\u0099L\2\u0387"\r
+            + "\u0385\3\2\2\2\u0387\u0386\3\2\2\2\u0388\u0098\3\2\2\2\u0389\u038a\7w"\r
+            + "\2\2\u038a\u038b\5\u009bM\2\u038b\u038c\5\u009bM\2\u038c\u038d\5\u009b"\r
+            + "M\2\u038d\u038e\5\u009bM\2\u038e\u009a\3\2\2\2\u038f\u0390\t\7\2\2\u0390"\r
+            + "\u009c\3\2\2\2\u0391\u0392\7=\2\2\u0392\u0393\3\2\2\2\u0393\u0394\bNI"\r
+            + "\2\u0394\u009e\3\2\2\2\u0395\u0396\7}\2\2\u0396\u0397\3\2\2\2\u0397\u0398"\r
+            + "\bOJ\2\u0398\u00a0\3\2\2\2\u0399\u039e\7$\2\2\u039a\u039d\5\u0097K\2\u039b"\r
+            + "\u039d\n\b\2\2\u039c\u039a\3\2\2\2\u039c\u039b\3\2\2\2\u039d\u03a0\3\2"\r
+            + "\2\2\u039e\u039c\3\2\2\2\u039e\u039f\3\2\2\2\u039f\u03a1\3\2\2\2\u03a0"\r
+            + "\u039e\3\2\2\2\u03a1\u03ac\7$\2\2\u03a2\u03a7\7)\2\2\u03a3\u03a6\5\u0097"\r
+            + "K\2\u03a4\u03a6\n\t\2\2\u03a5\u03a3\3\2\2\2\u03a5\u03a4\3\2\2\2\u03a6"\r
+            + "\u03a9\3\2\2\2\u03a7\u03a5\3\2\2\2\u03a7\u03a8\3\2\2\2\u03a8\u03aa\3\2"\r
+            + "\2\2\u03a9\u03a7\3\2\2\2\u03aa\u03ac\7)\2\2\u03ab\u0399\3\2\2\2\u03ab"\r
+            + "\u03a2\3\2\2\2\u03ac\u00a2\3\2\2\2\u03ad\u03b4\5\u00a1P\2\u03ae\u03b0"\r
+            + "\n\n\2\2\u03af\u03ae\3\2\2\2\u03b0\u03b1\3\2\2\2\u03b1\u03af\3\2\2\2\u03b1"\r
+            + "\u03b2\3\2\2\2\u03b2\u03b4\3\2\2\2\u03b3\u03ad\3\2\2\2\u03b3\u03af\3\2"\r
+            + "\2\2\u03b4\u03b5\3\2\2\2\u03b5\u03b6\bQK\2\u03b6\u00a4\3\2\2\2\u03b7\u03b8"\r
+            + "\t\13\2\2\u03b8\u03b9\3\2\2\2\u03b9\u03ba\bRL\2\u03ba\u00a6\3\2\2\2\u03bb"\r
+            + "\u03bc\7,\2\2\u03bc\u03bd\7\61\2\2\u03bd\u03be\3\2\2\2\u03be\u03bf\bS"\r
+            + "M\2\u03bf\u00a8\3\2\2\2\u03c0\u03c1\13\2\2\2\u03c1\u03c2\3\2\2\2\u03c2"\r
+            + "\u03c3\bTN\2\u03c3\u00aa\3\2\2\2\17\2\3\4\u00b9\u037f\u0387\u039c\u039e"\r
+            + "\u03a5\u03a7\u03ab\u03b1\u03b3";\r
     public static final ATN _ATN = ATNSimulator.deserialize(_serializedATN\r
             .toCharArray());\r
     static {\r
index 2b22fc7396805af59306e903ec668bc037155426..91b0917e29627cfdcbcb705ebb019dba88b2489b 100644 (file)
@@ -7,21 +7,14 @@
  */\r
 package org.opendaylight.controller.antlrv4.code.gen;\r
 \r
-import java.util.List;\r
-\r
-import org.antlr.v4.runtime.NoViableAltException;\r
-import org.antlr.v4.runtime.Parser;\r
-import org.antlr.v4.runtime.ParserRuleContext;\r
-import org.antlr.v4.runtime.RecognitionException;\r
-import org.antlr.v4.runtime.TokenStream;\r
-import org.antlr.v4.runtime.atn.ATN;\r
-import org.antlr.v4.runtime.atn.ATNSimulator;\r
-import org.antlr.v4.runtime.atn.ParserATNSimulator;\r
-import org.antlr.v4.runtime.atn.PredictionContextCache;\r
+import org.antlr.v4.runtime.atn.*;\r
 import org.antlr.v4.runtime.dfa.DFA;\r
-import org.antlr.v4.runtime.tree.ParseTreeListener;\r
-import org.antlr.v4.runtime.tree.ParseTreeVisitor;\r
-import org.antlr.v4.runtime.tree.TerminalNode;\r
+import org.antlr.v4.runtime.*;\r
+import org.antlr.v4.runtime.misc.*;\r
+import org.antlr.v4.runtime.tree.*;\r
+import java.util.List;\r
+import java.util.Iterator;\r
+import java.util.ArrayList;\r
 \r
 @SuppressWarnings({ "all", "warnings", "unchecked", "unused", "cast" })\r
 public class YangParser extends Parser {\r
@@ -38,26 +31,26 @@ public class YangParser extends Parser {
             CONTAINER_KEYWORD = 62, DEVIATION_KEYWORD = 55,\r
             STATUS_KEYWORD = 18, IDENTITY_KEYWORD = 50, IDENTIFIER = 73,\r
             REFINE_KEYWORD = 23, USES_KEYWORD = 12, VALUE_KEYWORD = 11,\r
-            IMPORT_KEYWORD = 48, BLOCK_COMMENT = 7, INPUT_KEYWORD = 46,\r
-            IF_FEATURE_KEYWORD = 49, PLUS = 4, PATTERN_KEYWORD = 29,\r
-            LENGTH_KEYWORD = 42, FEATURE_KEYWORD = 53,\r
-            REQUIRE_INSTANCE_KEYWORD = 22, ORGANIZATION_KEYWORD = 32,\r
-            UNIQUE_KEYWORD = 14, SUBMODULE_KEYWORD = 17, TYPE_KEYWORD = 16,\r
-            RIGHT_BRACE = 3, ERROR_MESSAGE_KEYWORD = 57, LINE_COMMENT = 6,\r
-            OUTPUT_KEYWORD = 31, MIN_ELEMENTS_KEYWORD = 38, MUST_KEYWORD = 36,\r
-            SEMICOLON = 1, POSITION_KEYWORD = 28, PATH_KEYWORD = 30, S = 75,\r
-            KEY_KEYWORD = 45, EXTENSION_KEYWORD = 56, WS = 5,\r
+            IMPORT_KEYWORD = 48, INPUT_KEYWORD = 46, IF_FEATURE_KEYWORD = 49,\r
+            PLUS = 4, PATTERN_KEYWORD = 29, LENGTH_KEYWORD = 42,\r
+            FEATURE_KEYWORD = 53, REQUIRE_INSTANCE_KEYWORD = 22,\r
+            ORGANIZATION_KEYWORD = 32, UNIQUE_KEYWORD = 14,\r
+            SUBMODULE_KEYWORD = 17, TYPE_KEYWORD = 16, RIGHT_BRACE = 3,\r
+            ERROR_MESSAGE_KEYWORD = 57, LINE_COMMENT = 6, OUTPUT_KEYWORD = 31,\r
+            MIN_ELEMENTS_KEYWORD = 38, MUST_KEYWORD = 36, SEMICOLON = 1,\r
+            POSITION_KEYWORD = 28, PATH_KEYWORD = 30, S = 75, KEY_KEYWORD = 45,\r
+            EXTENSION_KEYWORD = 56, START_BLOCK_COMMENT = 7, WS = 5,\r
             MANDATORY_KEYWORD = 40, ORDERED_BY_KEYWORD = 33,\r
             ERROR_APP_TAG_KEYWORD = 58, INCLUDE_KEYWORD = 47,\r
             ANYXML_KEYWORD = 72, AUGMENT_KEYWORD = 70, DEVIATE_KEYWORD = 54,\r
             LEFT_BRACE = 2, YANG_VERSION_KEYWORD = 9, LIST_KEYWORD = 41,\r
             TYPEDEF_KEYWORD = 15, MAX_ELEMENTS_KEYWORD = 39, ENUM_KEYWORD = 59,\r
             CASE_KEYWORD = 66, UNITS_KEYWORD = 13, GROUPING_KEYWORD = 51,\r
-            BASE_KEYWORD = 69, RANGE_KEYWORD = 25,\r
+            END_BLOCK_COMMENT = 76, BASE_KEYWORD = 69, RANGE_KEYWORD = 25,\r
             FRACTION_DIGITS_KEYWORD = 52, CONFIG_KEYWORD = 64,\r
             BIT_KEYWORD = 67, STRING = 74;\r
     public static final String[] tokenNames = { "<INVALID>", "SEMICOLON",\r
-            "LEFT_BRACE", "'}'", "'+'", "WS", "LINE_COMMENT", "BLOCK_COMMENT",\r
+            "LEFT_BRACE", "'}'", "'+'", "WS", "LINE_COMMENT", "'/*'",\r
             "'yin-element'", "'yang-version'", "'when'", "'value'", "'uses'",\r
             "'units'", "'unique'", "'typedef'", "'type'", "'submodule'",\r
             "'status'", "'rpc'", "'revision-date'", "'revision'",\r
@@ -73,7 +66,7 @@ public class YangParser extends Parser {
             "'description'", "'default'", "'container'", "'contact'",\r
             "'config'", "'choice'", "'case'", "'bit'", "'belongs-to'",\r
             "'base'", "'augment'", "'argument'", "'anyxml'", "IDENTIFIER",\r
-            "STRING", "S" };\r
+            "STRING", "S", "'*/'" };\r
     public static final int RULE_yang = 0, RULE_string = 1,\r
             RULE_identifier_stmt = 2, RULE_stmtend = 3,\r
             RULE_deviate_replace_stmt = 4, RULE_deviate_delete_stmt = 5,\r
@@ -12858,7 +12851,7 @@ public class YangParser extends Parser {
         return _localctx;\r
     }\r
 \r
-    public static final String _serializedATN = "\2\3M\u04bd\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4"\r
+    public static final String _serializedATN = "\2\3N\u04bd\4\2\t\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4"\r
             + "\t\t\t\4\n\t\n\4\13\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20"\r
             + "\4\21\t\21\4\22\t\22\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27"\r
             + "\4\30\t\30\4\31\t\31\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36"\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/AugmentationSchemaBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/AugmentationSchemaBuilderImpl.java
deleted file mode 100644 (file)
index 2ece5a0..0000000
+++ /dev/null
@@ -1,306 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.model.parser.api.AugmentationSchemaBuilder;\r
-import org.opendaylight.controller.model.parser.api.DataSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.model.parser.util.YangModelBuilderHelper;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-\r
-public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder {\r
-\r
-       private final AugmentationSchemaImpl instance;\r
-       private final SchemaPath augmentTarget;\r
-       final Set<DataSchemaNodeBuilder> childNodes = new HashSet<DataSchemaNodeBuilder>();\r
-       final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();\r
-       private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();\r
-\r
-       AugmentationSchemaBuilderImpl(String augmentPath) {\r
-               SchemaPath targetPath = YangModelBuilderHelper.parsePath(augmentPath);\r
-               augmentTarget = targetPath;\r
-               instance = new AugmentationSchemaImpl(targetPath);\r
-       }\r
-\r
-       @Override\r
-       public void addChildNode(DataSchemaNodeBuilder childNode) {\r
-               childNodes.add(childNode);\r
-       }\r
-\r
-       @Override\r
-       public void addGrouping(GroupingBuilder grouping) {\r
-               groupings.add(grouping);\r
-       }\r
-\r
-       /**\r
-        * Always returns null.\r
-        */\r
-       @Override\r
-       public QName getQName() {\r
-               return null;\r
-       }\r
-\r
-       @Override\r
-       public AugmentationSchema build() {\r
-\r
-               // CHILD NODES\r
-               Map<QName, DataSchemaNode> childs = new HashMap<QName, DataSchemaNode>();\r
-               for(DataSchemaNodeBuilder node : childNodes) {\r
-                       childs.put(node.getQName(), node.build());\r
-               }\r
-               instance.setChildNodes(childs);\r
-\r
-               // GROUPINGS\r
-               Set<GroupingDefinition> groupingDefinitions = new HashSet<GroupingDefinition>();\r
-               for(GroupingBuilder builder : groupings) {\r
-                       groupingDefinitions.add(builder.build());\r
-               }\r
-               instance.setGroupings(groupingDefinitions);\r
-\r
-               // USES\r
-               Set<UsesNode> usesNodeDefinitions = new HashSet<UsesNode>();\r
-               for(UsesNodeBuilder builder : usesNodes) {\r
-                       usesNodeDefinitions.add(builder.build());\r
-               }\r
-               instance.setUses(usesNodeDefinitions);\r
-\r
-               return instance;\r
-       }\r
-\r
-       @Override\r
-       public void addUsesNode(UsesNodeBuilder usesBuilder) {\r
-               usesNodes.add(usesBuilder);\r
-       }\r
-\r
-       @Override\r
-       public void addTypedef(TypeDefinitionBuilder type) {\r
-               throw new UnsupportedOperationException("Augmentation can not contains type definitions");\r
-       }\r
-\r
-       @Override\r
-       public void setDescription(String description) {\r
-               instance.setDescription(description);\r
-       }\r
-\r
-       @Override\r
-       public void setReference(String reference) {\r
-               instance.setReference(reference);\r
-       }\r
-\r
-       @Override\r
-       public void setStatus(Status status) {\r
-               instance.setStatus(status);\r
-       }\r
-\r
-       @Override\r
-       public SchemaPath getTargetPath() {\r
-               return augmentTarget;\r
-       }\r
-\r
-\r
-       private static class AugmentationSchemaImpl implements AugmentationSchema {\r
-\r
-               private final SchemaPath targetPath;\r
-               private Map<QName, DataSchemaNode> childNodes;\r
-               private Set<GroupingDefinition> groupings;\r
-               private Set<UsesNode> uses;\r
-\r
-               private String description;\r
-               private String reference;\r
-               private Status status;\r
-\r
-               private AugmentationSchemaImpl(SchemaPath targetPath) {\r
-                       this.targetPath = targetPath;\r
-               }\r
-\r
-\r
-               @Override\r
-               public SchemaPath getTargetPath() {\r
-                       return targetPath;\r
-               }\r
-\r
-               @Override\r
-               public Set<DataSchemaNode> getChildNodes() {\r
-                       return new HashSet<DataSchemaNode>(childNodes.values());\r
-               }\r
-               private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {\r
-                       this.childNodes = childNodes;\r
-               }\r
-\r
-               @Override\r
-               public Set<GroupingDefinition> getGroupings() {\r
-                       return groupings;\r
-               }\r
-               private void setGroupings(Set<GroupingDefinition> groupings) {\r
-                       this.groupings = groupings;\r
-               }\r
-\r
-               @Override\r
-               public Set<UsesNode> getUses() {\r
-                       return uses;\r
-               }\r
-               private void setUses(Set<UsesNode> uses) {\r
-                       this.uses = uses;\r
-               }\r
-\r
-               /**\r
-                * This method always returns null, because augmentation can not contains type definitions.\r
-                */\r
-               @Override\r
-               public Set<TypeDefinition<?>> getTypeDefinitions() {\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public String getDescription() {\r
-                       return description;\r
-               }\r
-               private void setDescription(String description) {\r
-                       this.description = description;\r
-               }\r
-\r
-               @Override\r
-               public String getReference() {\r
-                       return reference;\r
-               }\r
-               private void setReference(String reference) {\r
-                       this.reference = reference;\r
-               }\r
-\r
-               @Override\r
-               public Status getStatus() {\r
-                       return status;\r
-               }\r
-               private void setStatus(Status status) {\r
-                       this.status = status;\r
-               }\r
-\r
-               @Override\r
-               public DataSchemaNode getDataChildByName(QName name) {\r
-                       return childNodes.get(name);\r
-               }\r
-\r
-               @Override\r
-               public DataSchemaNode getDataChildByName(String name) {\r
-                       DataSchemaNode result = null;\r
-                       for(Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {\r
-                               if(entry.getKey().getLocalName().equals(name)) {\r
-                                       result = entry.getValue();\r
-                                       break;\r
-                               }\r
-                       }\r
-                       return result;\r
-               }\r
-\r
-               @Override\r
-               public int hashCode() {\r
-                       final int prime = 17;\r
-            int result = 1;\r
-            result = prime * result + ((targetPath == null) ? 0 : targetPath.hashCode());\r
-            result = prime * result + ((childNodes == null) ? 0 : childNodes.hashCode());\r
-            result = prime * result + ((groupings == null) ? 0 : groupings.hashCode());\r
-            result = prime * result + ((uses == null) ? 0 : uses.hashCode());\r
-            result = prime * result + ((description == null) ? 0 : description.hashCode());\r
-            result = prime * result + ((reference == null) ? 0 : reference.hashCode());\r
-            result = prime * result + ((status == null) ? 0 : status.hashCode());\r
-            return result;\r
-               }\r
-\r
-               @Override\r
-        public boolean equals(Object obj) {\r
-            if (this == obj) {\r
-                return true;\r
-            }\r
-            if (obj == null) {\r
-                return false;\r
-            }\r
-            if (getClass() != obj.getClass()) {\r
-                return false;\r
-            }\r
-            AugmentationSchemaImpl other = (AugmentationSchemaImpl) obj;\r
-            if (targetPath == null) {\r
-                if (other.targetPath != null) {\r
-                    return false;\r
-                }\r
-            } else if (!targetPath.equals(other.targetPath)) {\r
-                return false;\r
-            }\r
-            if (childNodes == null) {\r
-                if (other.childNodes != null) {\r
-                    return false;\r
-                }\r
-            } else if (!childNodes.equals(other.childNodes)) {\r
-                return false;\r
-            }\r
-            if (groupings == null) {\r
-                if (other.groupings != null) {\r
-                    return false;\r
-                }\r
-            } else if (!groupings.equals(other.groupings)) {\r
-                return false;\r
-            }\r
-            if (uses == null) {\r
-                if (other.uses != null) {\r
-                    return false;\r
-                }\r
-            } else if (!uses.equals(other.uses)) {\r
-                return false;\r
-            }\r
-            if (description == null) {\r
-                if (other.description != null) {\r
-                    return false;\r
-                }\r
-            } else if (!description.equals(other.description)) {\r
-                return false;\r
-            }\r
-            if (reference == null) {\r
-                if (other.reference != null) {\r
-                    return false;\r
-                }\r
-            } else if (!reference.equals(other.reference)) {\r
-                return false;\r
-            }\r
-            if (status == null) {\r
-                if (other.status != null) {\r
-                    return false;\r
-                }\r
-            } else if (!status.equals(other.status)) {\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-               @Override\r
-               public String toString() {\r
-                       StringBuilder sb = new StringBuilder(AugmentationSchemaImpl.class.getSimpleName());\r
-                       sb.append("[");\r
-                       sb.append("targetPath="+ targetPath);\r
-                       sb.append(", childNodes="+ childNodes.values());\r
-                       sb.append(", groupings="+ groupings);\r
-                       sb.append(", uses="+ uses);\r
-                       sb.append("]");\r
-                       return sb.toString();\r
-               }\r
-       }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/ContainerSchemaNodeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/ContainerSchemaNodeBuilder.java
deleted file mode 100644 (file)
index 1651bfc..0000000
+++ /dev/null
@@ -1,468 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.model.parser.api.AbstractChildNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.AugmentationTargetBuilder;\r
-import org.opendaylight.controller.model.parser.api.DataSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionAwareBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
-import org.opendaylight.controller.yang.model.api.ConstraintDefinition;\r
-import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.controller.yang.model.api.MustDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-\r
-public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder implements TypeDefinitionAwareBuilder, MustAwareBuilder, AugmentationTargetBuilder, DataSchemaNodeBuilder {\r
-\r
-       private final ContainerSchemaNodeImpl instance;\r
-\r
-       private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();\r
-       private final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();\r
-       private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();\r
-       private MustDefinitionBuilder mustDefinitionBuilder;\r
-\r
-       ContainerSchemaNodeBuilder(QName qname) {\r
-               super(qname);\r
-               instance = new ContainerSchemaNodeImpl(qname);\r
-       }\r
-\r
-       @Override\r
-       public ContainerSchemaNode build() {\r
-               // CHILD NODES\r
-               Map<QName, DataSchemaNode> childs = new HashMap<QName, DataSchemaNode>();\r
-               for (DataSchemaNodeBuilder node : childNodes) {\r
-                       childs.put(node.getQName(), node.build());\r
-               }\r
-               instance.setChildNodes(childs);\r
-\r
-               // GROUPINGS\r
-               Set<GroupingDefinition> groupingDefinitions = new HashSet<GroupingDefinition>();\r
-               for (GroupingBuilder builder : groupings) {\r
-                       groupingDefinitions.add(builder.build());\r
-               }\r
-               instance.setGroupings(groupingDefinitions);\r
-\r
-               // TYPEDEFS\r
-               Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();\r
-               for(TypeDefinitionBuilder entry : addedTypedefs) {\r
-                       typedefs.add(entry.build());\r
-               }\r
-               instance.setTypeDefinitions(typedefs);\r
-\r
-               // USES\r
-               Set<UsesNode> uses = new HashSet<UsesNode>();\r
-               for (UsesNodeBuilder builder : addedUsesNodes) {\r
-                       uses.add(builder.build());\r
-               }\r
-               instance.setUses(uses);\r
-\r
-               // MUST definition\r
-               if(mustDefinitionBuilder != null) {\r
-                       MustDefinition md = mustDefinitionBuilder.build();\r
-                       instance.setMustStatement(md);\r
-               }\r
-\r
-               instance.setAvailableAugmentations(augmentations);\r
-\r
-               return instance;\r
-       }\r
-\r
-\r
-       @Override\r
-       public void addTypedef(TypeDefinitionBuilder type) {\r
-               addedTypedefs.add(type);\r
-       }\r
-\r
-       @Override\r
-       public void addAugmentation(AugmentationSchema augment) {\r
-               augmentations.add(augment);\r
-       }\r
-\r
-       @Override\r
-       public void setPath(SchemaPath schemaPath) {\r
-               instance.setPath(schemaPath);\r
-       }\r
-\r
-       @Override\r
-       public void setDescription(String description) {\r
-               instance.setDescription(description);\r
-       }\r
-\r
-       @Override\r
-       public void setReference(String reference) {\r
-               instance.setReference(reference);\r
-       }\r
-\r
-       @Override\r
-       public void setStatus(Status status) {\r
-               instance.setStatus(status);\r
-       }\r
-\r
-       @Override\r
-       public void setAugmenting(boolean augmenting) {\r
-               instance.setAugmenting(augmenting);\r
-       }\r
-\r
-       @Override\r
-       public void setConfiguration(boolean configuration) {\r
-               instance.setConfiguration(configuration);\r
-       }\r
-\r
-       public void setConstraints(ConstraintDefinition constraints) {\r
-               instance.setConstraints(constraints);\r
-       }\r
-\r
-       @Override\r
-       public void addUsesNode(UsesNodeBuilder usesNodeBuilder) {\r
-               addedUsesNodes.add(usesNodeBuilder);\r
-       }\r
-\r
-       public void setPresenceContainer(boolean presence) {\r
-               instance.setPresenceContainer(presence);\r
-       }\r
-\r
-       @Override\r
-       public void setMustDefinitionBuilder(MustDefinitionBuilder mustDefinitionBuilder) {\r
-               this.mustDefinitionBuilder = mustDefinitionBuilder;\r
-       }\r
-\r
-\r
-       private class ContainerSchemaNodeImpl implements ContainerSchemaNode {\r
-\r
-               private final QName qname;\r
-               private SchemaPath path;\r
-               private String description;\r
-               private String reference;\r
-               private Status status = Status.CURRENT;\r
-\r
-               private boolean augmenting;\r
-               private boolean configuration;\r
-               private ConstraintDefinition constraints;\r
-\r
-               private Set<AugmentationSchema> augmentations;\r
-\r
-               private Map<QName, DataSchemaNode> childNodes;\r
-               private Set<GroupingDefinition> groupings;\r
-               private Set<TypeDefinition<?>> typeDefinitions;\r
-\r
-               private Set<UsesNode> uses;\r
-               private boolean presence;\r
-\r
-               private MustDefinition mustDefinition;\r
-\r
-               private ContainerSchemaNodeImpl(QName qname) {\r
-                       this.qname = qname;\r
-               }\r
-\r
-               @Override\r
-               public QName getQName() {\r
-                       return qname;\r
-               }\r
-\r
-               @Override\r
-               public SchemaPath getPath() {\r
-                       return path;\r
-               }\r
-               private void setPath(SchemaPath path) {\r
-                       this.path = path;\r
-               }\r
-\r
-               @Override\r
-               public String getDescription() {\r
-                       return description;\r
-               }\r
-               private void setDescription(String description) {\r
-                       this.description = description;\r
-               }\r
-\r
-               @Override\r
-               public String getReference() {\r
-                       return reference;\r
-               }\r
-               private void setReference(String reference) {\r
-                       this.reference = reference;\r
-               }\r
-\r
-               @Override\r
-               public Status getStatus() {\r
-                       return status;\r
-               }\r
-               private void setStatus(Status status) {\r
-                       this.status = status;\r
-               }\r
-\r
-               @Override\r
-               public boolean isAugmenting() {\r
-                       return augmenting;\r
-               }\r
-               private void setAugmenting(boolean augmenting) {\r
-                       this.augmenting = augmenting;\r
-               }\r
-\r
-               @Override\r
-               public boolean isConfiguration() {\r
-                       return configuration;\r
-               }\r
-               private void setConfiguration(boolean configuration) {\r
-                       this.configuration = configuration;\r
-               }\r
-\r
-               @Override\r
-               public ConstraintDefinition getConstraints() {\r
-                       return constraints;\r
-               }\r
-               private void setConstraints(ConstraintDefinition constraints) {\r
-                       this.constraints = constraints;\r
-               }\r
-\r
-               @Override\r
-               public Set<AugmentationSchema> getAvailableAugmentations() {\r
-                       return augmentations;\r
-               }\r
-               private void setAvailableAugmentations(\r
-                               Set<AugmentationSchema> augmentations) {\r
-                       this.augmentations = augmentations;\r
-               }\r
-\r
-               @Override\r
-               public Set<DataSchemaNode> getChildNodes() {\r
-                       return new HashSet<DataSchemaNode>(childNodes.values());\r
-               }\r
-               private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {\r
-                       this.childNodes = childNodes;\r
-               }\r
-\r
-               @Override\r
-               public Set<GroupingDefinition> getGroupings() {\r
-                       return groupings;\r
-               }\r
-               private void setGroupings(Set<GroupingDefinition> groupings) {\r
-                       this.groupings = groupings;\r
-               }\r
-\r
-               @Override\r
-               public DataSchemaNode getDataChildByName(QName name) {\r
-                       return childNodes.get(name);\r
-               }\r
-\r
-               @Override\r
-               public DataSchemaNode getDataChildByName(String name) {\r
-                       DataSchemaNode result = null;\r
-                       for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {\r
-                               if (entry.getKey().getLocalName().equals(name)) {\r
-                                       result = entry.getValue();\r
-                                       break;\r
-                               }\r
-                       }\r
-                       return result;\r
-               }\r
-\r
-               @Override\r
-               public Set<UsesNode> getUses() {\r
-                       return uses;\r
-               }\r
-\r
-               private void setUses(Set<UsesNode> uses) {\r
-                       this.uses = uses;\r
-               }\r
-\r
-               @Override\r
-               public boolean isPresenceContainer() {\r
-                       return presence;\r
-               }\r
-\r
-               private void setPresenceContainer(boolean presence) {\r
-                       this.presence = presence;\r
-               }\r
-\r
-               @Override\r
-               public MustDefinition getMustDefinition() {\r
-                       return mustDefinition;\r
-               }\r
-               private void setMustStatement(MustDefinition mustDefinition) {\r
-                       this.mustDefinition = mustDefinition;\r
-               }\r
-\r
-               @Override\r
-               public Set<TypeDefinition<?>> getTypeDefinitions() {\r
-                       return typeDefinitions;\r
-               }\r
-               private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {\r
-                       this.typeDefinitions = typeDefinitions;\r
-               }\r
-\r
-               @Override\r
-               public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-                       // TODO Auto-generated method stub\r
-                       return null;\r
-               }\r
-\r
-\r
-               @Override\r
-        public int hashCode() {\r
-            final int prime = 31;\r
-            int result = 1;\r
-            result = prime * result + ((qname == null) ? 0 : qname.hashCode());\r
-            result = prime * result + ((path == null) ? 0 : path.hashCode());\r
-            result = prime * result + ((description == null) ? 0 : description.hashCode());\r
-            result = prime * result + ((reference == null) ? 0 : reference.hashCode());\r
-            result = prime * result + ((status == null) ? 0 : status.hashCode());\r
-            result = prime * result + (augmenting ? 1231 : 1237);\r
-            result = prime * result + (configuration ? 1231 : 1237);\r
-            result = prime * result + ((constraints == null) ? 0 : constraints.hashCode());\r
-            result = prime * result + ((augmentations == null) ? 0 : augmentations.hashCode());\r
-            result = prime * result + ((childNodes == null) ? 0 : childNodes.hashCode());\r
-            result = prime * result + ((groupings == null) ? 0 : groupings.hashCode());\r
-            result = prime * result + ((uses == null) ? 0 : uses.hashCode());\r
-            result = prime * result + (presence ? 1231 : 1237);\r
-            result = prime * result + ((mustDefinition == null) ? 0 : mustDefinition.hashCode());\r
-            return result;\r
-        }\r
-\r
-        @Override\r
-        public boolean equals(Object obj) {\r
-            if (this == obj) {\r
-                return true;\r
-            }\r
-            if (obj == null) {\r
-                return false;\r
-            }\r
-            if (getClass() != obj.getClass()) {\r
-                return false;\r
-            }\r
-            ContainerSchemaNodeImpl other = (ContainerSchemaNodeImpl) obj;\r
-            if (qname == null) {\r
-                if (other.qname != null) {\r
-                    return false;\r
-                }\r
-            } else if (!qname.equals(other.qname)) {\r
-                return false;\r
-            }\r
-            if (path == null) {\r
-                if (other.path != null) {\r
-                    return false;\r
-                }\r
-            } else if (!path.equals(other.path)) {\r
-                return false;\r
-            }\r
-            if (description == null) {\r
-                if (other.description != null) {\r
-                    return false;\r
-                }\r
-            } else if (!description.equals(other.description)) {\r
-                return false;\r
-            }\r
-            if (reference == null) {\r
-                if (other.reference != null) {\r
-                    return false;\r
-                }\r
-            } else if (!reference.equals(other.reference)) {\r
-                return false;\r
-            }\r
-            if (status == null) {\r
-                if (other.status != null) {\r
-                    return false;\r
-                }\r
-            } else if (!status.equals(other.status)) {\r
-                return false;\r
-            }\r
-            if(augmenting != other.augmenting) {\r
-               return false;\r
-            }\r
-            if(configuration != other.configuration) {\r
-               return false;\r
-            }\r
-            if (constraints == null) {\r
-                if (other.constraints != null) {\r
-                    return false;\r
-                }\r
-            } else if (!constraints.equals(other.constraints)) {\r
-                return false;\r
-            }\r
-            if (augmentations == null) {\r
-                if (other.augmentations != null) {\r
-                    return false;\r
-                }\r
-            } else if (!augmentations.equals(other.augmentations)) {\r
-                return false;\r
-            }\r
-            if (childNodes == null) {\r
-                if (other.childNodes != null) {\r
-                    return false;\r
-                }\r
-            } else if (!childNodes.equals(other.childNodes)) {\r
-                return false;\r
-            }\r
-            if (groupings == null) {\r
-                if (other.groupings != null) {\r
-                    return false;\r
-                }\r
-            } else if (!groupings.equals(other.groupings)) {\r
-                return false;\r
-            }\r
-            if (uses == null) {\r
-                if (other.uses != null) {\r
-                    return false;\r
-                }\r
-            } else if (!uses.equals(other.uses)) {\r
-                return false;\r
-            }\r
-               if(presence != other.presence) {\r
-               return false;\r
-            }\r
-               if (mustDefinition == null) {\r
-                if (other.mustDefinition != null) {\r
-                    return false;\r
-                }\r
-            } else if (!mustDefinition.equals(other.mustDefinition)) {\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-               @Override\r
-               public String toString() {\r
-                       StringBuilder sb = new StringBuilder(\r
-                                       ContainerSchemaNodeImpl.class.getSimpleName());\r
-                       sb.append("[");\r
-                       sb.append("qname=" + qname);\r
-                       sb.append(", path=" + path);\r
-                       sb.append(", description=" + description);\r
-                       sb.append(", reference=" + reference);\r
-                       sb.append(", status=" + status);\r
-                       sb.append(", augmenting=" + augmenting);\r
-                       sb.append(", constraints=" + constraints);\r
-                       sb.append(", augmentations=" + augmentations);\r
-                       sb.append(", childNodes=" + childNodes.values());\r
-                       sb.append(", groupings=" + groupings);\r
-                       sb.append(", uses=" + uses);\r
-                       sb.append(", presence=" + presence);\r
-                       sb.append(", mustDefinition="+ mustDefinition);\r
-                       sb.append("]");\r
-                       return sb.toString();\r
-               }\r
-       }\r
-\r
-}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/DeviationBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/DeviationBuilder.java
deleted file mode 100644 (file)
index abc6198..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import org.opendaylight.controller.model.parser.api.Builder;\r
-import org.opendaylight.controller.model.parser.util.YangModelBuilderHelper;\r
-import org.opendaylight.controller.yang.model.api.Deviation;\r
-import org.opendaylight.controller.yang.model.api.MustDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Deviation.Deviate;\r
-\r
-\r
-public class DeviationBuilder implements MustAwareBuilder, Builder {\r
-\r
-       private final DeviationImpl instance;\r
-       private MustDefinitionBuilder mustDefinitionBuilder;\r
-\r
-       DeviationBuilder(String targetPathStr) {\r
-               SchemaPath targetPath = YangModelBuilderHelper.parsePath(targetPathStr);\r
-               instance = new DeviationImpl(targetPath);\r
-       }\r
-\r
-       @Override\r
-       public Deviation build() {\r
-               // MUST definition\r
-               if(mustDefinitionBuilder != null) {\r
-                       MustDefinition md = mustDefinitionBuilder.build();\r
-                       instance.setMustDefinition(md);\r
-               }\r
-               return instance;\r
-       }\r
-\r
-       public void setDeviate(String deviate) {\r
-               if(deviate.equals("not-supported")) {\r
-                       instance.setDeviate(Deviate.NOT_SUPPORTED);\r
-               } else if(deviate.equals("add")) {\r
-                       instance.setDeviate(Deviate.ADD);\r
-               } else if(deviate.equals("replace")) {\r
-                       instance.setDeviate(Deviate.REPLACE);\r
-               } else if(deviate.equals("delete")) {\r
-                       instance.setDeviate(Deviate.DELETE);\r
-               } else {\r
-                       throw new IllegalArgumentException("Unsupported type of 'deviate' statement: "+ deviate);\r
-               }\r
-       }\r
-\r
-       public void setReference(String reference) {\r
-               instance.setReference(reference);\r
-       }\r
-\r
-       @Override\r
-       public void setMustDefinitionBuilder(MustDefinitionBuilder mustDefinitionBuilder) {\r
-               this.mustDefinitionBuilder = mustDefinitionBuilder;\r
-       }\r
-\r
-       private static class DeviationImpl implements Deviation {\r
-\r
-               private SchemaPath targetPath;\r
-               private Deviate deviate;\r
-               private String reference;\r
-               private MustDefinition mustDefinition;\r
-\r
-               private DeviationImpl(SchemaPath targetPath) {\r
-                       this.targetPath = targetPath;\r
-               }\r
-\r
-               @Override\r
-               public SchemaPath getTargetPath() {\r
-                       return targetPath;\r
-               }\r
-\r
-               @Override\r
-               public Deviate getDeviate() {\r
-                       return deviate;\r
-               }\r
-               private void setDeviate(Deviate deviate) {\r
-                       this.deviate = deviate;\r
-               }\r
-\r
-               @Override\r
-               public String getReference() {\r
-                       return reference;\r
-               }\r
-               private void setReference(String reference) {\r
-                       this.reference = reference;\r
-               }\r
-\r
-               @Override\r
-               public String toString() {\r
-                       return DeviationImpl.class.getSimpleName() +"[targetPath="+ targetPath +", deviate="+ deviate +", reference="+ reference +", mustDefinition="+ mustDefinition +"]";\r
-               }\r
-\r
-               @Override\r
-               public MustDefinition getMustDefinition() {\r
-                       return mustDefinition;\r
-               }\r
-               private void setMustDefinition(MustDefinition mustDefinition) {\r
-                       this.mustDefinition = mustDefinition;\r
-               }\r
-\r
-       }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/FeatureBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/FeatureBuilder.java
deleted file mode 100644 (file)
index e91d2fb..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.model.parser.api.SchemaNodeBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
-import org.opendaylight.controller.yang.model.api.FeatureDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaNode;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-\r
-\r
-public class FeatureBuilder implements SchemaNodeBuilder {\r
-\r
-       private final FeatureDefinitionImpl instance;\r
-       private final QName qname;\r
-\r
-       FeatureBuilder(QName qname) {\r
-               this.qname = qname;\r
-               instance = new FeatureDefinitionImpl(qname);\r
-       }\r
-\r
-       @Override\r
-       public SchemaNode build() {\r
-               return instance;\r
-       }\r
-\r
-       @Override\r
-       public QName getQName() {\r
-               return qname;\r
-       }\r
-\r
-       @Override\r
-       public void setPath(SchemaPath path) {\r
-               instance.setPath(path);\r
-       }\r
-\r
-       @Override\r
-       public void setDescription(String description) {\r
-               instance.setDescription(description);\r
-       }\r
-\r
-       @Override\r
-       public void setReference(String reference) {\r
-               instance.setReference(reference);\r
-       }\r
-\r
-       @Override\r
-       public void setStatus(Status status) {\r
-               instance.setStatus(status);\r
-       }\r
-\r
-       private static class FeatureDefinitionImpl implements FeatureDefinition {\r
-\r
-               private final QName qname;\r
-               private SchemaPath path;\r
-               private String description;\r
-               private String reference;\r
-               private Status status;\r
-\r
-               private FeatureDefinitionImpl(QName qname) {\r
-                       this.qname = qname;\r
-               }\r
-\r
-               @Override\r
-               public QName getQName() {\r
-                       return qname;\r
-               }\r
-\r
-               @Override\r
-               public SchemaPath getPath() {\r
-                       return path;\r
-               }\r
-               private void setPath(SchemaPath path) {\r
-                       this.path = path;;\r
-               }\r
-\r
-               @Override\r
-               public String getDescription() {\r
-                       return description;\r
-               }\r
-               private void setDescription(String description) {\r
-                       this.description = description;\r
-               }\r
-\r
-               @Override\r
-               public String getReference() {\r
-                       return reference;\r
-               }\r
-               private void setReference(String reference) {\r
-                       this.reference = reference;\r
-               }\r
-\r
-               @Override\r
-               public Status getStatus() {\r
-                       return status;\r
-               }\r
-               private void setStatus(Status status) {\r
-                       this.status = status;\r
-               }\r
-\r
-               @Override\r
-               public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-                       // TODO Auto-generated method stub\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-        public int hashCode() {\r
-            final int prime = 31;\r
-            int result = 1;\r
-            result = prime * result + ((qname == null) ? 0 : qname.hashCode());\r
-            result = prime * result + ((path == null) ? 0 : path.hashCode());\r
-            result = prime * result + ((description == null) ? 0 : description.hashCode());\r
-            result = prime * result + ((reference == null) ? 0 : reference.hashCode());\r
-            result = prime * result + ((status == null) ? 0 : status.hashCode());\r
-            return result;\r
-        }\r
-\r
-        @Override\r
-        public boolean equals(Object obj) {\r
-            if (this == obj) {\r
-                return true;\r
-            }\r
-            if (obj == null) {\r
-                return false;\r
-            }\r
-            if (getClass() != obj.getClass()) {\r
-                return false;\r
-            }\r
-            FeatureDefinitionImpl other = (FeatureDefinitionImpl) obj;\r
-            if (qname == null) {\r
-                if (other.qname != null) {\r
-                    return false;\r
-                }\r
-            } else if (!qname.equals(other.qname)) {\r
-                return false;\r
-            }\r
-            if (path == null) {\r
-                if (other.path != null) {\r
-                    return false;\r
-                }\r
-            } else if (!path.equals(other.path)) {\r
-                return false;\r
-            }\r
-            if (description == null) {\r
-                if (other.description != null) {\r
-                    return false;\r
-                }\r
-            } else if (!description.equals(other.description)) {\r
-                return false;\r
-            }\r
-            if (reference == null) {\r
-                if (other.reference != null) {\r
-                    return false;\r
-                }\r
-            } else if (!reference.equals(other.reference)) {\r
-                return false;\r
-            }\r
-            if (status == null) {\r
-                if (other.status != null) {\r
-                    return false;\r
-                }\r
-            } else if (!status.equals(other.status)) {\r
-                return false;\r
-            }\r
-            return true;\r
-        }\r
-\r
-               @Override\r
-               public String toString() {\r
-                       StringBuilder sb = new StringBuilder(FeatureDefinitionImpl.class.getSimpleName());\r
-                       sb.append("[name="+ qname);\r
-                       sb.append(", path="+ path);\r
-                       sb.append(", description="+ description);\r
-                       sb.append(", reference="+ reference);\r
-                       sb.append(", status="+ status +"]");\r
-                       return sb.toString();\r
-               }\r
-       }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/GroupingBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/GroupingBuilderImpl.java
deleted file mode 100644 (file)
index 5ffe307..0000000
+++ /dev/null
@@ -1,245 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.model.parser.api.DataSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-\r
-public class GroupingBuilderImpl implements GroupingBuilder {\r
-\r
-       private final GroupingDefinitionImpl instance;\r
-       private final Set<DataSchemaNodeBuilder> childNodes = new HashSet<DataSchemaNodeBuilder>();\r
-       private final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();\r
-       private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();\r
-       private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();\r
-\r
-       GroupingBuilderImpl(QName qname) {\r
-               this.instance = new GroupingDefinitionImpl(qname);\r
-       }\r
-\r
-       @Override\r
-       public GroupingDefinition build() {\r
-               // CHILD NODES\r
-               Map<QName, DataSchemaNode> childs = new HashMap<QName, DataSchemaNode>();\r
-               for(DataSchemaNodeBuilder node : childNodes) {\r
-                       childs.put(node.getQName(), node.build());\r
-               }\r
-               instance.setChildNodes(childs);\r
-\r
-               // GROUPINGS\r
-               Set<GroupingDefinition> groupingDefinitions = new HashSet<GroupingDefinition>();\r
-               for(GroupingBuilder builder : groupings) {\r
-                       groupingDefinitions.add(builder.build());\r
-               }\r
-               instance.setGroupings(groupingDefinitions);\r
-\r
-               // TYPEDEFS\r
-               Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();\r
-               for (TypeDefinitionBuilder entry : addedTypedefs) {\r
-                       typedefs.add(entry.build());\r
-               }\r
-               instance.setTypeDefinitions(typedefs);\r
-\r
-               // USES\r
-               Set<UsesNode> usesNodeDefinitions = new HashSet<UsesNode>();\r
-               for(UsesNodeBuilder builder : usesNodes) {\r
-                       usesNodeDefinitions.add(builder.build());\r
-               }\r
-               instance.setUses(usesNodeDefinitions);\r
-\r
-               return instance;\r
-       }\r
-\r
-       @Override\r
-       public void addTypedef(TypeDefinitionBuilder type) {\r
-               addedTypedefs.add(type);\r
-       }\r
-       @Override\r
-       public void setPath(SchemaPath schemaPath) {\r
-               instance.setPath(schemaPath);\r
-       }\r
-       @Override\r
-       public void setDescription(String description) {\r
-               instance.setDescription(description);\r
-       }\r
-       @Override\r
-       public void setReference(String reference) {\r
-               instance.setReference(reference);\r
-       }\r
-       @Override\r
-       public void setStatus(Status status) {\r
-               instance.setStatus(status);\r
-       }\r
-\r
-       @Override\r
-       public void addChildNode(DataSchemaNodeBuilder childNode) {\r
-               childNodes.add(childNode);\r
-       }\r
-\r
-       @Override\r
-       public void addGrouping(GroupingBuilder grouping) {\r
-               groupings.add(grouping);\r
-       }\r
-\r
-       @Override\r
-       public void addUsesNode(UsesNodeBuilder usesBuilder) {\r
-               usesNodes.add(usesBuilder);\r
-       }\r
-\r
-\r
-\r
-       private static class GroupingDefinitionImpl implements GroupingDefinition {\r
-\r
-               private final QName qname;\r
-               private SchemaPath path;\r
-               private String description;\r
-               private String reference;\r
-               private Status status;\r
-\r
-               private Map<QName, DataSchemaNode> childNodes;\r
-               private Set<GroupingDefinition> groupings;\r
-               private Set<TypeDefinition<?>> typeDefinitions;\r
-               private Set<UsesNode> uses;\r
-\r
-               private GroupingDefinitionImpl(QName qname) {\r
-                       this.qname = qname;\r
-               }\r
-\r
-               @Override\r
-               public QName getQName() {\r
-                       return qname;\r
-               }\r
-\r
-               @Override\r
-               public SchemaPath getPath() {\r
-                       return path;\r
-               }\r
-               private void setPath(SchemaPath path) {\r
-                       this.path = path;\r
-               }\r
-\r
-               @Override\r
-               public String getDescription() {\r
-                       return description;\r
-               }\r
-               private void setDescription(String description) {\r
-                       this.description = description;\r
-               }\r
-\r
-               @Override\r
-               public String getReference() {\r
-                       return reference;\r
-               }\r
-               private void setReference(String reference) {\r
-                       this.reference = reference;\r
-               }\r
-\r
-               @Override\r
-               public Status getStatus() {\r
-                       return status;\r
-               }\r
-               private void setStatus(Status status) {\r
-                       this.status = status;\r
-               }\r
-\r
-               @Override\r
-               public Set<DataSchemaNode> getChildNodes() {\r
-                       return new HashSet<DataSchemaNode>(childNodes.values());\r
-               }\r
-               private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {\r
-                       this.childNodes = childNodes;\r
-               }\r
-\r
-               @Override\r
-               public Set<GroupingDefinition> getGroupings() {\r
-                       return groupings;\r
-               }\r
-               private void setGroupings(Set<GroupingDefinition> groupings) {\r
-                       this.groupings = groupings;\r
-               }\r
-\r
-               @Override\r
-               public Set<UsesNode> getUses() {\r
-                       return uses;\r
-               }\r
-               private void setUses(Set<UsesNode> uses) {\r
-                       this.uses = uses;\r
-               }\r
-\r
-               @Override\r
-               public Set<TypeDefinition<?>> getTypeDefinitions() {\r
-                       return typeDefinitions;\r
-               }\r
-               private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {\r
-                       this.typeDefinitions = typeDefinitions;\r
-               }\r
-\r
-               @Override\r
-               public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-                       // TODO Auto-generated method stub\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public DataSchemaNode getDataChildByName(QName name) {\r
-                       return childNodes.get(name);\r
-               }\r
-\r
-               @Override\r
-               public DataSchemaNode getDataChildByName(String name) {\r
-                       DataSchemaNode result = null;\r
-                       for(Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {\r
-                               if(entry.getKey().getLocalName().equals(name)) {\r
-                                       result = entry.getValue();\r
-                                       break;\r
-                               }\r
-                       }\r
-                       return result;\r
-               }\r
-\r
-               @Override\r
-               public String toString() {\r
-                       StringBuilder sb = new StringBuilder();\r
-                       sb.append(GroupingDefinitionImpl.class.getSimpleName() +"[\n");\r
-                       sb.append("qname="+ qname +", \n");\r
-                       sb.append("path="+ path +", \n");\r
-                       sb.append("description="+ description +", \n");\r
-                       sb.append("reference="+ reference +", \n");\r
-                       sb.append("status="+ status +", \n");\r
-                       sb.append("childNodes="+ childNodes.values() +", \n");\r
-                       sb.append("groupings="+ groupings +"]");\r
-                       return sb.toString();\r
-               }\r
-       }\r
-\r
-       /**\r
-        * Always returns null.\r
-        */\r
-       @Override\r
-       public QName getQName() {\r
-               return null;\r
-       }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/LeafListSchemaNodeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/LeafListSchemaNodeBuilder.java
deleted file mode 100644 (file)
index f2ea8ca..0000000
+++ /dev/null
@@ -1,221 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.model.parser.api.DataSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.SchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeAwareBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ConstraintDefinition;\r
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
-import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.MustDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-\r
-\r
-public class LeafListSchemaNodeBuilder implements SchemaNodeBuilder, TypeAwareBuilder, MustAwareBuilder, DataSchemaNodeBuilder {\r
-\r
-               private final LeafListSchemaNodeImpl instance;\r
-               private final QName qname;\r
-               private TypeDefinition<?> type;\r
-               private MustDefinitionBuilder mustDefinitionBuilder;\r
-\r
-               LeafListSchemaNodeBuilder(QName qname) {\r
-                       this.qname = qname;\r
-                       instance = new LeafListSchemaNodeImpl(qname);\r
-               }\r
-\r
-\r
-               @Override\r
-               public DataSchemaNode build() {\r
-                       if(mustDefinitionBuilder != null) {\r
-                               MustDefinition mustDefinition = mustDefinitionBuilder.build();\r
-                               instance.setMustDefinition(mustDefinition);\r
-                       }\r
-                       return instance;\r
-               }\r
-\r
-               @Override\r
-               public QName getQName() {\r
-                       return qname;\r
-               }\r
-\r
-               @Override\r
-               public void setPath(SchemaPath path) {\r
-                       instance.setPath(path);\r
-               }\r
-\r
-               @Override\r
-               public void setDescription(String description) {\r
-                       instance.setDescription(description);\r
-               }\r
-\r
-               @Override\r
-               public void setReference(String reference) {\r
-                       instance.setReference(reference);\r
-               }\r
-\r
-               @Override\r
-               public void setStatus(Status status) {\r
-                       instance.setStatus(status);\r
-               }\r
-\r
-               @Override\r
-               public TypeDefinition<?> getType() {\r
-                       return type;\r
-               }\r
-\r
-               @Override\r
-               public void setType(TypeDefinition<?> type) {\r
-                       this.type = type;\r
-                       instance.setType(type);\r
-               }\r
-\r
-               @Override\r
-               public void setMustDefinitionBuilder(MustDefinitionBuilder mustDefinitionBuilder) {\r
-                       this.mustDefinitionBuilder = mustDefinitionBuilder;\r
-               }\r
-\r
-               public void setAugmenting(boolean augmenting) {\r
-                       instance.setAugmenting(augmenting);\r
-               }\r
-               public void setConfiguration(boolean configuration) {\r
-                       instance.setConfiguration(configuration);\r
-               }\r
-               public void setConstraints(ConstraintDefinition constraints) {\r
-                       instance.setConstraints(constraints);\r
-               }\r
-               public void setUserOrdered(boolean userOrdered) {\r
-                       instance.setUserOrdered(userOrdered);\r
-               }\r
-\r
-\r
-               private class LeafListSchemaNodeImpl implements LeafListSchemaNode {\r
-                       private final QName qname;\r
-                       private SchemaPath path;\r
-                       private String description;\r
-                       private String reference;\r
-                       private Status status = Status.CURRENT;\r
-\r
-                       private boolean augmenting;\r
-                       private boolean configuration;\r
-                       private ConstraintDefinition constraints;\r
-\r
-                       private TypeDefinition<?> type;\r
-                       private boolean userOrdered;\r
-\r
-                       private MustDefinition mustDefinition;\r
-\r
-                       private LeafListSchemaNodeImpl(QName qname) {\r
-                               this.qname = qname;\r
-                       }\r
-\r
-\r
-                       @Override\r
-                       public QName getQName() {\r
-                               return qname;\r
-                       }\r
-\r
-                       @Override\r
-                       public SchemaPath getPath() {\r
-                               return path;\r
-                       }\r
-                       private void setPath(SchemaPath path) {\r
-                               this.path = path;;\r
-                       }\r
-\r
-                       @Override\r
-                       public String getDescription() {\r
-                               return description;\r
-                       }\r
-                       private void setDescription(String description) {\r
-                               this.description = description;\r
-                       }\r
-\r
-                       @Override\r
-                       public String getReference() {\r
-                               return reference;\r
-                       }\r
-                       private void setReference(String reference) {\r
-                               this.reference = reference;\r
-                       }\r
-\r
-                       @Override\r
-                       public Status getStatus() {\r
-                               return status;\r
-                       }\r
-                       private void setStatus(Status status) {\r
-                               this.status = status;\r
-                       }\r
-\r
-                       @Override\r
-                       public boolean isAugmenting() {\r
-                               return augmenting;\r
-                       }\r
-                       private void setAugmenting(boolean augmenting) {\r
-                               this.augmenting = augmenting;\r
-                       }\r
-\r
-                       @Override\r
-                       public boolean isConfiguration() {\r
-                               return configuration;\r
-                       }\r
-                       private void setConfiguration(boolean configuration) {\r
-                               this.configuration = configuration;\r
-                       }\r
-\r
-                       @Override\r
-                       public ConstraintDefinition getConstraints() {\r
-                               return constraints;\r
-                       }\r
-                       private void setConstraints(ConstraintDefinition constraints) {\r
-                               this.constraints = constraints;\r
-                       }\r
-\r
-                       @Override\r
-                       public TypeDefinition<?> getType() {\r
-                               return type;\r
-                       }\r
-                       public void setType(TypeDefinition<? extends TypeDefinition<?>> type) {\r
-                               this.type = type;\r
-                       }\r
-\r
-                       @Override\r
-                       public boolean isUserOrdered() {\r
-                               return userOrdered;\r
-                       }\r
-                       private void setUserOrdered(boolean userOrdered) {\r
-                               this.userOrdered = userOrdered;\r
-                       }\r
-\r
-                       @Override\r
-                       public MustDefinition getMustDefinition() {\r
-                               return mustDefinition;\r
-                       }\r
-                       private void setMustDefinition(MustDefinition mustDefinition) {\r
-                               this.mustDefinition = mustDefinition;\r
-                       }\r
-\r
-                       @Override\r
-                       public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-                               // TODO Auto-generated method stub\r
-                               return null;\r
-                       }\r
-\r
-                       @Override\r
-                       public String toString() {\r
-                               return LeafListSchemaNodeImpl.class.getSimpleName() +"[qname="+ qname +", type="+ type +"]";\r
-                       }\r
-               }\r
-\r
-       }
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/LeafSchemaNodeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/LeafSchemaNodeBuilder.java
deleted file mode 100644 (file)
index f50ac8a..0000000
+++ /dev/null
@@ -1,232 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.model.parser.api.DataSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.SchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeAwareBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ConstraintDefinition;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
-import org.opendaylight.controller.yang.model.api.LeafSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.MustDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-\r
-\r
-public class LeafSchemaNodeBuilder implements DataSchemaNodeBuilder,\r
-               SchemaNodeBuilder, TypeAwareBuilder, MustAwareBuilder {\r
-\r
-       private final QName qname;\r
-       private final LeafSchemaNodeImpl instance;\r
-       private TypeDefinition<?> type;\r
-       private MustDefinitionBuilder mustDefinitionBuilder;\r
-\r
-       LeafSchemaNodeBuilder(QName qname) {\r
-               this.qname = qname;\r
-               instance = new LeafSchemaNodeImpl(qname);\r
-       }\r
-\r
-       @Override\r
-       public LeafSchemaNode build() {\r
-               if (mustDefinitionBuilder != null) {\r
-                       MustDefinition mustDefinition = mustDefinitionBuilder.build();\r
-                       instance.setMustDefinition(mustDefinition);\r
-               }\r
-               return instance;\r
-       }\r
-\r
-       @Override\r
-       public QName getQName() {\r
-               return qname;\r
-       }\r
-\r
-       @Override\r
-       public void setPath(SchemaPath path) {\r
-               instance.setPath(path);\r
-       }\r
-\r
-       @Override\r
-       public void setDescription(String description) {\r
-               instance.setDescription(description);\r
-       }\r
-\r
-       @Override\r
-       public void setReference(String reference) {\r
-               instance.setReference(reference);\r
-       }\r
-\r
-       @Override\r
-       public void setStatus(Status status) {\r
-               instance.setStatus(status);\r
-       }\r
-\r
-       public void setAugmenting(boolean augmenting) {\r
-               instance.setAugmenting(augmenting);\r
-       }\r
-\r
-       public void setConfiguration(boolean configuration) {\r
-               instance.setConfiguration(configuration);\r
-       }\r
-\r
-       public void setConstraints(ConstraintDefinition constraints) {\r
-               instance.setConstraints(constraints);\r
-       }\r
-\r
-       @Override\r
-       public TypeDefinition<?> getType() {\r
-               return type;\r
-       }\r
-\r
-       @Override\r
-       public void setType(TypeDefinition<?> type) {\r
-               this.type = type;\r
-               instance.setType(type);\r
-       }\r
-\r
-       @Override\r
-       public void setMustDefinitionBuilder(\r
-                       MustDefinitionBuilder mustDefinitionBuilder) {\r
-               this.mustDefinitionBuilder = mustDefinitionBuilder;\r
-       }\r
-\r
-       private class LeafSchemaNodeImpl implements LeafSchemaNode {\r
-               private final QName qname;\r
-               private SchemaPath path;\r
-               private String description;\r
-               private String reference;\r
-               private Status status = Status.CURRENT;\r
-\r
-               private boolean augmenting;\r
-               private boolean configuration;\r
-               private ConstraintDefinition constraints;\r
-\r
-               private TypeDefinition<?> type;\r
-               private MustDefinition mustDefinition;\r
-\r
-               private LeafSchemaNodeImpl(QName qname) {\r
-                       this.qname = qname;\r
-               }\r
-\r
-               @Override\r
-               public QName getQName() {\r
-                       return qname;\r
-               }\r
-\r
-               @Override\r
-               public SchemaPath getPath() {\r
-                       return path;\r
-               }\r
-\r
-               private void setPath(SchemaPath path) {\r
-                       this.path = path;\r
-               }\r
-\r
-               @Override\r
-               public String getDescription() {\r
-                       return description;\r
-               }\r
-\r
-               private void setDescription(String description) {\r
-                       this.description = description;\r
-               }\r
-\r
-               @Override\r
-               public String getReference() {\r
-                       return reference;\r
-               }\r
-\r
-               private void setReference(String reference) {\r
-                       this.reference = reference;\r
-               }\r
-\r
-               @Override\r
-               public Status getStatus() {\r
-                       return status;\r
-               }\r
-\r
-               private void setStatus(Status status) {\r
-                       if (status != null) {\r
-                               this.status = status;\r
-                       }\r
-               }\r
-\r
-               @Override\r
-               public boolean isAugmenting() {\r
-                       return augmenting;\r
-               }\r
-\r
-               private void setAugmenting(boolean augmenting) {\r
-                       this.augmenting = augmenting;\r
-               }\r
-\r
-               @Override\r
-               public boolean isConfiguration() {\r
-                       return configuration;\r
-               }\r
-\r
-               private void setConfiguration(boolean configuration) {\r
-                       this.configuration = configuration;\r
-               }\r
-\r
-               @Override\r
-               public ConstraintDefinition getConstraints() {\r
-                       return constraints;\r
-               }\r
-\r
-               private void setConstraints(ConstraintDefinition constraints) {\r
-                       this.constraints = constraints;\r
-               }\r
-\r
-               @Override\r
-               public TypeDefinition<?> getType() {\r
-                       return type;\r
-               }\r
-\r
-               private void setType(TypeDefinition<? extends TypeDefinition<?>> type) {\r
-                       this.type = type;\r
-               }\r
-\r
-               @Override\r
-               public MustDefinition getMustDefinition() {\r
-                       return mustDefinition;\r
-               }\r
-\r
-               private void setMustDefinition(MustDefinition mustDefinition) {\r
-                       this.mustDefinition = mustDefinition;\r
-               }\r
-\r
-               @Override\r
-               public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-                       // TODO Auto-generated method stub\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public String toString() {\r
-                       StringBuilder sb = new StringBuilder(\r
-                                       LeafSchemaNodeImpl.class.getSimpleName());\r
-                       sb.append("[");\r
-                       sb.append("qname=" + qname);\r
-                       sb.append(", path=" + path);\r
-                       sb.append(", description=" + description);\r
-                       sb.append(", reference=" + reference);\r
-                       sb.append(", status=" + status);\r
-                       sb.append(", augmenting=" + augmenting);\r
-                       sb.append(", configuration=" + configuration);\r
-                       sb.append(", constraints=" + constraints);\r
-                       sb.append(", type=" + type);\r
-                       sb.append(", mustDefinition=" + mustDefinition);\r
-                       sb.append("]");\r
-                       return sb.toString();\r
-               }\r
-       }\r
-}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/ListSchemaNodeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/ListSchemaNodeBuilder.java
deleted file mode 100644 (file)
index 3059ba9..0000000
+++ /dev/null
@@ -1,463 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.model.parser.api.AbstractChildNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.AugmentationTargetBuilder;\r
-import org.opendaylight.controller.model.parser.api.DataSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.api.SchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionAwareBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
-import org.opendaylight.controller.yang.model.api.ConstraintDefinition;\r
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.controller.yang.model.api.ListSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-\r
-public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements DataSchemaNodeBuilder, SchemaNodeBuilder, AugmentationTargetBuilder, TypeDefinitionAwareBuilder {\r
-\r
-               private final ListSchemaNodeImpl instance;\r
-\r
-               private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();\r
-               private final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();\r
-               private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();\r
-\r
-               ListSchemaNodeBuilder(QName qname) {\r
-                       super(qname);\r
-                       instance = new ListSchemaNodeImpl(qname);\r
-               }\r
-\r
-               @Override\r
-               public ListSchemaNode build() {\r
-                       // CHILD NODES\r
-                       Map<QName, DataSchemaNode> childs = new HashMap<QName, DataSchemaNode>();\r
-                       for(DataSchemaNodeBuilder node : childNodes) {\r
-                               childs.put(node.getQName(), node.build());\r
-                       }\r
-                       instance.setChildNodes(childs);\r
-\r
-                       // TYPEDEFS\r
-                       Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();\r
-                       for (TypeDefinitionBuilder entry : addedTypedefs) {\r
-                               typedefs.add(entry.build());\r
-                       }\r
-                       instance.setTypeDefinitions(typedefs);\r
-\r
-                       // USES\r
-                       Set<UsesNode> usesNodeDefinitions = new HashSet<UsesNode>();\r
-                       for(UsesNodeBuilder builder : usesNodes) {\r
-                               usesNodeDefinitions.add(builder.build());\r
-                       }\r
-                       instance.setUses(usesNodeDefinitions);\r
-\r
-                       // GROUPINGS\r
-                       Set<GroupingDefinition> groupingDefinitions = new HashSet<GroupingDefinition>();\r
-                       for (GroupingBuilder builder : groupings) {\r
-                               groupingDefinitions.add(builder.build());\r
-                       }\r
-                       instance.setGroupings(groupingDefinitions);\r
-\r
-                       instance.setAvailableAugmentations(augmentations);\r
-\r
-                       return instance;\r
-               }\r
-\r
-\r
-               @Override\r
-               public void addTypedef(TypeDefinitionBuilder type) {\r
-                       addedTypedefs.add(type);\r
-               }\r
-\r
-               @Override\r
-               public void setPath(SchemaPath path) {\r
-                       instance.setPath(path);\r
-               }\r
-\r
-               @Override\r
-               public void setDescription(String description) {\r
-                       instance.setDescription(description);\r
-               }\r
-\r
-               @Override\r
-               public void setReference(String reference) {\r
-                       instance.setReference(reference);\r
-               }\r
-\r
-               @Override\r
-               public void setStatus(Status status) {\r
-                       instance.setStatus(status);\r
-               }\r
-\r
-               @Override\r
-               public void addUsesNode(UsesNodeBuilder usesBuilder) {\r
-                       usesNodes.add(usesBuilder);\r
-               }\r
-\r
-               @Override\r
-               public void addAugmentation(AugmentationSchema augmentationSchema) {\r
-                       augmentations.add(augmentationSchema);\r
-               }\r
-\r
-               public void setKeyDefinition(List<QName> keyDefinition) {\r
-                       instance.setKeyDefinition(keyDefinition);\r
-               }\r
-               public void setAugmenting(boolean augmenting) {\r
-                       instance.setAugmenting(augmenting);\r
-               }\r
-               public void setConfiguration(boolean configuration) {\r
-                       instance.setConfiguration(configuration);\r
-               }\r
-               public void setConstraints(ConstraintDefinition constraints) {\r
-                       instance.setConstraints(constraints);\r
-               }\r
-               public void setUserOrdered(boolean userOrdered) {\r
-                       instance.setUserOrdered(userOrdered);\r
-               }\r
-\r
-\r
-               private class ListSchemaNodeImpl implements ListSchemaNode {\r
-                       private final QName qname;\r
-                       private SchemaPath path;\r
-                       private String description;\r
-                       private String reference;\r
-                       private Status status = Status.CURRENT;\r
-\r
-                       private List<QName> keyDefinition;\r
-\r
-                       private boolean augmenting;\r
-                       private boolean configuration;\r
-                       private ConstraintDefinition constraints;\r
-\r
-                       private Set<AugmentationSchema> augmentations;\r
-\r
-                       private Map<QName, DataSchemaNode> childNodes;\r
-                       private Set<TypeDefinition<?>> typeDefinitions;\r
-                       private Set<GroupingDefinition> groupings;\r
-                       private Set<UsesNode> uses;\r
-\r
-                       private boolean userOrdered;\r
-\r
-                       private ListSchemaNodeImpl(QName qname) {\r
-                               this.qname = qname;\r
-                       }\r
-\r
-\r
-                       @Override\r
-                       public QName getQName() {\r
-                               return qname;\r
-                       }\r
-\r
-                       @Override\r
-                       public SchemaPath getPath() {\r
-                               return path;\r
-                       }\r
-                       private void setPath(SchemaPath path) {\r
-                               this.path = path;\r
-                       }\r
-\r
-                       @Override\r
-                       public String getDescription() {\r
-                               return description;\r
-                       }\r
-                       private void setDescription(String description) {\r
-                               this.description = description;\r
-                       }\r
-\r
-                       @Override\r
-                       public String getReference() {\r
-                               return reference;\r
-                       }\r
-                       private void setReference(String reference) {\r
-                               this.reference = reference;\r
-                       }\r
-\r
-                       @Override\r
-                       public Status getStatus() {\r
-                               return status;\r
-                       }\r
-                       private void setStatus(Status status) {\r
-                               this.status = status;\r
-                       }\r
-\r
-                       @Override\r
-                       public List<QName> getKeyDefinition() {\r
-                               return keyDefinition;\r
-                       }\r
-                       private void setKeyDefinition(List<QName> keyDefinition) {\r
-                               this.keyDefinition = keyDefinition;\r
-                       }\r
-\r
-                       @Override\r
-                       public boolean isAugmenting() {\r
-                               return augmenting;\r
-                       }\r
-                       private void setAugmenting(boolean augmenting) {\r
-                               this.augmenting = augmenting;\r
-                       }\r
-\r
-                       @Override\r
-                       public boolean isConfiguration() {\r
-                               return configuration;\r
-                       }\r
-                       private void setConfiguration(boolean configuration) {\r
-                               this.configuration = configuration;\r
-                       }\r
-\r
-                       @Override\r
-                       public ConstraintDefinition getConstraints() {\r
-                               return constraints;\r
-                       }\r
-                       private void setConstraints(ConstraintDefinition constraints) {\r
-                               this.constraints = constraints;\r
-                       }\r
-\r
-                       @Override\r
-                       public Set<AugmentationSchema> getAvailableAugmentations() {\r
-                               return augmentations;\r
-                       }\r
-                       private void setAvailableAugmentations(Set<AugmentationSchema> augmentations) {\r
-                               this.augmentations = augmentations;\r
-                       }\r
-\r
-                       @Override\r
-                       public Set<DataSchemaNode> getChildNodes() {\r
-                               return new HashSet<DataSchemaNode>(childNodes.values());\r
-                       }\r
-                       void setChildNodes(Map<QName, DataSchemaNode> childNodes) {\r
-                               this.childNodes = childNodes;\r
-                       }\r
-\r
-                       @Override\r
-                       public Set<GroupingDefinition> getGroupings() {\r
-                               return groupings;\r
-                       }\r
-                       private void setGroupings(Set<GroupingDefinition> groupings) {\r
-                               this.groupings = groupings;\r
-                       }\r
-\r
-                       @Override\r
-                       public Set<TypeDefinition<?>> getTypeDefinitions() {\r
-                               return typeDefinitions;\r
-                       }\r
-                       private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {\r
-                               this.typeDefinitions = typeDefinitions;\r
-                       }\r
-\r
-                       @Override\r
-                       public Set<UsesNode> getUses() {\r
-                               return uses;\r
-                       }\r
-                       private void setUses(Set<UsesNode> uses) {\r
-                               this.uses = uses;\r
-                       }\r
-\r
-                       @Override\r
-                       public DataSchemaNode getDataChildByName(QName name) {\r
-                               return childNodes.get(name);\r
-                       }\r
-\r
-                       @Override\r
-                       public DataSchemaNode getDataChildByName(String name) {\r
-                               DataSchemaNode result = null;\r
-                               for(Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {\r
-                                       if(entry.getKey().getLocalName().equals(name)) {\r
-                                               result = entry.getValue();\r
-                                               break;\r
-                                       }\r
-                               }\r
-                               return result;\r
-                       }\r
-\r
-                       @Override\r
-                       public boolean isUserOrdered() {\r
-                               return userOrdered;\r
-                       }\r
-                       private void setUserOrdered(boolean userOrdered) {\r
-                               this.userOrdered = userOrdered;\r
-                       }\r
-\r
-                       @Override\r
-                       public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-                               // TODO Auto-generated method stub\r
-                               return null;\r
-                       }\r
-\r
-                       @Override\r
-               public int hashCode() {\r
-                   final int prime = 31;\r
-                   int result = 1;\r
-                   result = prime * result + ((qname == null) ? 0 : qname.hashCode());\r
-                   result = prime * result + ((path == null) ? 0 : path.hashCode());\r
-                   result = prime * result + ((description == null) ? 0 : description.hashCode());\r
-                   result = prime * result + ((reference == null) ? 0 : reference.hashCode());\r
-                   result = prime * result + ((status == null) ? 0 : status.hashCode());\r
-                   result = prime * result + ((keyDefinition == null) ? 0 : keyDefinition.hashCode());\r
-                   result = prime * result + (augmenting ? 1231 : 1237);\r
-                   result = prime * result + (configuration ? 1231 : 1237);\r
-                   result = prime * result + ((constraints == null) ? 0 : constraints.hashCode());\r
-                   result = prime * result + ((augmentations == null) ? 0 : augmentations.hashCode());\r
-                   result = prime * result + ((childNodes == null) ? 0 : childNodes.hashCode());\r
-                   result = prime * result + ((typeDefinitions == null) ? 0 : typeDefinitions.hashCode());\r
-                   result = prime * result + ((groupings == null) ? 0 : groupings.hashCode());\r
-                   result = prime * result + ((uses == null) ? 0 : uses.hashCode());\r
-                   result = prime * result + (userOrdered ? 1231 : 1237);\r
-                   return result;\r
-               }\r
-\r
-\r
-                       @Override\r
-               public boolean equals(Object obj) {\r
-                   if (this == obj) {\r
-                       return true;\r
-                   }\r
-                   if (obj == null) {\r
-                       return false;\r
-                   }\r
-                   if (getClass() != obj.getClass()) {\r
-                       return false;\r
-                   }\r
-                   ListSchemaNodeImpl other = (ListSchemaNodeImpl) obj;\r
-                   if (qname == null) {\r
-                       if (other.qname != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!qname.equals(other.qname)) {\r
-                       return false;\r
-                   }\r
-                   if (path == null) {\r
-                       if (other.path != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!path.equals(other.path)) {\r
-                       return false;\r
-                   }\r
-                   if (description == null) {\r
-                       if (other.description != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!description.equals(other.description)) {\r
-                       return false;\r
-                   }\r
-                   if (reference == null) {\r
-                       if (other.reference != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!reference.equals(other.reference)) {\r
-                       return false;\r
-                   }\r
-                   if (status == null) {\r
-                       if (other.status != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!status.equals(other.status)) {\r
-                       return false;\r
-                   }\r
-                   if (keyDefinition == null) {\r
-                       if (other.keyDefinition != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!keyDefinition.equals(other.keyDefinition)) {\r
-                       return false;\r
-                   }\r
-                   if(augmenting != other.augmenting) {\r
-                       return false;\r
-                   }\r
-                   if(configuration != other.configuration) {\r
-                       return false;\r
-                   }\r
-                   if (constraints == null) {\r
-                       if (other.constraints != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!constraints.equals(other.constraints)) {\r
-                       return false;\r
-                   }\r
-                   if (augmentations == null) {\r
-                       if (other.augmentations != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!augmentations.equals(other.augmentations)) {\r
-                       return false;\r
-                   }\r
-                   if (childNodes == null) {\r
-                       if (other.childNodes != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!childNodes.equals(other.childNodes)) {\r
-                       return false;\r
-                   }\r
-                   if (typeDefinitions == null) {\r
-                       if (other.typeDefinitions != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!typeDefinitions.equals(other.typeDefinitions)) {\r
-                       return false;\r
-                   }\r
-                   if (groupings == null) {\r
-                       if (other.groupings != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!groupings.equals(other.groupings)) {\r
-                       return false;\r
-                   }\r
-                   if (uses == null) {\r
-                       if (other.uses != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!uses.equals(other.uses)) {\r
-                       return false;\r
-                   }\r
-                       if(userOrdered != other.userOrdered) {\r
-                       return false;\r
-                   }\r
-                   return true;\r
-               }\r
-\r
-\r
-\r
-\r
-                       @Override\r
-                       public String toString() {\r
-                               StringBuilder sb = new StringBuilder(ListSchemaNodeImpl.class.getSimpleName());\r
-                               sb.append("[");\r
-                               sb.append("qname="+ qname);\r
-                               sb.append(", path="+ path);\r
-                               sb.append(", description="+ description);\r
-                               sb.append(", reference="+ reference);\r
-                               sb.append(", status="+ status);\r
-                               sb.append(", keyDefinition="+ keyDefinition);\r
-                               sb.append(", augmenting="+ augmenting);\r
-                               sb.append(", configuration="+ configuration);\r
-                               sb.append(", constraints="+ constraints);\r
-                               sb.append(", augmentations="+ augmentations);\r
-                               sb.append(", childNodes="+ childNodes.values());\r
-                               sb.append(", typedefinitions="+ typeDefinitions);\r
-                               sb.append(", groupings="+ groupings);\r
-                               sb.append(", uses="+ uses);\r
-                               sb.append(", userOrdered="+ userOrdered);\r
-                               sb.append("]");\r
-                               return sb.toString();\r
-                       }\r
-               }\r
-\r
-       }
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/ModuleBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/ModuleBuilder.java
deleted file mode 100644 (file)
index 98cfbb6..0000000
+++ /dev/null
@@ -1,824 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.net.URI;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-import java.util.Stack;\r
-\r
-import org.opendaylight.controller.model.parser.api.AugmentationSchemaBuilder;\r
-import org.opendaylight.controller.model.parser.api.Builder;\r
-import org.opendaylight.controller.model.parser.api.ChildNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.DataSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeAwareBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionAwareBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.Deviation;\r
-import org.opendaylight.controller.yang.model.api.FeatureDefinition;\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.controller.yang.model.api.Module;\r
-import org.opendaylight.controller.yang.model.api.ModuleImport;\r
-import org.opendaylight.controller.yang.model.api.NotificationDefinition;\r
-import org.opendaylight.controller.yang.model.api.RpcDefinition;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-\r
-/**\r
- * This builder builds Module object. If this module is dependent on external\r
- * module/modules, these dependencies must be resolved before module is built,\r
- * otherwise result may not be valid.\r
- */\r
-public class ModuleBuilder implements Builder {\r
-\r
-       private final ModuleImpl instance;\r
-       private final String name;\r
-       private String prefix;\r
-\r
-       private final Set<ModuleImport> imports = new HashSet<ModuleImport>();\r
-       private Set<AugmentationSchema> augmentations;\r
-\r
-       /**\r
-        * All nodes, that can contain other nodes\r
-        */\r
-       private final Map<List<String>, Builder> moduleNodes = new HashMap<List<String>, Builder>();\r
-\r
-       /**\r
-        * Holds all child (DataSchemaNode) nodes: anyxml, choice, container, list, leaf, leaf-list.\r
-        */\r
-       private final Map<List<String>, DataSchemaNodeBuilder> addedChilds = new HashMap<List<String>, DataSchemaNodeBuilder>();\r
-\r
-       private final Map<List<String>, GroupingBuilder> addedGroupings = new HashMap<List<String>, GroupingBuilder>();\r
-       private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();\r
-       private final Map<List<String>, UsesNodeBuilder> addedUsesNodes = new HashMap<List<String>, UsesNodeBuilder>();\r
-       private final Map<List<String>, RpcDefinitionBuilder> addedRpcs = new HashMap<List<String>, RpcDefinitionBuilder>();\r
-       private final Set<NotificationBuilder> addedNotifications = new HashSet<NotificationBuilder>();\r
-       private final Map<List<String>, FeatureBuilder> addedFeatures = new HashMap<List<String>, FeatureBuilder>();\r
-       private final Map<String, DeviationBuilder> addedDeviations = new HashMap<String, DeviationBuilder>();\r
-       private final Map<List<String>, TypeDefinitionBuilder> addedTypedefs = new HashMap<List<String>, TypeDefinitionBuilder>();\r
-\r
-\r
-       private final Map<List<String>, TypeAwareBuilder> dirtyNodes = new HashMap<List<String>, TypeAwareBuilder>();\r
-\r
-\r
-       public ModuleBuilder(String name) {\r
-               this.name = name;\r
-               instance = new ModuleImpl(name);\r
-       }\r
-\r
-       /**\r
-        * Build new Module object based on this builder. Throws IllegalStateException if builder contains unresolved nodes.\r
-        */\r
-       public Module build() {\r
-               instance.setImports(imports);\r
-\r
-               // TYPEDEFS\r
-               Set<TypeDefinition<?>> typedefs = buildModuleTypedefs(addedTypedefs);\r
-               instance.setTypeDefinitions(typedefs);\r
-\r
-               // CHILD NODES\r
-               final Map<QName, DataSchemaNode> childNodes = buildModuleChildNodes(addedChilds);\r
-               instance.setChildNodes(childNodes);\r
-\r
-               // GROUPINGS\r
-               final Set<GroupingDefinition> groupings = buildModuleGroupings(addedGroupings);\r
-               instance.setGroupings(groupings);\r
-\r
-               // USES\r
-               final Set<UsesNode> usesNodeDefinitions = buildUsesNodes(addedUsesNodes);\r
-               instance.setUses(usesNodeDefinitions);\r
-\r
-               // FEATURES\r
-               Set<FeatureDefinition> features = buildModuleFeatures(addedFeatures);\r
-               instance.setFeatures(features);\r
-\r
-               // NOTIFICATIONS\r
-               final Set<NotificationDefinition> notifications = new HashSet<NotificationDefinition>();\r
-               for (NotificationBuilder entry : addedNotifications) {\r
-                       notifications.add((NotificationDefinition) entry.build());\r
-               }\r
-               instance.setNotifications(notifications);\r
-\r
-               // AUGMENTATIONS\r
-//             final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();\r
-//             for(AugmentationSchemaBuilder entry : addedAugments) {\r
-//                     augmentations.add(entry.build());\r
-//             }\r
-//             instance.setAugmentations(augmentations);\r
-               instance.setAugmentations(augmentations);\r
-\r
-               // RPCs\r
-               final Set<RpcDefinition> rpcs = buildModuleRpcs(addedRpcs);\r
-               instance.setRpcs(rpcs);\r
-\r
-               // DEVIATIONS\r
-               Set<Deviation> deviations = new HashSet<Deviation>();\r
-               for(Map.Entry<String, DeviationBuilder> entry : addedDeviations.entrySet()) {\r
-                       deviations.add(entry.getValue().build());\r
-               }\r
-               instance.setDeviations(deviations);\r
-\r
-               return instance;\r
-       }\r
-\r
-       Builder getNode(List<String> path) {\r
-               return moduleNodes.get(path);\r
-       }\r
-\r
-       Map<List<String>, TypeAwareBuilder> getDirtyNodes() {\r
-               return dirtyNodes;\r
-       }\r
-\r
-       String getName() {\r
-               return name;\r
-       }\r
-\r
-       String getPrefix() {\r
-               return prefix;\r
-       }\r
-\r
-       Set<AugmentationSchemaBuilder> getAddedAugments() {\r
-               return addedAugments;\r
-       }\r
-\r
-\r
-       public void addDirtyNode(Stack<String> path) {\r
-               List<String> dirtyNodePath = new ArrayList<String>(path);\r
-               TypeAwareBuilder nodeBuilder = (TypeAwareBuilder)moduleNodes.get(dirtyNodePath);\r
-               dirtyNodes.put(dirtyNodePath, nodeBuilder);\r
-       }\r
-\r
-       public void setNamespace(URI namespace) {\r
-               instance.setNamespace(namespace);\r
-       }\r
-\r
-       public void setRevision(Date revision) {\r
-               instance.setRevision(revision);\r
-       }\r
-\r
-       public void setPrefix(String prefix) {\r
-               this.prefix = prefix;\r
-               instance.setPrefix(prefix);\r
-       }\r
-\r
-       public void setYangVersion(String yangVersion) {\r
-               instance.setYangVersion(yangVersion);\r
-       }\r
-\r
-       public void setDescription(String description) {\r
-               instance.setDescription(description);\r
-       }\r
-       public void setReference(String reference) {\r
-               instance.setReference(reference);\r
-       }\r
-       public void setOrganization(String organization) {\r
-               instance.setOrganization(organization);\r
-       }\r
-       public void setContact(String contact) {\r
-               instance.setContact(contact);\r
-       }\r
-       public void setAugmentations(Set<AugmentationSchema> augmentations) {\r
-               this.augmentations = augmentations;\r
-       }\r
-\r
-       public boolean addModuleImport(final String moduleName, final Date revision, final String prefix) {\r
-               ModuleImport moduleImport = createModuleImport(moduleName, revision, prefix);\r
-               return imports.add(moduleImport);\r
-       }\r
-\r
-       public Set<ModuleImport> getModuleImports() {\r
-               return imports;\r
-       }\r
-\r
-       public ContainerSchemaNodeBuilder addContainerNode(QName containerName, Stack<String> parentPath) {\r
-               List<String> pathToNode = new ArrayList<String>(parentPath);\r
-\r
-               ContainerSchemaNodeBuilder containerBuilder = new ContainerSchemaNodeBuilder(containerName);\r
-\r
-               ChildNodeBuilder parent = (ChildNodeBuilder)moduleNodes.get(pathToNode);\r
-               if(parent != null) {\r
-                       parent.addChildNode(containerBuilder);\r
-               }\r
-\r
-               pathToNode.add(containerName.getLocalName());\r
-               moduleNodes.put(pathToNode, containerBuilder);\r
-               addedChilds.put(pathToNode, containerBuilder);\r
-\r
-               return containerBuilder;\r
-       }\r
-\r
-       public ListSchemaNodeBuilder addListNode(QName listName, Stack<String> parentPath) {\r
-               List<String> pathToNode = new ArrayList<String>(parentPath);\r
-\r
-               ListSchemaNodeBuilder listBuilder = new ListSchemaNodeBuilder(listName);\r
-\r
-               ChildNodeBuilder parent = (ChildNodeBuilder)moduleNodes.get(pathToNode);\r
-               if(parent != null) {\r
-                       parent.addChildNode(listBuilder);\r
-               }\r
-\r
-               pathToNode.add(listName.getLocalName());\r
-               moduleNodes.put(pathToNode, listBuilder);\r
-               addedChilds.put(pathToNode, listBuilder);\r
-\r
-               return listBuilder;\r
-       }\r
-\r
-       public LeafSchemaNodeBuilder addLeafNode(QName leafName, Stack<String> parentPath) {\r
-               List<String> pathToNode = new ArrayList<String>(parentPath);\r
-\r
-               LeafSchemaNodeBuilder leafBuilder = new LeafSchemaNodeBuilder(leafName);\r
-\r
-               ChildNodeBuilder parent = (ChildNodeBuilder)moduleNodes.get(pathToNode);\r
-               if(parent != null) {\r
-                       parent.addChildNode(leafBuilder);\r
-               }\r
-\r
-               pathToNode.add(leafName.getLocalName());\r
-               addedChilds.put(pathToNode, leafBuilder);\r
-               moduleNodes.put(pathToNode, leafBuilder);\r
-\r
-               return leafBuilder;\r
-       }\r
-\r
-       public LeafListSchemaNodeBuilder addLeafListNode(QName leafListName, Stack<String> parentPath) {\r
-               List<String> pathToNode = new ArrayList<String>(parentPath);\r
-\r
-               LeafListSchemaNodeBuilder leafListBuilder = new LeafListSchemaNodeBuilder(leafListName);\r
-               ChildNodeBuilder parent = (ChildNodeBuilder)moduleNodes.get(pathToNode);\r
-               if(parent != null) {\r
-                       parent.addChildNode(leafListBuilder);\r
-               }\r
-\r
-               pathToNode.add(leafListName.getLocalName());\r
-               addedChilds.put(pathToNode, leafListBuilder);\r
-               moduleNodes.put(pathToNode, leafListBuilder);\r
-\r
-               return leafListBuilder;\r
-       }\r
-\r
-       public GroupingBuilder addGrouping(QName qname, Stack<String> parentPath) {\r
-               List<String> pathToGroup = new ArrayList<String>(parentPath);\r
-\r
-               GroupingBuilder builder = new GroupingBuilderImpl(qname);\r
-               ChildNodeBuilder parentNodeBuilder = (ChildNodeBuilder)moduleNodes.get(pathToGroup);\r
-               if(parentNodeBuilder != null) {\r
-                       parentNodeBuilder.addGrouping(builder);\r
-               }\r
-\r
-               pathToGroup.add(qname.getLocalName());\r
-               moduleNodes.put(pathToGroup, builder);\r
-               addedGroupings.put(pathToGroup, builder);\r
-\r
-               return builder;\r
-       }\r
-\r
-       public AugmentationSchemaBuilder addAugment(String name, Stack<String> parentPath) {\r
-               List<String> pathToAugment = new ArrayList<String>(parentPath);\r
-\r
-               AugmentationSchemaBuilder builder = new AugmentationSchemaBuilderImpl(name);\r
-\r
-               // augment can only be in 'module' or 'uses' statement\r
-               UsesNodeBuilder parent = addedUsesNodes.get(pathToAugment);\r
-               if(parent != null) {\r
-                       parent.addAugment(builder);\r
-               }\r
-\r
-               pathToAugment.add(name);\r
-               moduleNodes.put(pathToAugment, builder);\r
-               addedAugments.add(builder);\r
-\r
-               return builder;\r
-       }\r
-\r
-       public UsesNodeBuilder addUsesNode(String groupingPathStr, Stack<String> parentPath) {\r
-               List<String> pathToUses = new ArrayList<String>(parentPath);\r
-\r
-               UsesNodeBuilder builder = new UsesNodeBuilderImpl(groupingPathStr);\r
-\r
-               ChildNodeBuilder parent = (ChildNodeBuilder)moduleNodes.get(pathToUses);\r
-               if(parent != null) {\r
-                       parent.addUsesNode(builder);\r
-               }\r
-\r
-               pathToUses.add(groupingPathStr);\r
-               addedUsesNodes.put(pathToUses, builder);\r
-\r
-               return builder;\r
-       }\r
-\r
-       public RpcDefinitionBuilder addRpc(QName qname, Stack<String> parentPath) {\r
-               List<String> pathToRpc = new ArrayList<String>(parentPath);\r
-\r
-               RpcDefinitionBuilder rpcBuilder = new RpcDefinitionBuilder(qname);\r
-\r
-               pathToRpc.add(qname.getLocalName());\r
-               addedRpcs.put(pathToRpc, rpcBuilder);\r
-\r
-               QName inputQName = new QName(qname.getNamespace(), qname.getRevision(), qname.getPrefix(), "input");\r
-               ContainerSchemaNodeBuilder inputBuilder = new ContainerSchemaNodeBuilder(inputQName);\r
-               List<String> pathToInput = new ArrayList<String>(pathToRpc);\r
-               pathToInput.add("input");\r
-               moduleNodes.put(pathToInput, inputBuilder);\r
-               rpcBuilder.setInput(inputBuilder);\r
-\r
-               QName outputQName = new QName(qname.getNamespace(), qname.getRevision(), qname.getPrefix(), "output");\r
-               ContainerSchemaNodeBuilder outputBuilder = new ContainerSchemaNodeBuilder(outputQName);\r
-               List<String> pathToOutput = new ArrayList<String>(pathToRpc);\r
-               pathToOutput.add("output");\r
-               moduleNodes.put(pathToOutput, outputBuilder);\r
-               rpcBuilder.setOutput(outputBuilder);\r
-\r
-               return rpcBuilder;\r
-       }\r
-\r
-       public NotificationBuilder addNotification(QName notificationName, Stack<String> parentPath) {\r
-               List<String> pathToNotification = new ArrayList<String>(parentPath);\r
-\r
-               NotificationBuilder notificationBuilder = new NotificationBuilder(notificationName);\r
-\r
-               pathToNotification.add(notificationName.getLocalName());\r
-               moduleNodes.put(pathToNotification, notificationBuilder);\r
-               addedNotifications.add(notificationBuilder);\r
-\r
-               return notificationBuilder;\r
-       }\r
-\r
-       public FeatureBuilder addFeature(QName featureName, Stack<String> parentPath) {\r
-               List<String> pathToFeature = new ArrayList<String>(parentPath);\r
-               pathToFeature.add(featureName.getLocalName());\r
-\r
-               FeatureBuilder builder = new FeatureBuilder(featureName);\r
-               addedFeatures.put(pathToFeature, builder);\r
-               return builder;\r
-       }\r
-\r
-       public TypedefBuilder addTypedef(QName typeDefName, Stack<String> parentPath) {\r
-               List<String> pathToType = new ArrayList<String>(parentPath);\r
-               TypedefBuilder builder = new TypedefBuilder(typeDefName);\r
-               TypeDefinitionAwareBuilder parent = (TypeDefinitionAwareBuilder)moduleNodes.get(pathToType);\r
-               if(parent != null) {\r
-                       parent.addTypedef(builder);\r
-               }\r
-               pathToType.add(typeDefName.getLocalName());\r
-               addedTypedefs.put(pathToType, builder);\r
-               moduleNodes.put(pathToType, builder);\r
-               return builder;\r
-       }\r
-\r
-       public Set<TypeDefinitionBuilder> getModuleTypedefs() {\r
-               Set<TypeDefinitionBuilder> typedefs = new HashSet<TypeDefinitionBuilder>();\r
-               for(Map.Entry<List<String>, TypeDefinitionBuilder> entry : addedTypedefs.entrySet()) {\r
-                       if(entry.getKey().size() == 2) {\r
-                               typedefs.add(entry.getValue());\r
-                       }\r
-               }\r
-               return typedefs;\r
-       }\r
-\r
-       public void setType(TypeDefinition<?> type, Stack<String> parentPath) {\r
-               TypeAwareBuilder parent = (TypeAwareBuilder)moduleNodes.get(parentPath);\r
-               parent.setType(type);\r
-       }\r
-\r
-       public DeviationBuilder addDeviation(String targetPath) {\r
-               DeviationBuilder builder = new DeviationBuilder(targetPath);\r
-               addedDeviations.put(targetPath, builder);\r
-               return builder;\r
-       }\r
-\r
-       public MustDefinitionBuilder addMustDefinition(String xpathStr, Stack<String> parentPath) {\r
-               MustAwareBuilder parent = (MustAwareBuilder)moduleNodes.get(parentPath);\r
-               String path = parentPath.get(parentPath.size()-1);\r
-               if(parent == null) {\r
-                       for(Map.Entry<String, DeviationBuilder> db : addedDeviations.entrySet()) {\r
-                               String key = db.getKey();\r
-                               if(key.equals(path)) {\r
-                                       parent = db.getValue();\r
-                               }\r
-                       }\r
-               }\r
-               MustDefinitionBuilder builder = new MustDefinitionBuilder(xpathStr);\r
-               parent.setMustDefinitionBuilder(builder);\r
-               return builder;\r
-       }\r
-\r
-       public ModuleBuilder addSubmodule(QName qname) {\r
-               ModuleBuilder submoduleBuilder = new ModuleBuilder(qname.getLocalName());\r
-               return submoduleBuilder;\r
-       }\r
-\r
-\r
-\r
-       private class ModuleImpl implements Module {\r
-\r
-       private URI namespace;\r
-       private final String name;\r
-       private Date revision;\r
-       private String prefix;\r
-       private String yangVersion;\r
-       private String description;\r
-       private String reference;\r
-       private String organization;\r
-       private String contact;\r
-       private Set<ModuleImport> imports;\r
-       private Set<FeatureDefinition> features;\r
-       private Set<TypeDefinition<?>> typeDefinitions;\r
-       private Set<NotificationDefinition> notifications;\r
-       private Set<AugmentationSchema> augmentations;\r
-       private Set<RpcDefinition> rpcs;\r
-       private Set<Deviation> deviations;\r
-       private Map<QName, DataSchemaNode> childNodes;\r
-       private Set<GroupingDefinition> groupings;\r
-       private Set<UsesNode> uses;\r
-\r
-       private ModuleImpl(String name) {\r
-               this.name = name;\r
-       }\r
-\r
-\r
-       @Override\r
-       public URI getNamespace() {\r
-               return namespace;\r
-       }\r
-       private void setNamespace(URI namespace) {\r
-               this.namespace = namespace;\r
-       }\r
-\r
-       @Override\r
-       public String getName() {\r
-               return name;\r
-       }\r
-\r
-       @Override\r
-       public Date getRevision() {\r
-               return revision;\r
-       }\r
-       private void setRevision(Date revision) {\r
-               this.revision = revision;\r
-       }\r
-\r
-       @Override\r
-       public String getPrefix() {\r
-               return prefix;\r
-       }\r
-       private void setPrefix(String prefix) {\r
-               this.prefix = prefix;\r
-       }\r
-\r
-       @Override\r
-       public String getYangVersion() {\r
-               return yangVersion;\r
-       }\r
-       private void setYangVersion(String yangVersion) {\r
-               this.yangVersion = yangVersion;\r
-       }\r
-\r
-       @Override\r
-       public String getDescription() {\r
-               return description;\r
-       }\r
-       private void setDescription(String description) {\r
-               this.description = description;\r
-       }\r
-\r
-       @Override\r
-       public String getReference() {\r
-               return reference;\r
-       }\r
-       private void setReference(String reference) {\r
-               this.reference = reference;\r
-       }\r
-\r
-       @Override\r
-       public String getOrganization() {\r
-               return organization;\r
-       }\r
-       private void setOrganization(String organization) {\r
-               this.organization = organization;\r
-       }\r
-\r
-       @Override\r
-       public String getContact() {\r
-               return contact;\r
-       }\r
-       private void setContact(String contact) {\r
-               this.contact = contact;\r
-       }\r
-\r
-       @Override\r
-       public Set<ModuleImport> getImports() {\r
-               return imports;\r
-       }\r
-       private void setImports(Set<ModuleImport> imports) {\r
-               this.imports = imports;\r
-       }\r
-\r
-       @Override\r
-       public Set<FeatureDefinition> getFeatures() {\r
-               return features;\r
-       }\r
-       private void setFeatures(Set<FeatureDefinition> features) {\r
-               this.features = features;\r
-       }\r
-\r
-       @Override\r
-       public Set<TypeDefinition<?>> getTypeDefinitions() {\r
-               return typeDefinitions;\r
-       }\r
-       private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {\r
-               this.typeDefinitions = typeDefinitions;\r
-       }\r
-\r
-       @Override\r
-       public Set<NotificationDefinition> getNotifications() {\r
-               return notifications;\r
-       }\r
-       private void setNotifications(Set<NotificationDefinition> notifications) {\r
-               this.notifications = notifications;\r
-       }\r
-\r
-       @Override\r
-               public Set<AugmentationSchema> getAugmentations() {\r
-                       return augmentations;\r
-               }\r
-       private void setAugmentations(Set<AugmentationSchema> augmentations) {\r
-                       this.augmentations = augmentations;\r
-               }\r
-\r
-       @Override\r
-       public Set<RpcDefinition> getRpcs() {\r
-               return rpcs;\r
-       }\r
-       private void setRpcs(Set<RpcDefinition> rpcs) {\r
-               this.rpcs = rpcs;\r
-       }\r
-\r
-       @Override\r
-       public Set<Deviation> getDeviations() {\r
-               return deviations;\r
-       }\r
-       private void setDeviations(Set<Deviation> deviations) {\r
-               this.deviations = deviations;\r
-       }\r
-\r
-       @Override\r
-       public Set<DataSchemaNode> getChildNodes() {\r
-               return new HashSet<DataSchemaNode>(childNodes.values());\r
-       }\r
-       private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {\r
-               this.childNodes = childNodes;\r
-       }\r
-\r
-       @Override\r
-       public Set<GroupingDefinition> getGroupings() {\r
-               return groupings;\r
-       }\r
-       private void setGroupings(Set<GroupingDefinition> groupings) {\r
-               this.groupings = groupings;\r
-       }\r
-\r
-       @Override\r
-       public Set<UsesNode> getUses() {\r
-                       return uses;\r
-               }\r
-               private void setUses(Set<UsesNode> uses) {\r
-                       this.uses = uses;\r
-               }\r
-\r
-       @Override\r
-               public DataSchemaNode getDataChildByName(QName name) {\r
-                       return childNodes.get(name);\r
-               }\r
-               @Override\r
-               public DataSchemaNode getDataChildByName(String name) {\r
-                       DataSchemaNode result = null;\r
-                       for(Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {\r
-                               if(entry.getKey().getLocalName().equals(name)) {\r
-                                       result = entry.getValue();\r
-                                       break;\r
-                               }\r
-                       }\r
-                       return result;\r
-               }\r
-\r
-               @Override\r
-               public String toString() {\r
-                       StringBuilder sb = new StringBuilder(ModuleImpl.class.getSimpleName());\r
-                       sb.append("[\n");\r
-                       sb.append("name="+ name +",\n");\r
-                       sb.append("namespace="+ namespace +",\n");\r
-                       sb.append("revision="+ revision +",\n");\r
-                       sb.append("prefix="+ prefix +",\n");\r
-                       sb.append("yangVersion="+ yangVersion +",\n");\r
-                       sb.append("description="+ description +",\n");\r
-                       sb.append("reference="+ reference +",\n");\r
-                       sb.append("organization="+ organization +",\n");\r
-                       sb.append("contact="+ contact +",\n");\r
-                       sb.append("childNodes="+ childNodes.values() +",\n");\r
-                       sb.append("groupings="+ groupings +",\n");\r
-                       sb.append("imports="+ imports +",\n");\r
-                       sb.append("features="+ features +",\n");\r
-                       sb.append("typeDefinitions="+ typeDefinitions +",\n");\r
-                       sb.append("notifications="+ notifications +",\n");\r
-                       sb.append("augmentations="+ augmentations +",\n");\r
-                       sb.append("rpcs="+ rpcs +",\n");\r
-                       sb.append("deviations="+ deviations +"\n");\r
-                       sb.append("]");\r
-                       return sb.toString();\r
-               }\r
-\r
-    }\r
-\r
-       private ModuleImport createModuleImport(final String moduleName, final Date revision, final String prefix) {\r
-               ModuleImport moduleImport = new ModuleImport() {\r
-                       @Override\r
-                       public String getModuleName() {\r
-                               return moduleName;\r
-                       }\r
-                       @Override\r
-                       public Date getRevision() {\r
-                               return revision;\r
-                       }\r
-                       @Override\r
-                       public String getPrefix() {\r
-                               return prefix;\r
-                       }\r
-\r
-                       @Override\r
-                       public int hashCode() {\r
-                               final int prime = 31;\r
-                   int result = 1;\r
-                   result = prime * result + ((moduleName == null) ? 0 : moduleName.hashCode());\r
-                   result = prime * result + ((revision == null) ? 0 : revision.hashCode());\r
-                   result = prime * result + ((prefix == null) ? 0 : prefix.hashCode());\r
-                   return result;\r
-                       }\r
-\r
-                       @Override\r
-               public boolean equals(Object obj) {\r
-                   if (this == obj) {\r
-                       return true;\r
-                   }\r
-                   if (obj == null) {\r
-                       return false;\r
-                   }\r
-                   if (getClass() != obj.getClass()) {\r
-                       return false;\r
-                   }\r
-                   ModuleImport other = (ModuleImport) obj;\r
-                   if (getModuleName() == null) {\r
-                       if (other.getModuleName() != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!getModuleName().equals(other.getModuleName())) {\r
-                       return false;\r
-                   }\r
-                   if (getRevision() == null) {\r
-                       if (other.getRevision() != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!getRevision().equals(other.getRevision())) {\r
-                       return false;\r
-                   }\r
-                   if (getPrefix() == null) {\r
-                       if (other.getPrefix() != null) {\r
-                           return false;\r
-                       }\r
-                   } else if (!getPrefix().equals(other.getPrefix())) {\r
-                       return false;\r
-                   }\r
-                   return true;\r
-               }\r
-\r
-                       @Override\r
-                       public String toString() {\r
-                               return "ModuleImport[moduleName="+ moduleName +", revision="+ revision +", prefix="+ prefix +"]";\r
-                       }\r
-               };\r
-               return moduleImport;\r
-       }\r
-\r
-       /**\r
-        * Traverse through given addedChilds and add only direct module childs. Direct\r
-        * module child path size is 2 (1. module name, 2. child name).\r
-        *\r
-        * @param addedChilds\r
-        * @return map of children, where key is child QName and value is child itself\r
-        */\r
-       private Map<QName, DataSchemaNode> buildModuleChildNodes(\r
-                       Map<List<String>, DataSchemaNodeBuilder> addedChilds) {\r
-               final Map<QName, DataSchemaNode> childNodes = new HashMap<QName, DataSchemaNode>();\r
-               for (Map.Entry<List<String>, DataSchemaNodeBuilder> entry : addedChilds\r
-                               .entrySet()) {\r
-                       if (entry.getKey().size() == 2) {\r
-                               DataSchemaNode node = entry.getValue().build();\r
-                               QName qname = entry.getValue().getQName();\r
-                               childNodes.put(qname, node);\r
-                       }\r
-               }\r
-               return childNodes;\r
-       }\r
-\r
-       /**\r
-        * Traverse through given addedGroupings and add only direct module groupings. Direct\r
-        * module grouping path size is 2 (1. module name, 2. grouping name).\r
-        *\r
-        * @param addedGroupings\r
-        * @return set of built GroupingDefinition objects\r
-        */\r
-       private Set<GroupingDefinition> buildModuleGroupings(Map<List<String>, GroupingBuilder> addedGroupings) {\r
-               final Set<GroupingDefinition> groupings = new HashSet<GroupingDefinition>();\r
-               for(Map.Entry<List<String>, GroupingBuilder> entry : addedGroupings.entrySet()) {\r
-                       if(entry.getKey().size() == 2) {\r
-                               groupings.add(entry.getValue().build());\r
-                       }\r
-               }\r
-               return groupings;\r
-       }\r
-\r
-       /**\r
-        * Traverse through given addedRpcs and build RpcDefinition objects.\r
-        * @param addedRpcs\r
-        * @return set of built RpcDefinition objects\r
-        */\r
-       private Set<RpcDefinition> buildModuleRpcs(Map<List<String>, RpcDefinitionBuilder> addedRpcs) {\r
-               final Set<RpcDefinition> rpcs = new HashSet<RpcDefinition>();\r
-               RpcDefinitionBuilder builder;\r
-               for(Map.Entry<List<String>, RpcDefinitionBuilder> entry : addedRpcs.entrySet()) {\r
-                       builder = entry.getValue();\r
-                       RpcDefinition rpc = builder.build();\r
-                       rpcs.add(rpc);\r
-               }\r
-               return rpcs;\r
-       }\r
-\r
-       /**\r
-        * Traverse through given addedTypedefs and add only direct module typedef statements. Direct\r
-        * module typedef path size is 2 (1. module name, 2. typedef name).\r
-        *\r
-        * @param addedTypedefs\r
-        * @return set of built module typedef statements\r
-        */\r
-       private Set<TypeDefinition<?>> buildModuleTypedefs(Map<List<String>, TypeDefinitionBuilder> addedTypedefs) {\r
-               Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();\r
-               for(Map.Entry<List<String>, TypeDefinitionBuilder> entry : addedTypedefs.entrySet()) {\r
-                       if(entry.getKey().size() == 2) {\r
-                               TypeDefinition<? extends TypeDefinition<?>> node = entry.getValue().build();\r
-                               typedefs.add(node);\r
-                       }\r
-               }\r
-               return typedefs;\r
-       }\r
-\r
-       /**\r
-        * Traverse through given addedUsesNodes and add only direct module uses nodes. Direct\r
-        * module uses node path size is 2 (1. module name, 2. uses name).\r
-        *\r
-        * @param addedUsesNodes\r
-        * @return set of built module uses nodes\r
-        */\r
-       private Set<UsesNode> buildUsesNodes(Map<List<String>, UsesNodeBuilder> addedUsesNodes) {\r
-               final Set<UsesNode> usesNodeDefinitions = new HashSet<UsesNode>();\r
-               for (Map.Entry<List<String>, UsesNodeBuilder> entry : addedUsesNodes.entrySet()) {\r
-                       if (entry.getKey().size() == 2) {\r
-                               usesNodeDefinitions.add(entry.getValue().build());\r
-                       }\r
-               }\r
-               return usesNodeDefinitions;\r
-       }\r
-\r
-       /**\r
-        * Traverse through given addedFeatures and add only direct module features. Direct\r
-        * module feature path size is 2 (1. module name, 2. feature name).\r
-        *\r
-        * @param addedFeatures\r
-        * @return set of built module features\r
-        */\r
-       private Set<FeatureDefinition> buildModuleFeatures(Map<List<String>, FeatureBuilder> addedFeatures) {\r
-               Set<FeatureDefinition> features = new HashSet<FeatureDefinition>();\r
-               for(Map.Entry<List<String>, FeatureBuilder> entry : addedFeatures.entrySet()) {\r
-                       if(entry.getKey().size() == 2) {\r
-                               features.add((FeatureDefinition)entry.getValue().build());\r
-                       }\r
-               }\r
-               return features;\r
-       }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/MustDefinitionBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/MustDefinitionBuilder.java
deleted file mode 100644 (file)
index fecfae8..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import org.opendaylight.controller.model.parser.api.Builder;\r
-import org.opendaylight.controller.yang.model.api.MustDefinition;\r
-import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
-\r
-\r
-public class MustDefinitionBuilder implements Builder {\r
-\r
-       private final MustDefinitionImpl instance;\r
-\r
-       MustDefinitionBuilder(String xpathStr) {\r
-               instance = new MustDefinitionImpl(xpathStr);\r
-       }\r
-\r
-       @Override\r
-       public MustDefinition build() {\r
-               return instance;\r
-       }\r
-\r
-       public void setDescription(String description) {\r
-               instance.setDescription(description);\r
-       }\r
-\r
-       public void setReference(String reference) {\r
-               instance.setReference(reference);\r
-       }\r
-\r
-       private static class MustDefinitionImpl implements MustDefinition {\r
-\r
-               private final String xpathStr;\r
-               private String description;\r
-               private String reference;\r
-\r
-               private MustDefinitionImpl(String xpathStr) {\r
-                       this.xpathStr = xpathStr;\r
-               }\r
-\r
-               @Override\r
-               public String getDescription() {\r
-                       return description;\r
-               }\r
-               private void setDescription(String description) {\r
-                       this.description = description;\r
-               }\r
-\r
-               @Override\r
-               public String getErrorAppTag() {\r
-                       // TODO Auto-generated method stub\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public String getErrorMessage() {\r
-                       // TODO Auto-generated method stub\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public String getReference() {\r
-                       return reference;\r
-               }\r
-               private void setReference(String reference) {\r
-                       this.reference = reference;\r
-               }\r
-\r
-               @Override\r
-               public RevisionAwareXPath getXpath() {\r
-                       // TODO Auto-generated method stub\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public String toString() {\r
-                       return MustDefinitionImpl.class.getSimpleName() +"[xpathStr="+ xpathStr +"]";\r
-               }\r
-       }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/NotificationBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/NotificationBuilder.java
deleted file mode 100644 (file)
index 52decc0..0000000
+++ /dev/null
@@ -1,229 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.model.parser.api.AbstractChildNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.DataSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.api.SchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionAwareBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.controller.yang.model.api.NotificationDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaNode;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-\r
-public class NotificationBuilder extends AbstractChildNodeBuilder implements TypeDefinitionAwareBuilder, SchemaNodeBuilder {\r
-\r
-       private final NotificationDefinitionImpl instance;\r
-       private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();\r
-       private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();\r
-\r
-       NotificationBuilder(QName qname) {\r
-               super(qname);\r
-               instance = new NotificationDefinitionImpl(qname);\r
-       }\r
-\r
-       @Override\r
-       public SchemaNode build() {\r
-               // CHILD NODES\r
-               Map<QName, DataSchemaNode> childs = new HashMap<QName, DataSchemaNode>();\r
-               for (DataSchemaNodeBuilder node : childNodes) {\r
-                       childs.put(node.getQName(), node.build());\r
-               }\r
-               instance.setChildNodes(childs);\r
-\r
-               // GROUPINGS\r
-               Set<GroupingDefinition> groupingDefinitions = new HashSet<GroupingDefinition>();\r
-               for (GroupingBuilder builder : groupings) {\r
-                       groupingDefinitions.add(builder.build());\r
-               }\r
-               instance.setGroupings(groupingDefinitions);\r
-\r
-               // TYPEDEFS\r
-               Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();\r
-               for (TypeDefinitionBuilder entry : addedTypedefs) {\r
-                       typedefs.add(entry.build());\r
-               }\r
-               instance.setTypeDefinitions(typedefs);\r
-\r
-               // USES\r
-               Set<UsesNode> uses = new HashSet<UsesNode>();\r
-               for (UsesNodeBuilder builder : addedUsesNodes) {\r
-                       uses.add(builder.build());\r
-               }\r
-               instance.setUses(uses);\r
-\r
-               return instance;\r
-       }\r
-\r
-       @Override\r
-       public void addTypedef(TypeDefinitionBuilder type) {\r
-               addedTypedefs.add(type);\r
-       }\r
-\r
-       @Override\r
-       public void addUsesNode(UsesNodeBuilder usesNodeBuilder) {\r
-               addedUsesNodes.add(usesNodeBuilder);\r
-       }\r
-\r
-       @Override\r
-       public void setPath(SchemaPath schemaPath) {\r
-               instance.setPath(schemaPath);\r
-       }\r
-\r
-       @Override\r
-       public void setDescription(String description) {\r
-               instance.setDescription(description);\r
-       }\r
-\r
-       @Override\r
-       public void setReference(String reference) {\r
-               instance.setReference(reference);\r
-       }\r
-\r
-       @Override\r
-       public void setStatus(Status status) {\r
-               instance.setStatus(status);\r
-       }\r
-\r
-\r
-       private class NotificationDefinitionImpl implements NotificationDefinition {\r
-\r
-               private final QName qname;\r
-               private SchemaPath path;\r
-               private String description;\r
-               private String reference;\r
-               private Status status;\r
-\r
-               private Map<QName, DataSchemaNode> childNodes;\r
-               private Set<GroupingDefinition> groupings;\r
-               private Set<TypeDefinition<?>> typeDefinitions;\r
-\r
-               private Set<UsesNode> uses;\r
-\r
-               private NotificationDefinitionImpl(QName qname) {\r
-                       this.qname = qname;\r
-               }\r
-\r
-               @Override\r
-               public QName getQName() {\r
-                       return qname;\r
-               }\r
-\r
-               @Override\r
-               public SchemaPath getPath() {\r
-                       return path;\r
-               }\r
-               private void setPath(SchemaPath path) {\r
-                       this.path = path;\r
-               }\r
-\r
-               @Override\r
-               public String getDescription() {\r
-                       return description;\r
-               }\r
-               private void setDescription(String description) {\r
-                       this.description = description;\r
-               }\r
-\r
-               @Override\r
-               public String getReference() {\r
-                       return reference;\r
-               }\r
-               private void setReference(String reference) {\r
-                       this.reference = reference;\r
-               }\r
-\r
-               @Override\r
-               public Status getStatus() {\r
-                       return status;\r
-               }\r
-               private void setStatus(Status status) {\r
-                       this.status = status;\r
-               }\r
-\r
-               @Override\r
-               public Set<DataSchemaNode> getChildNodes() {\r
-                       return new HashSet<DataSchemaNode>(childNodes.values());\r
-               }\r
-               private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {\r
-                       this.childNodes = childNodes;\r
-               }\r
-\r
-               @Override\r
-               public Set<GroupingDefinition> getGroupings() {\r
-                       return groupings;\r
-               }\r
-               private void setGroupings(Set<GroupingDefinition> groupings) {\r
-                       this.groupings = groupings;\r
-               }\r
-\r
-               @Override\r
-               public Set<UsesNode> getUses() {\r
-                       return uses;\r
-               }\r
-               private void setUses(Set<UsesNode> uses) {\r
-                       this.uses = uses;\r
-               }\r
-\r
-               @Override\r
-               public Set<TypeDefinition<?>> getTypeDefinitions() {\r
-                       return typeDefinitions;\r
-               }\r
-               private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {\r
-                       this.typeDefinitions = typeDefinitions;\r
-               }\r
-\r
-               @Override\r
-               public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-                       // TODO Auto-generated method stub\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public DataSchemaNode getDataChildByName(QName name) {\r
-                       return childNodes.get(name);\r
-               }\r
-\r
-               @Override\r
-               public DataSchemaNode getDataChildByName(String name) {\r
-                       DataSchemaNode result = null;\r
-                       for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {\r
-                               if (entry.getKey().getLocalName().equals(name)) {\r
-                                       result = entry.getValue();\r
-                                       break;\r
-                               }\r
-                       }\r
-                       return result;\r
-               }\r
-\r
-               @Override\r
-               public String toString() {\r
-                       StringBuilder sb = new StringBuilder(\r
-                                       NotificationDefinitionImpl.class.getSimpleName());\r
-                       sb.append("[qname=" + qname + "]");\r
-                       return sb.toString();\r
-               }\r
-       }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/TypedefBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/TypedefBuilder.java
deleted file mode 100644 (file)
index a6a3c60..0000000
+++ /dev/null
@@ -1,196 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.model.parser.api.SchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeAwareBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionBuilder;\r
-import org.opendaylight.controller.model.util.UnknownType;\r
-import org.opendaylight.controller.model.util.YangTypesConverter;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-\r
-\r
-public class TypedefBuilder implements TypeDefinitionBuilder, SchemaNodeBuilder, TypeAwareBuilder {\r
-\r
-       private final QName qname;\r
-       private SchemaPath schemaPath;\r
-       private TypeDefinition<?> baseType;\r
-\r
-       private String description;\r
-       private String reference;\r
-       private Status status;\r
-\r
-       TypedefBuilder(QName qname) {\r
-               this.qname = qname;\r
-       }\r
-\r
-       @Override\r
-       public TypeDefinition<? extends TypeDefinition<?>> build() {\r
-               final TypeDefinition<?> type = YangTypesConverter.javaTypeForBaseYangType(qname);\r
-               if(type != null) {\r
-                       return type;\r
-               } else {\r
-                       if(baseType != null) {\r
-                               // typedef\r
-                               TypeDefinitionImpl instance = new TypeDefinitionImpl(qname);\r
-                               instance.setDescription(description);\r
-                               instance.setReference(reference);\r
-                               instance.setStatus(status);\r
-                               instance.setPath(schemaPath);\r
-                               instance.setBaseType(baseType);\r
-                               return instance;\r
-                       } else {\r
-                               // type\r
-                               final UnknownType.Builder unknownBuilder = new UnknownType.Builder(qname, description, reference);\r
-                               unknownBuilder.status(status);\r
-                               return unknownBuilder.build();\r
-                       }\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public QName getQName() {\r
-               return qname;\r
-       }\r
-\r
-       @Override\r
-       public void setPath(final SchemaPath schemaPath) {\r
-               this.schemaPath = schemaPath;\r
-       }\r
-\r
-       @Override\r
-       public void setDescription(final String description) {\r
-               this.description = description;\r
-       }\r
-\r
-       @Override\r
-       public void setReference(final String reference) {\r
-               this.reference = reference;\r
-       }\r
-\r
-       @Override\r
-       public void setStatus(final Status status) {\r
-               if(status != null) {\r
-                       this.status = status;\r
-               }\r
-       }\r
-\r
-       @Override\r
-       public TypeDefinition<?> getType() {\r
-               return baseType;\r
-       }\r
-\r
-       @Override\r
-       public void setType(TypeDefinition<?> baseType) {\r
-               this.baseType = baseType;\r
-       }\r
-\r
-       @Override\r
-       public TypeDefinition<?> getBaseType() {\r
-               return baseType;\r
-       }\r
-\r
-\r
-\r
-       private static class TypeDefinitionImpl<T extends TypeDefinition<T>> implements TypeDefinition<T> {\r
-\r
-               private final QName qname;\r
-               private SchemaPath path;\r
-               private String description;\r
-               private String reference;\r
-               private Status status = Status.CURRENT;\r
-               private T baseType;\r
-\r
-               private TypeDefinitionImpl(QName qname) {\r
-                       this.qname = qname;\r
-               }\r
-\r
-               @Override\r
-               public QName getQName() {\r
-                       return qname;\r
-               }\r
-\r
-               @Override\r
-               public SchemaPath getPath() {\r
-                       return path;\r
-               }\r
-               private void setPath(SchemaPath path) {\r
-                       this.path = path;\r
-               }\r
-\r
-               @Override\r
-               public String getDescription() {\r
-                       return description;\r
-               }\r
-               private void setDescription(String description) {\r
-                       this.description = description;\r
-               }\r
-\r
-               @Override\r
-               public String getReference() {\r
-                       return reference;\r
-               }\r
-               private void setReference(String reference) {\r
-                       this.reference = reference;\r
-               }\r
-\r
-               @Override\r
-               public Status getStatus() {\r
-                       return status;\r
-               }\r
-               private void setStatus(Status status) {\r
-                       this.status = status;\r
-               }\r
-\r
-               @Override\r
-               public T getBaseType() {\r
-                       return baseType;\r
-               }\r
-               private void setBaseType(T type) {\r
-                       this.baseType = type;\r
-               }\r
-\r
-               @Override\r
-               public String getUnits() {\r
-                       // TODO Auto-generated method stub\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public Object getDefaultValue() {\r
-                       // TODO Auto-generated method stub\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-                       // TODO Auto-generated method stub\r
-                       return null;\r
-               }\r
-\r
-               @Override\r
-               public String toString() {\r
-                       final StringBuilder sb = new StringBuilder(TypeDefinitionImpl.class.getSimpleName());\r
-                       sb.append("[");\r
-                       sb.append("qname="+ qname);\r
-                       sb.append(", path="+ path);\r
-                       sb.append(", description="+ description);\r
-                       sb.append(", reference="+ reference);\r
-                       sb.append(", status="+ status);\r
-                       sb.append(", baseType="+ baseType +"]");\r
-                       return sb.toString();\r
-               }\r
-       }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/UsesNodeBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/UsesNodeBuilderImpl.java
deleted file mode 100644 (file)
index df626f1..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.model.parser.api.AugmentationSchemaBuilder;\r
-import org.opendaylight.controller.model.parser.api.Builder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-public class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {\r
-\r
-    private final String groupingPathStr;\r
-\r
-    UsesNodeBuilderImpl(String groupingPathStr) {\r
-        this.groupingPathStr = groupingPathStr;\r
-    }\r
-\r
-    @Override\r
-    public UsesNode build() {\r
-        SchemaPath groupingPath = parseUsesPath(groupingPathStr);\r
-        final UsesNodeImpl instance = new UsesNodeImpl(groupingPath);\r
-        return instance;\r
-    }\r
-\r
-    public void addAugment(AugmentationSchemaBuilder augmentBuilder) {\r
-        // TODO:\r
-    }\r
-\r
-    private SchemaPath parseUsesPath(String augmentPath) {\r
-        String[] splittedPath = augmentPath.split("/");\r
-        List<QName> path = new ArrayList<QName>();\r
-        QName name;\r
-        for (String pathElement : splittedPath) {\r
-            String[] splittedElement = pathElement.split(":");\r
-            if (splittedElement.length == 1) {\r
-                name = new QName(null, null, null, splittedElement[0]);\r
-            } else {\r
-                name = new QName(null, null, splittedElement[0],\r
-                        splittedElement[1]);\r
-            }\r
-            path.add(name);\r
-        }\r
-        // TODO: absolute vs relative?\r
-        return new SchemaPath(path, false);\r
-    }\r
-\r
-    private static class UsesNodeImpl implements UsesNode {\r
-\r
-        private final SchemaPath groupingPath;\r
-\r
-        private UsesNodeImpl(SchemaPath groupingPath) {\r
-            this.groupingPath = groupingPath;\r
-        }\r
-\r
-        @Override\r
-        public SchemaPath getGroupingPath() {\r
-            return groupingPath;\r
-        }\r
-\r
-        @Override\r
-        public String toString() {\r
-            return UsesNodeImpl.class.getSimpleName() + "[groupingPath="\r
-                    + groupingPath + "]";\r
-        }\r
-\r
-    }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/YangModelBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/builder/YangModelBuilder.java
deleted file mode 100644 (file)
index bc0f363..0000000
+++ /dev/null
@@ -1,198 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.IOException;\r
-import java.util.ArrayList;\r
-import java.util.HashMap;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Map;\r
-import java.util.Set;\r
-\r
-import org.antlr.v4.runtime.ANTLRInputStream;\r
-import org.antlr.v4.runtime.CommonTokenStream;\r
-import org.antlr.v4.runtime.tree.ParseTree;\r
-import org.antlr.v4.runtime.tree.ParseTreeWalker;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangLexer;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser;\r
-import org.opendaylight.controller.model.parser.api.AugmentationSchemaBuilder;\r
-import org.opendaylight.controller.model.parser.api.AugmentationTargetBuilder;\r
-import org.opendaylight.controller.model.parser.api.Builder;\r
-import org.opendaylight.controller.model.parser.api.TypeAwareBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.impl.YangModelParserImpl;\r
-import org.opendaylight.controller.model.util.UnknownType;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
-import org.opendaylight.controller.yang.model.api.Module;\r
-import org.opendaylight.controller.yang.model.api.ModuleImport;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-public class YangModelBuilder implements Builder {\r
-\r
-    private static final Logger logger = LoggerFactory\r
-            .getLogger(YangModelBuilder.class);\r
-\r
-    private final Map<String, ModuleBuilder> modules = new HashMap<String, ModuleBuilder>();\r
-\r
-    public YangModelBuilder(String... yangFiles) {\r
-        final YangModelParserImpl yangModelParser = new YangModelParserImpl();\r
-        final ParseTreeWalker walker = new ParseTreeWalker();\r
-\r
-        List<ParseTree> trees = parseYangFiles(yangFiles);\r
-\r
-        ModuleBuilder[] builders = new ModuleBuilder[trees.size()];\r
-\r
-        for (int i = 0; i < trees.size(); i++) {\r
-            walker.walk(yangModelParser, trees.get(i));\r
-            builders[i] = yangModelParser.getModuleBuilder();\r
-        }\r
-\r
-        for (ModuleBuilder builder : builders) {\r
-            final String builderName = builder.getName();\r
-            modules.put(builderName, builder);\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public Map<String, Module> build() {\r
-        Map<String, Module> builtModules = new HashMap<String, Module>();\r
-        for (ModuleBuilder builder : modules.values()) {\r
-            validateBuilder(builder);\r
-            builtModules.put(builder.getName(), builder.build());\r
-        }\r
-        return builtModules;\r
-    }\r
-\r
-    private void validateBuilder(ModuleBuilder builder) {\r
-        resolveTypedefs(builder);\r
-        resolveAugments(builder);\r
-    }\r
-\r
-    private void resolveTypedefs(ModuleBuilder builder) {\r
-        Map<List<String>, TypeAwareBuilder> dirtyNodes = builder\r
-                .getDirtyNodes();\r
-        if (dirtyNodes.size() == 0) {\r
-            return;\r
-        } else {\r
-            for (Map.Entry<List<String>, TypeAwareBuilder> entry : dirtyNodes\r
-                    .entrySet()) {\r
-                TypeAwareBuilder tab = entry.getValue();\r
-                TypeDefinitionBuilder tdb = findTypeAwareBuilder(\r
-                        entry.getValue(), builder);\r
-                tab.setType(tdb.build());\r
-            }\r
-        }\r
-    }\r
-\r
-    private TypeDefinitionBuilder findTypeAwareBuilder(\r
-            TypeAwareBuilder typeBuilder, ModuleBuilder builder) {\r
-        UnknownType type = (UnknownType) typeBuilder.getType();\r
-        QName typeQName = type.getQName();\r
-        String typeName = type.getQName().getLocalName();\r
-        String prefix = typeQName.getPrefix();\r
-\r
-        ModuleBuilder dependentModuleBuilder;\r
-        if (prefix.equals(builder.getPrefix())) {\r
-            dependentModuleBuilder = builder;\r
-        } else {\r
-            String dependentModuleName = getDependentModuleName(builder, prefix);\r
-            dependentModuleBuilder = modules.get(dependentModuleName);\r
-        }\r
-\r
-        Set<TypeDefinitionBuilder> typedefs = dependentModuleBuilder\r
-                .getModuleTypedefs();\r
-\r
-        TypeDefinitionBuilder lookedUpBuilder = null;\r
-        for (TypeDefinitionBuilder tdb : typedefs) {\r
-            QName qname = tdb.getQName();\r
-            if (qname.getLocalName().equals(typeName)) {\r
-                lookedUpBuilder = tdb;\r
-                break;\r
-            }\r
-        }\r
-\r
-        if (lookedUpBuilder.getBaseType() instanceof UnknownType) {\r
-            return findTypeAwareBuilder((TypeAwareBuilder) lookedUpBuilder,\r
-                    dependentModuleBuilder);\r
-        } else {\r
-            return lookedUpBuilder;\r
-        }\r
-    }\r
-\r
-    private void resolveAugments(ModuleBuilder builder) {\r
-        Set<AugmentationSchemaBuilder> augmentBuilders = builder\r
-                .getAddedAugments();\r
-\r
-        Set<AugmentationSchema> augments = new HashSet<AugmentationSchema>();\r
-        for (AugmentationSchemaBuilder augmentBuilder : augmentBuilders) {\r
-            SchemaPath augmentTargetSchemaPath = augmentBuilder.getTargetPath();\r
-            String prefix = null;\r
-            List<String> augmentTargetPath = new ArrayList<String>();\r
-            for (QName pathPart : augmentTargetSchemaPath.getPath()) {\r
-                prefix = pathPart.getPrefix();\r
-                augmentTargetPath.add(pathPart.getLocalName());\r
-            }\r
-            String dependentModuleName = getDependentModuleName(builder, prefix);\r
-            augmentTargetPath.add(0, dependentModuleName);\r
-\r
-            ModuleBuilder dependentModule = modules.get(dependentModuleName);\r
-            AugmentationTargetBuilder augmentTarget = (AugmentationTargetBuilder) dependentModule\r
-                    .getNode(augmentTargetPath);\r
-            AugmentationSchema result = augmentBuilder.build();\r
-            augmentTarget.addAugmentation(result);\r
-            augments.add(result);\r
-        }\r
-        builder.setAugmentations(augments);\r
-    }\r
-\r
-    private List<ParseTree> parseYangFiles(String... yangFiles) {\r
-        List<ParseTree> trees = new ArrayList<ParseTree>();\r
-        File yangFile;\r
-        for (String fileName : yangFiles) {\r
-            try {\r
-                yangFile = new File(fileName);\r
-                FileInputStream inStream = new FileInputStream(yangFile);\r
-                ANTLRInputStream input = new ANTLRInputStream(inStream);\r
-                final YangLexer lexer = new YangLexer(input);\r
-                final CommonTokenStream tokens = new CommonTokenStream(lexer);\r
-                final YangParser parser = new YangParser(tokens);\r
-                trees.add(parser.yang());\r
-            } catch (IOException e) {\r
-                logger.warn("Exception while reading yang file: " + fileName, e);\r
-            }\r
-        }\r
-        return trees;\r
-    }\r
-\r
-    /**\r
-     * Returns name of dependent module based on given prefix.\r
-     * \r
-     * @param builder\r
-     *            current builder which contains import\r
-     * @param prefix\r
-     *            prefix of dependent module used in current builder\r
-     * @return name of dependent module\r
-     */\r
-    private String getDependentModuleName(ModuleBuilder builder, String prefix) {\r
-        ModuleImport moduleImport = null;\r
-        for (ModuleImport mi : builder.getModuleImports()) {\r
-            if (mi.getPrefix().equals(prefix)) {\r
-                moduleImport = mi;\r
-                break;\r
-            }\r
-        }\r
-        return moduleImport.getModuleName();\r
-    }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/util/YangModelBuilderHelper.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/model/parser/util/YangModelBuilderHelper.java
deleted file mode 100644 (file)
index 7d9dcf1..0000000
+++ /dev/null
@@ -1,659 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.util;\r
-\r
-import java.net.URI;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.List;\r
-import java.util.Stack;\r
-\r
-import org.antlr.v4.runtime.tree.ParseTree;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Bit_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Bits_specificationContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Decimal64_specificationContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Description_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Enum_specificationContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Enum_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Fraction_digits_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Length_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Numerical_restrictionsContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Pattern_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Position_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Range_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Reference_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Status_argContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Status_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.StringContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.String_restrictionsContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Type_body_stmtsContext;\r
-import org.opendaylight.controller.model.api.type.BitsTypeDefinition;\r
-import org.opendaylight.controller.model.api.type.EnumTypeDefinition;\r
-import org.opendaylight.controller.model.api.type.LengthConstraint;\r
-import org.opendaylight.controller.model.api.type.PatternConstraint;\r
-import org.opendaylight.controller.model.api.type.RangeConstraint;\r
-import org.opendaylight.controller.model.api.type.BitsTypeDefinition.Bit;\r
-import org.opendaylight.controller.model.parser.api.SchemaNodeBuilder;\r
-import org.opendaylight.controller.model.util.BaseConstraints;\r
-import org.opendaylight.controller.model.util.UnknownType;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-public class YangModelBuilderHelper {\r
-\r
-    private static final Logger logger = LoggerFactory\r
-            .getLogger(YangModelBuilderHelper.class);\r
-\r
-    /**\r
-     * Get 'description', 'reference' and 'status' statements and fill in\r
-     * builder.\r
-     * \r
-     * @param ctx\r
-     *            context to parse\r
-     * @param builder\r
-     *            builder to fill in with parsed statements\r
-     */\r
-    public static void parseSchemaNodeArgs(ParseTree ctx,\r
-            SchemaNodeBuilder builder) {\r
-        for (int i = 0; i < ctx.getChildCount(); i++) {\r
-            ParseTree child = ctx.getChild(i);\r
-            if (child instanceof Description_stmtContext) {\r
-                String desc = stringFromNode(child);\r
-                builder.setDescription(desc);\r
-            } else if (child instanceof Reference_stmtContext) {\r
-                String ref = stringFromNode(child);\r
-                builder.setReference(ref);\r
-            } else if (child instanceof Status_stmtContext) {\r
-                Status status = getStatus((Status_stmtContext) child);\r
-                builder.setStatus(status);\r
-            }\r
-        }\r
-    }\r
-\r
-    public static SchemaPath getActualSchemaPath(Stack<String> actualPath,\r
-            URI namespace, Date revision, String prefix) {\r
-        final List<QName> path = new ArrayList<QName>();\r
-        QName qname;\r
-        for (String pathElement : actualPath) {\r
-            qname = new QName(namespace, revision, prefix, pathElement);\r
-            path.add(qname);\r
-        }\r
-        return new SchemaPath(path, true);\r
-    }\r
-\r
-    public static Status getStatus(Status_stmtContext ctx) {\r
-        for (int i = 0; i < ctx.getChildCount(); i++) {\r
-            ParseTree statusArg = ctx.getChild(i);\r
-            if (statusArg instanceof Status_argContext) {\r
-                String statusArgStr = stringFromNode(statusArg);\r
-                if (statusArgStr.equals("current")) {\r
-                    return Status.CURRENT;\r
-                } else if (statusArgStr.equals("deprecated")) {\r
-                    return Status.DEPRECATED;\r
-                } else if (statusArgStr.equals("obsolete")) {\r
-                    return Status.OBSOLOTE;\r
-                } else {\r
-                    logger.warn("Invalid 'status' statement: " + statusArgStr);\r
-                }\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    public static String stringFromNode(final ParseTree treeNode) {\r
-        final String result = "";\r
-        for (int j = 0; j < treeNode.getChildCount(); ++j) {\r
-            if (treeNode.getChild(j) instanceof StringContext) {\r
-                final StringContext context = (StringContext) treeNode\r
-                        .getChild(j);\r
-\r
-                if (context != null) {\r
-                    return context.getChild(0).getText().replace("\"", "");\r
-                }\r
-            }\r
-        }\r
-        return result;\r
-    }\r
-\r
-    public static SchemaPath parsePath(String augmentPath) {\r
-        boolean absolute = augmentPath.startsWith("/");\r
-        String[] splittedPath = augmentPath.split("/");\r
-        List<QName> path = new ArrayList<QName>();\r
-        QName name;\r
-        for (String pathElement : splittedPath) {\r
-            if (pathElement.length() > 0) {\r
-                String[] splittedElement = pathElement.split(":");\r
-                if (splittedElement.length == 1) {\r
-                    name = new QName(null, null, null, splittedElement[0]);\r
-                } else {\r
-                    name = new QName(null, null, splittedElement[0],\r
-                            splittedElement[1]);\r
-                }\r
-                path.add(name);\r
-            }\r
-        }\r
-        return new SchemaPath(path, absolute);\r
-    }\r
-\r
-    public static List<QName> createListKey(String keyDefinition,\r
-            URI namespace, Date revision, String prefix) {\r
-        List<QName> key = new ArrayList<QName>();\r
-        String[] splittedKey = keyDefinition.split(" ");\r
-\r
-        QName qname = null;\r
-        for (String keyElement : splittedKey) {\r
-            if (keyElement.length() != 0) {\r
-                qname = new QName(namespace, revision, prefix, keyElement);\r
-                key.add(qname);\r
-            }\r
-        }\r
-        return key;\r
-    }\r
-\r
-    public static TypeDefinition<?> parseUnknownType(QName typedefQName,\r
-            ParseTree ctx) {\r
-        UnknownType.Builder ut = new UnknownType.Builder(typedefQName);\r
-        for (int i = 0; i < ctx.getChildCount(); i++) {\r
-            ParseTree child = ctx.getChild(i);\r
-            if (child instanceof Type_body_stmtsContext) {\r
-                for (int j = 0; j < child.getChildCount(); j++) {\r
-                    ParseTree typeBodyChild = child.getChild(j);\r
-                    // NUMERICAL RESTRICTIONS\r
-                    if (typeBodyChild instanceof Numerical_restrictionsContext) {\r
-                        for (int k = 0; k < typeBodyChild.getChildCount(); k++) {\r
-                            ParseTree numRestrictionsChild = typeBodyChild\r
-                                    .getChild(k);\r
-                            if (numRestrictionsChild instanceof Range_stmtContext) {\r
-                                List<RangeConstraint> ranges = parseRangeConstraints((Range_stmtContext) numRestrictionsChild);\r
-                                ut.rangeStatements(ranges);\r
-                            }\r
-                        }\r
-                        // STRING RESTRICTIONS\r
-                    } else if (typeBodyChild instanceof String_restrictionsContext) {\r
-                        List<PatternConstraint> patterns = new ArrayList<PatternConstraint>();\r
-                        List<LengthConstraint> lengths = new ArrayList<LengthConstraint>();\r
-                        for (int k = 0; k < typeBodyChild.getChildCount(); k++) {\r
-                            ParseTree stringRestrictionsChild = typeBodyChild\r
-                                    .getChild(k);\r
-                            if (stringRestrictionsChild instanceof Pattern_stmtContext) {\r
-                                patterns.add(parsePatternConstraint((Pattern_stmtContext) stringRestrictionsChild));\r
-                            } else if (stringRestrictionsChild instanceof Length_stmtContext) {\r
-                                lengths = parseLengthConstraints((Length_stmtContext) stringRestrictionsChild);\r
-                            }\r
-                        }\r
-                        ut.patterns(patterns);\r
-                        ut.lengthStatements(lengths);\r
-                        // DECIMAL64\r
-                    } else if (typeBodyChild instanceof Decimal64_specificationContext) {\r
-                        for (int k = 0; k < typeBodyChild.getChildCount(); k++) {\r
-                            ParseTree fdChild = typeBodyChild.getChild(k);\r
-                            if (fdChild instanceof Fraction_digits_stmtContext) {\r
-                                // TODO: implement fraction digits\r
-                                // return\r
-                                // Integer.valueOf(stringFromNode(fdChild));\r
-                            }\r
-                        }\r
-                    }\r
-\r
-                }\r
-            }\r
-        }\r
-        return ut.build();\r
-    }\r
-\r
-    public static List<RangeConstraint> getRangeConstraints(\r
-            Type_body_stmtsContext ctx) {\r
-        List<RangeConstraint> rangeConstraints = new ArrayList<RangeConstraint>();\r
-        for (int j = 0; j < ctx.getChildCount(); j++) {\r
-            ParseTree numRestrChild = ctx.getChild(j);\r
-            if (numRestrChild instanceof Numerical_restrictionsContext) {\r
-                for (int k = 0; k < numRestrChild.getChildCount(); k++) {\r
-                    ParseTree rangeChild = numRestrChild.getChild(k);\r
-                    if (rangeChild instanceof Range_stmtContext) {\r
-                        rangeConstraints\r
-                                .addAll(parseRangeConstraints((Range_stmtContext) rangeChild));\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return rangeConstraints;\r
-    }\r
-\r
-    private static List<RangeConstraint> parseRangeConstraints(\r
-            Range_stmtContext ctx) {\r
-        List<RangeConstraint> rangeConstraints = new ArrayList<RangeConstraint>();\r
-        String description = null;\r
-        String reference = null;\r
-\r
-        for (int i = 0; i < ctx.getChildCount(); i++) {\r
-            ParseTree child = ctx.getChild(i);\r
-            if (child instanceof Description_stmtContext) {\r
-                description = stringFromNode(child);\r
-            } else if (child instanceof Reference_stmtContext) {\r
-                reference = stringFromNode(child);\r
-            }\r
-        }\r
-\r
-        String rangeStr = stringFromNode(ctx);\r
-        String trimmed = rangeStr.replace(" ", "");\r
-        String[] splittedRange = trimmed.split("\\|");\r
-        for (String rangeDef : splittedRange) {\r
-            // TODO: this needs to be refactored, because valid range can be\r
-            // also defined as "1..max"\r
-            String[] splittedRangeDef = rangeDef.split("\\.\\.");\r
-            Long min = Long.valueOf(splittedRangeDef[0]);\r
-            Long max = Long.valueOf(splittedRangeDef[1]);\r
-            RangeConstraint range = BaseConstraints.rangeConstraint(min, max,\r
-                    description, reference);\r
-            rangeConstraints.add(range);\r
-        }\r
-\r
-        return rangeConstraints;\r
-    }\r
-\r
-    public static Integer getFractionDigits(Type_body_stmtsContext ctx) {\r
-        for (int j = 0; j < ctx.getChildCount(); j++) {\r
-            ParseTree dec64specChild = ctx.getChild(j);\r
-            if (dec64specChild instanceof Decimal64_specificationContext) {\r
-                for (int k = 0; k < dec64specChild.getChildCount(); k++) {\r
-                    ParseTree fdChild = dec64specChild.getChild(k);\r
-                    if (fdChild instanceof Fraction_digits_stmtContext) {\r
-                        return Integer.valueOf(stringFromNode(fdChild));\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return null;\r
-    }\r
-\r
-    public static List<EnumTypeDefinition.EnumPair> getEnumConstants(\r
-            Type_body_stmtsContext ctx) {\r
-        List<EnumTypeDefinition.EnumPair> enumConstants = new ArrayList<EnumTypeDefinition.EnumPair>();\r
-\r
-        out: for (int j = 0; j < ctx.getChildCount(); j++) {\r
-            ParseTree enumSpecChild = ctx.getChild(j);\r
-            if (enumSpecChild instanceof Enum_specificationContext) {\r
-                for (int k = 0; k < enumSpecChild.getChildCount(); k++) {\r
-                    ParseTree enumChild = enumSpecChild.getChild(k);\r
-                    if (enumChild instanceof Enum_stmtContext) {\r
-                        enumConstants.add(createEnumPair(\r
-                                (Enum_stmtContext) enumChild, k));\r
-                        if (k == enumSpecChild.getChildCount() - 1) {\r
-                            break out;\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return enumConstants;\r
-    }\r
-\r
-    private static EnumTypeDefinition.EnumPair createEnumPair(\r
-            Enum_stmtContext ctx, final int value) {\r
-        final String name = stringFromNode(ctx);\r
-        return new EnumTypeDefinition.EnumPair() {\r
-\r
-            @Override\r
-            public QName getQName() {\r
-                // TODO Auto-generated method stub\r
-                return null;\r
-            }\r
-\r
-            @Override\r
-            public SchemaPath getPath() {\r
-                // TODO Auto-generated method stub\r
-                return null;\r
-            }\r
-\r
-            @Override\r
-            public String getDescription() {\r
-                // TODO Auto-generated method stub\r
-                return null;\r
-            }\r
-\r
-            @Override\r
-            public String getReference() {\r
-                // TODO Auto-generated method stub\r
-                return null;\r
-            }\r
-\r
-            @Override\r
-            public Status getStatus() {\r
-                // TODO Auto-generated method stub\r
-                return null;\r
-            }\r
-\r
-            @Override\r
-            public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-                // TODO Auto-generated method stub\r
-                return null;\r
-            }\r
-\r
-            @Override\r
-            public String getName() {\r
-                return name;\r
-            }\r
-\r
-            @Override\r
-            public Integer getValue() {\r
-                return value;\r
-            }\r
-\r
-            @Override\r
-            public String toString() {\r
-                return EnumTypeDefinition.EnumPair.class.getSimpleName()\r
-                        + "[name=" + name + ", value=" + value + "]";\r
-            }\r
-        };\r
-    }\r
-\r
-    public static List<LengthConstraint> getLengthConstraints(\r
-            Type_body_stmtsContext ctx) {\r
-        List<LengthConstraint> lengthConstraints = new ArrayList<LengthConstraint>();\r
-        for (int j = 0; j < ctx.getChildCount(); j++) {\r
-            ParseTree stringRestrChild = ctx.getChild(j);\r
-            if (stringRestrChild instanceof String_restrictionsContext) {\r
-                for (int k = 0; k < stringRestrChild.getChildCount(); k++) {\r
-                    ParseTree lengthChild = stringRestrChild.getChild(k);\r
-                    if (lengthChild instanceof Length_stmtContext) {\r
-                        lengthConstraints\r
-                                .addAll(parseLengthConstraints((Length_stmtContext) lengthChild));\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return lengthConstraints;\r
-    }\r
-\r
-    private static List<LengthConstraint> parseLengthConstraints(\r
-            Length_stmtContext ctx) {\r
-        List<LengthConstraint> lengthConstraints = new ArrayList<LengthConstraint>();\r
-        String description = null;\r
-        String reference = null;\r
-\r
-        for (int i = 0; i < ctx.getChildCount(); i++) {\r
-            ParseTree child = ctx.getChild(i);\r
-            if (child instanceof Description_stmtContext) {\r
-                description = stringFromNode(child);\r
-            } else if (child instanceof Reference_stmtContext) {\r
-                reference = stringFromNode(child);\r
-            }\r
-        }\r
-\r
-        String lengthStr = stringFromNode(ctx);\r
-        String trimmed = lengthStr.replace(" ", "");\r
-        String[] splittedRange = trimmed.split("\\|");\r
-        for (String rangeDef : splittedRange) {\r
-            // TODO: this needs to be refactored, because valid length can be\r
-            // also defined as "1"\r
-            String[] splittedRangeDef = rangeDef.split("\\.\\.");\r
-            Long min = Long.valueOf(splittedRangeDef[0]);\r
-            Long max = Long.valueOf(splittedRangeDef[1]);\r
-            LengthConstraint range = BaseConstraints.lengthConstraint(min, max,\r
-                    description, reference);\r
-            lengthConstraints.add(range);\r
-        }\r
-\r
-        return lengthConstraints;\r
-    }\r
-\r
-    public static List<PatternConstraint> getPatternConstraint(\r
-            Type_body_stmtsContext ctx) {\r
-        List<PatternConstraint> patterns = new ArrayList<PatternConstraint>();\r
-\r
-        out: for (int j = 0; j < ctx.getChildCount(); j++) {\r
-            ParseTree stringRestrChild = ctx.getChild(j);\r
-            if (stringRestrChild instanceof String_restrictionsContext) {\r
-                for (int k = 0; k < stringRestrChild.getChildCount(); k++) {\r
-                    ParseTree lengthChild = stringRestrChild.getChild(k);\r
-                    if (lengthChild instanceof Pattern_stmtContext) {\r
-                        patterns.add(parsePatternConstraint((Pattern_stmtContext) lengthChild));\r
-                        if (k == lengthChild.getChildCount() - 1) {\r
-                            break out;\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return patterns;\r
-    }\r
-\r
-    /**\r
-     * Internal helper method.\r
-     * \r
-     * @param ctx\r
-     *            pattern context\r
-     * @return PatternConstraint object\r
-     */\r
-    private static PatternConstraint parsePatternConstraint(\r
-            Pattern_stmtContext ctx) {\r
-        String description = null;\r
-        String reference = null;\r
-        for (int i = 0; i < ctx.getChildCount(); i++) {\r
-            ParseTree child = ctx.getChild(i);\r
-            if (child instanceof Description_stmtContext) {\r
-                description = stringFromNode(child);\r
-            } else if (child instanceof Reference_stmtContext) {\r
-                reference = stringFromNode(child);\r
-            }\r
-        }\r
-        String pattern = stringFromNode(ctx);\r
-        return BaseConstraints.patternConstraint(pattern, description,\r
-                reference);\r
-    }\r
-\r
-    public static List<BitsTypeDefinition.Bit> getBits(\r
-            Type_body_stmtsContext ctx, Stack<String> actualPath,\r
-            URI namespace, Date revision, String prefix) {\r
-        List<BitsTypeDefinition.Bit> bits = new ArrayList<BitsTypeDefinition.Bit>();\r
-        for (int j = 0; j < ctx.getChildCount(); j++) {\r
-            ParseTree bitsSpecChild = ctx.getChild(j);\r
-            if (bitsSpecChild instanceof Bits_specificationContext) {\r
-                for (int k = 0; k < bitsSpecChild.getChildCount(); k++) {\r
-                    ParseTree bitChild = bitsSpecChild.getChild(k);\r
-                    if (bitChild instanceof Bit_stmtContext) {\r
-                        bits.add(parseBit((Bit_stmtContext) bitChild,\r
-                                actualPath, namespace, revision, prefix));\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return bits;\r
-    }\r
-\r
-    private static BitsTypeDefinition.Bit parseBit(final Bit_stmtContext ctx,\r
-            Stack<String> actualPath, final URI namespace, final Date revision,\r
-            final String prefix) {\r
-        String name = stringFromNode(ctx);\r
-        final QName qname = new QName(namespace, revision, prefix, name);\r
-        Long position = null;\r
-\r
-        String description = null;\r
-        String reference = null;\r
-        Status status = Status.CURRENT;\r
-\r
-        Stack<String> bitPath = new Stack<String>();\r
-        bitPath.addAll(actualPath);\r
-        bitPath.add(name);\r
-\r
-        SchemaPath schemaPath = getActualSchemaPath(bitPath, namespace,\r
-                revision, prefix);\r
-\r
-        for (int i = 0; i < ctx.getChildCount(); i++) {\r
-            ParseTree child = ctx.getChild(i);\r
-            if (child instanceof Position_stmtContext) {\r
-                String positionStr = stringFromNode(child);\r
-                position = Long.valueOf(positionStr);\r
-                if (position < 0 || position > 4294967295L) {\r
-                    throw new IllegalArgumentException(\r
-                            "position value MUST be in the range 0 to 4294967295, but was: "\r
-                                    + position);\r
-                }\r
-            } else if (child instanceof Description_stmtContext) {\r
-                description = stringFromNode(child);\r
-            } else if (child instanceof Reference_stmtContext) {\r
-                reference = stringFromNode(child);\r
-            } else if (child instanceof Status_stmtContext) {\r
-                status = getStatus((Status_stmtContext) child);\r
-            }\r
-        }\r
-\r
-        // TODO: extensionDefinitions\r
-        return createBit(qname, schemaPath, description, reference, status,\r
-                null, position);\r
-    }\r
-\r
-    private static BitsTypeDefinition.Bit createBit(final QName qname,\r
-            final SchemaPath schemaPath, final String description,\r
-            final String reference, final Status status,\r
-            final List<ExtensionDefinition> extensionDefinitions,\r
-            final Long position) {\r
-        return new BitsTypeDefinition.Bit() {\r
-\r
-            @Override\r
-            public QName getQName() {\r
-                return qname;\r
-            }\r
-\r
-            @Override\r
-            public SchemaPath getPath() {\r
-                return schemaPath;\r
-            }\r
-\r
-            @Override\r
-            public String getDescription() {\r
-                return description;\r
-            }\r
-\r
-            @Override\r
-            public String getReference() {\r
-                return reference;\r
-            }\r
-\r
-            @Override\r
-            public Status getStatus() {\r
-                return status;\r
-            }\r
-\r
-            @Override\r
-            public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-                return extensionDefinitions;\r
-            }\r
-\r
-            @Override\r
-            public Long getPosition() {\r
-                return position;\r
-            }\r
-\r
-            @Override\r
-            public String getName() {\r
-                return qname.getLocalName();\r
-            }\r
-\r
-            @Override\r
-            public int hashCode() {\r
-                final int prime = 31;\r
-                int result = 1;\r
-                result = prime * result\r
-                        + ((qname == null) ? 0 : qname.hashCode());\r
-                result = prime * result\r
-                        + ((schemaPath == null) ? 0 : schemaPath.hashCode());\r
-                result = prime * result\r
-                        + ((description == null) ? 0 : description.hashCode());\r
-                result = prime * result\r
-                        + ((reference == null) ? 0 : reference.hashCode());\r
-                result = prime * result\r
-                        + ((status == null) ? 0 : status.hashCode());\r
-                result = prime * result\r
-                        + ((position == null) ? 0 : position.hashCode());\r
-                result = prime\r
-                        * result\r
-                        + ((extensionDefinitions == null) ? 0\r
-                                : extensionDefinitions.hashCode());\r
-                return result;\r
-            }\r
-\r
-            @Override\r
-            public boolean equals(Object obj) {\r
-                if (this == obj) {\r
-                    return true;\r
-                }\r
-                if (obj == null) {\r
-                    return false;\r
-                }\r
-                if (getClass() != obj.getClass()) {\r
-                    return false;\r
-                }\r
-                Bit other = (Bit) obj;\r
-                if (qname == null) {\r
-                    if (other.getQName() != null) {\r
-                        return false;\r
-                    }\r
-                } else if (!qname.equals(other.getQName())) {\r
-                    return false;\r
-                }\r
-                if (schemaPath == null) {\r
-                    if (other.getPath() != null) {\r
-                        return false;\r
-                    }\r
-                } else if (!schemaPath.equals(other.getPath())) {\r
-                    return false;\r
-                }\r
-                if (description == null) {\r
-                    if (other.getDescription() != null) {\r
-                        return false;\r
-                    }\r
-                } else if (!description.equals(other.getDescription())) {\r
-                    return false;\r
-                }\r
-                if (reference == null) {\r
-                    if (other.getReference() != null) {\r
-                        return false;\r
-                    }\r
-                } else if (!reference.equals(other.getReference())) {\r
-                    return false;\r
-                }\r
-                if (status == null) {\r
-                    if (other.getStatus() != null) {\r
-                        return false;\r
-                    }\r
-                } else if (!status.equals(other.getStatus())) {\r
-                    return false;\r
-                }\r
-                if (extensionDefinitions == null) {\r
-                    if (other.getExtensionSchemaNodes() != null) {\r
-                        return false;\r
-                    }\r
-                } else if (!extensionDefinitions.equals(other\r
-                        .getExtensionSchemaNodes())) {\r
-                    return false;\r
-                }\r
-                if (position == null) {\r
-                    if (other.getPosition() != null) {\r
-                        return false;\r
-                    }\r
-                } else if (!position.equals(other.getPosition())) {\r
-                    return false;\r
-                }\r
-                return true;\r
-            }\r
-\r
-            @Override\r
-            public String toString() {\r
-                return Bit.class.getSimpleName() + "[name="\r
-                        + qname.getLocalName() + ", position=" + position + "]";\r
-            }\r
-        };\r
-    }\r
-\r
-}\r
@@ -1,40 +1,40 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.api;\r
-\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.yang.common.QName;\r
-\r
-public abstract class AbstractChildNodeBuilder implements ChildNodeBuilder {\r
-\r
-    private final QName qname;\r
-    protected final Set<DataSchemaNodeBuilder> childNodes = new HashSet<DataSchemaNodeBuilder>();\r
-    protected final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();\r
-\r
-    protected AbstractChildNodeBuilder(QName qname) {\r
-        this.qname = qname;\r
-    }\r
-\r
-    @Override\r
-    public QName getQName() {\r
-        return qname;\r
-    }\r
-\r
-    @Override\r
-    public void addChildNode(DataSchemaNodeBuilder childNode) {\r
-        childNodes.add(childNode);\r
-    }\r
-\r
-    @Override\r
-    public void addGrouping(GroupingBuilder grouping) {\r
-        groupings.add(grouping);\r
-    }\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.api;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.common.QName;
+
+public abstract class AbstractChildNodeBuilder implements ChildNodeBuilder {
+
+    private final QName qname;
+    protected final Set<DataSchemaNodeBuilder> childNodes = new HashSet<DataSchemaNodeBuilder>();
+    protected final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();
+
+    protected AbstractChildNodeBuilder(QName qname) {
+        this.qname = qname;
+    }
+
+    @Override
+    public QName getQName() {
+        return qname;
+    }
+
+    @Override
+    public void addChildNode(DataSchemaNodeBuilder childNode) {
+        childNodes.add(childNode);
+    }
+
+    @Override
+    public void addGrouping(GroupingBuilder grouping) {
+        groupings.add(grouping);
+    }
+
+}
@@ -1,26 +1,31 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.api;\r
-\r
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-\r
-/**\r
- * Interface for builders of 'augment' statement.\r
- */\r
-public interface AugmentationSchemaBuilder extends ChildNodeBuilder, TypeDefinitionAwareBuilder {\r
-\r
-       void setDescription(String description);\r
-       void setReference(String reference);\r
-       void setStatus(Status status);\r
-\r
-       AugmentationSchema build();\r
-       SchemaPath getTargetPath();\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.api;
+
+import java.util.Set;
+
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+
+/**
+ * Interface for builders of 'augment' statement.
+ */
+public interface AugmentationSchemaBuilder extends ChildNodeBuilder, TypeDefinitionAwareBuilder {
+
+       void setDescription(String description);
+       void setReference(String reference);
+       void setStatus(Status status);
+
+       SchemaPath getTargetPath();
+
+       Set<DataSchemaNodeBuilder> getChildNodes();
+
+        AugmentationSchema build();
+
+}
@@ -1,23 +1,23 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.api;\r
-\r
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
-\r
-/**\r
- * Interface for builders of those nodes, which can be augmentation targets.\r
- */\r
-public interface AugmentationTargetBuilder {\r
-\r
-       /**\r
-        * Add augment, which points to this node.\r
-        * @param augment augment which points to this node\r
-        */\r
-       void addAugmentation(AugmentationSchema augment);\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.api;
+
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+
+/**
+ * Interface for builders of those nodes, which can be augmentation targets.
+ */
+public interface AugmentationTargetBuilder {
+
+       /**
+        * Add augment, which points to this node.
+        * @param augment augment which points to this node
+        */
+       void addAugmentation(AugmentationSchema augment);
+
+}
@@ -1,22 +1,23 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.api;\r
-\r
-import org.opendaylight.controller.yang.common.QName;\r
-\r
-/**\r
- * Interface for all yang data-node containers [augment, case, container, grouping, list, module, notification].\r
- */\r
-public interface ChildNodeBuilder extends Builder {\r
-\r
-       QName getQName();\r
-       void addChildNode(DataSchemaNodeBuilder childNode);\r
-       void addGrouping(GroupingBuilder groupingBuilder);\r
-       void addUsesNode(UsesNodeBuilder usesBuilder);\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.api;
+
+import org.opendaylight.controller.yang.common.QName;
+
+/**
+ * Interface for all yang data-node containers [augment, case, container, grouping, list, module, notification].
+ */
+public interface ChildNodeBuilder extends Builder {
+
+       QName getQName();
+       void addChildNode(DataSchemaNodeBuilder childNode);
+       void addGrouping(GroupingBuilder groupingBuilder);
+       void addUsesNode(UsesNodeBuilder usesBuilder);
+       void addTypedef(TypeDefinitionBuilder typedefBuilder);
+
+}
@@ -1,21 +1,27 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.api;\r
-\r
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;\r
-\r
-/**\r
- * Interface for all yang data-schema nodes [anyxml, case, container, grouping, list, module, notification].\r
- */\r
-public interface DataSchemaNodeBuilder extends SchemaNodeBuilder {\r
-\r
-       DataSchemaNode build();\r
-       void setAugmenting(boolean augmenting);\r
-       void setConfiguration(boolean configuration);\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.api;
+
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ConstraintsBuilder;
+
+/**
+ * Interface for all yang data-schema nodes [anyxml, case, container, grouping,
+ * list, module, notification].
+ */
+public interface DataSchemaNodeBuilder extends SchemaNodeBuilder {
+
+    DataSchemaNode build();
+
+    void setAugmenting(boolean augmenting);
+
+    void setConfiguration(boolean configuration);
+
+    ConstraintsBuilder getConstraintsBuilder();
+
+}
@@ -1,19 +1,19 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.api;\r
-\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-\r
-/**\r
- * Interface for builders of 'grouping' statement.\r
- */\r
-public interface GroupingBuilder extends ChildNodeBuilder, SchemaNodeBuilder, TypeDefinitionAwareBuilder {\r
-\r
-       GroupingDefinition build();\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.api;
+
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+
+/**
+ * Interface for builders of 'grouping' statement.
+ */
+public interface GroupingBuilder extends ChildNodeBuilder, SchemaNodeBuilder, TypeDefinitionAwareBuilder {
+
+       GroupingDefinition build();
+
+}
@@ -1,26 +1,26 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.api;\r
-\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-\r
-\r
-/**\r
- * Interface for all builders of SchemaNode nodes.\r
- */\r
-public interface SchemaNodeBuilder extends Builder {\r
-\r
-       QName getQName();\r
-       void setPath(SchemaPath schemaPath);\r
-       void setDescription(String description);\r
-       void setReference(String reference);\r
-       void setStatus(Status status);\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.api;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+
+
+/**
+ * Interface for all builders of SchemaNode nodes.
+ */
+public interface SchemaNodeBuilder extends Builder {
+
+       QName getQName();
+       void setPath(SchemaPath schemaPath);
+       void setDescription(String description);
+       void setReference(String reference);
+       void setStatus(Status status);
+
+}
@@ -1,21 +1,21 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.api;\r
-\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-\r
-/**\r
- * Builders of all nodes, which can have 'type' statement must implement this interface.\r
- * [typedef, type, leaf, leaf-list, deviate]\r
- */\r
-public interface TypeAwareBuilder {\r
-\r
-       TypeDefinition<?> getType();\r
-       void setType(TypeDefinition<?> type);\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.api;
+
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+
+/**
+ * Builders of all nodes, which can have 'type' statement must implement this interface.
+ * [typedef, type, leaf, leaf-list, deviate]
+ */
+public interface TypeAwareBuilder {
+
+       TypeDefinition<?> getType();
+       void setType(TypeDefinition<?> type);
+
+}
@@ -5,7 +5,7 @@
  * 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.model.parser.api;
+package org.opendaylight.controller.yang.model.parser.builder.api;
 
 /**
  * Builders of all nodes, which can have 'typedef' statement must implement this interface.
@@ -1,23 +1,24 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.api;\r
-\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-\r
-\r
-/**\r
- * Interface for builders of 'typedef' statement.\r
- */\r
-public interface TypeDefinitionBuilder {\r
-\r
-       QName getQName();\r
-       TypeDefinition<?> getBaseType();\r
-       TypeDefinition<?> build();\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.api;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+
+
+/**
+ * Interface for builders of 'typedef' statement.
+ */
+public interface TypeDefinitionBuilder {
+
+       QName getQName();
+       TypeDefinition<?> getBaseType();
+       TypeDefinition<?> build();
+       void setUnits(String units);
+
+}
@@ -1,21 +1,21 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.api;\r
-\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-/**\r
- * Interface for builders of 'uses' statement.\r
- */\r
-public interface UsesNodeBuilder {\r
-\r
-    void addAugment(AugmentationSchemaBuilder builder);\r
-\r
-    UsesNode build();\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.api;
+
+import org.opendaylight.controller.yang.model.api.UsesNode;
+
+/**
+ * Interface for builders of 'uses' statement.
+ */
+public interface UsesNodeBuilder extends Builder {
+
+    void addAugment(AugmentationSchemaBuilder builder);
+    void setAugmenting(boolean augmenting);
+    UsesNode build();
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/AugmentationSchemaBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/AugmentationSchemaBuilderImpl.java
new file mode 100644 (file)
index 0000000..1027cb1
--- /dev/null
@@ -0,0 +1,324 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UsesNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationSchemaBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.util.YangModelBuilderUtil;
+
+public class AugmentationSchemaBuilderImpl implements AugmentationSchemaBuilder {
+
+    private final AugmentationSchemaImpl instance;
+    private final SchemaPath augmentTarget;
+    final Set<DataSchemaNodeBuilder> childNodes = new HashSet<DataSchemaNodeBuilder>();
+    final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();
+    private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();
+
+    AugmentationSchemaBuilderImpl(String augmentPath) {
+        SchemaPath targetPath = YangModelBuilderUtil.parseAugmentPath(augmentPath);
+        augmentTarget = targetPath;
+        instance = new AugmentationSchemaImpl(targetPath);
+    }
+
+    @Override
+    public void addChildNode(DataSchemaNodeBuilder childNode) {
+        childNodes.add(childNode);
+    }
+
+    @Override
+    public Set<DataSchemaNodeBuilder> getChildNodes() {
+        return childNodes;
+    }
+
+    @Override
+    public void addGrouping(GroupingBuilder grouping) {
+        groupings.add(grouping);
+    }
+
+    @Override
+    public void addUsesNode(UsesNodeBuilder usesBuilder) {
+        usesNodes.add(usesBuilder);
+    }
+
+    /**
+     * Always returns null.
+     */
+    @Override
+    public QName getQName() {
+        return null;
+    }
+
+    @Override
+    public AugmentationSchema build() {
+
+        // CHILD NODES
+        Map<QName, DataSchemaNode> childs = new HashMap<QName, DataSchemaNode>();
+        for (DataSchemaNodeBuilder node : childNodes) {
+            childs.put(node.getQName(), node.build());
+        }
+        instance.setChildNodes(childs);
+
+        // GROUPINGS
+        Set<GroupingDefinition> groupingDefinitions = new HashSet<GroupingDefinition>();
+        for (GroupingBuilder builder : groupings) {
+            groupingDefinitions.add(builder.build());
+        }
+        instance.setGroupings(groupingDefinitions);
+
+        // USES
+        Set<UsesNode> usesNodeDefinitions = new HashSet<UsesNode>();
+        for (UsesNodeBuilder builder : usesNodes) {
+            usesNodeDefinitions.add(builder.build());
+        }
+        instance.setUses(usesNodeDefinitions);
+
+        return instance;
+    }
+
+    @Override
+    public void addTypedef(TypeDefinitionBuilder type) {
+        throw new UnsupportedOperationException(
+                "Augmentation can not contains type definitions");
+    }
+
+    @Override
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    @Override
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    @Override
+    public void setStatus(Status status) {
+        instance.setStatus(status);
+    }
+
+    @Override
+    public SchemaPath getTargetPath() {
+        return augmentTarget;
+    }
+
+    private static class AugmentationSchemaImpl implements AugmentationSchema {
+
+        private final SchemaPath targetPath;
+        private Map<QName, DataSchemaNode> childNodes;
+        private Set<GroupingDefinition> groupings;
+        private Set<UsesNode> uses;
+
+        private String description;
+        private String reference;
+        private Status status;
+
+        private AugmentationSchemaImpl(SchemaPath targetPath) {
+            this.targetPath = targetPath;
+        }
+
+        @Override
+        public SchemaPath getTargetPath() {
+            return targetPath;
+        }
+
+        @Override
+        public Set<DataSchemaNode> getChildNodes() {
+            return new HashSet<DataSchemaNode>(childNodes.values());
+        }
+
+        private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {
+            this.childNodes = childNodes;
+        }
+
+        @Override
+        public Set<GroupingDefinition> getGroupings() {
+            return groupings;
+        }
+
+        private void setGroupings(Set<GroupingDefinition> groupings) {
+            this.groupings = groupings;
+        }
+
+        @Override
+        public Set<UsesNode> getUses() {
+            return uses;
+        }
+
+        private void setUses(Set<UsesNode> uses) {
+            this.uses = uses;
+        }
+
+        /**
+         * Always returns an empty set, because augmentation can not contains
+         * type definitions.
+         */
+        @Override
+        public Set<TypeDefinition<?>> getTypeDefinitions() {
+            return Collections.emptySet();
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            this.status = status;
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(QName name) {
+            return childNodes.get(name);
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(String name) {
+            DataSchemaNode result = null;
+            for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
+                if (entry.getKey().getLocalName().equals(name)) {
+                    result = entry.getValue();
+                    break;
+                }
+            }
+            return result;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 17;
+            int result = 1;
+            result = prime * result
+                    + ((targetPath == null) ? 0 : targetPath.hashCode());
+            result = prime * result
+                    + ((childNodes == null) ? 0 : childNodes.hashCode());
+            result = prime * result
+                    + ((groupings == null) ? 0 : groupings.hashCode());
+            result = prime * result + ((uses == null) ? 0 : uses.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result
+                    + ((status == null) ? 0 : status.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            AugmentationSchemaImpl other = (AugmentationSchemaImpl) obj;
+            if (targetPath == null) {
+                if (other.targetPath != null) {
+                    return false;
+                }
+            } else if (!targetPath.equals(other.targetPath)) {
+                return false;
+            }
+            if (childNodes == null) {
+                if (other.childNodes != null) {
+                    return false;
+                }
+            } else if (!childNodes.equals(other.childNodes)) {
+                return false;
+            }
+            if (groupings == null) {
+                if (other.groupings != null) {
+                    return false;
+                }
+            } else if (!groupings.equals(other.groupings)) {
+                return false;
+            }
+            if (uses == null) {
+                if (other.uses != null) {
+                    return false;
+                }
+            } else if (!uses.equals(other.uses)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (status == null) {
+                if (other.status != null) {
+                    return false;
+                }
+            } else if (!status.equals(other.status)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    AugmentationSchemaImpl.class.getSimpleName());
+            sb.append("[");
+            sb.append("targetPath=" + targetPath);
+            sb.append(", childNodes=" + childNodes.values());
+            sb.append(", groupings=" + groupings);
+            sb.append(", uses=" + uses);
+            sb.append("]");
+            return sb.toString();
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ConstraintsBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ConstraintsBuilder.java
new file mode 100644 (file)
index 0000000..0e338f0
--- /dev/null
@@ -0,0 +1,317 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.opendaylight.controller.model.util.RevisionAwareXPathImpl;
+import org.opendaylight.controller.yang.model.api.ConstraintDefinition;
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.api.MustDefinition;
+import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
+
+public class ConstraintsBuilder implements Builder {
+
+    private final ConstraintDefinitionImpl instance;
+    private final Set<MustDefinition> mustDefinitions;
+    private String whenCondition;
+
+    ConstraintsBuilder() {
+        instance = new ConstraintDefinitionImpl();
+        mustDefinitions = new HashSet<MustDefinition>();
+    }
+
+    @Override
+    public ConstraintDefinition build() {
+        RevisionAwareXPath whenStmt = new RevisionAwareXPathImpl(whenCondition,
+                false);
+        instance.setWhenCondition(whenStmt);
+        instance.setMustConstraints(mustDefinitions);
+        return instance;
+    }
+
+    public void setMinElements(Integer minElements) {
+        instance.setMinElements(minElements);
+    }
+
+    public void setMaxElements(Integer maxElements) {
+        instance.setMaxElements(maxElements);
+    }
+
+    public void addMustDefinition(String mustStr, String description,
+            String reference) {
+        MustDefinition must = new MustDefinitionImpl(mustStr, description,
+                reference);
+        mustDefinitions.add(must);
+    }
+
+    public void addWhenCondition(String whenCondition) {
+        this.whenCondition = whenCondition;
+    }
+
+    public void setMandatory(boolean mandatory) {
+        instance.setMandatory(mandatory);
+    }
+
+    private static class ConstraintDefinitionImpl implements
+            ConstraintDefinition {
+
+        private DataSchemaNode parent;
+        private RevisionAwareXPath whenCondition;
+        private Set<MustDefinition> mustConstraints;
+        private boolean mandatory;
+        private Integer minElements;
+        private Integer maxElements;
+
+        @Override
+        public DataSchemaNode getParent() {
+            return parent;
+        }
+
+        @Override
+        public RevisionAwareXPath getWhenCondition() {
+            return whenCondition;
+        }
+
+        private void setWhenCondition(RevisionAwareXPath whenCondition) {
+            this.whenCondition = whenCondition;
+        }
+
+        @Override
+        public Set<MustDefinition> getMustConstraints() {
+            if (mustConstraints == null) {
+                return Collections.emptySet();
+            } else {
+                return mustConstraints;
+            }
+        }
+
+        private void setMustConstraints(Set<MustDefinition> mustConstraints) {
+            if (mustConstraints != null) {
+                this.mustConstraints = mustConstraints;
+            }
+        }
+
+        @Override
+        public boolean isMandatory() {
+            return mandatory;
+        }
+
+        private void setMandatory(boolean mandatory) {
+            this.mandatory = mandatory;
+        }
+
+        @Override
+        public Integer getMinElements() {
+            return minElements;
+        }
+
+        private void setMinElements(Integer minElements) {
+            this.minElements = minElements;
+        }
+
+        @Override
+        public Integer getMaxElements() {
+            return maxElements;
+        }
+
+        private void setMaxElements(Integer maxElements) {
+            this.maxElements = maxElements;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result
+                    + ((parent == null) ? 0 : parent.hashCode());
+            result = prime * result
+                    + ((whenCondition == null) ? 0 : whenCondition.hashCode());
+            result = prime
+                    * result
+                    + ((mustConstraints == null) ? 0 : mustConstraints
+                            .hashCode());
+            result = prime * result
+                    + ((minElements == null) ? 0 : minElements.hashCode());
+            result = prime * result
+                    + ((maxElements == null) ? 0 : maxElements.hashCode());
+            result = prime * result + (mandatory ? 1231 : 1237);
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            ConstraintDefinitionImpl other = (ConstraintDefinitionImpl) obj;
+            if (parent == null) {
+                if (other.parent != null) {
+                    return false;
+                }
+            } else if (!parent.equals(other.parent)) {
+                return false;
+            }
+            if (whenCondition == null) {
+                if (other.whenCondition != null) {
+                    return false;
+                }
+            } else if (!whenCondition.equals(other.whenCondition)) {
+                return false;
+            }
+            if (mustConstraints == null) {
+                if (other.mustConstraints != null) {
+                    return false;
+                }
+            } else if (!mustConstraints.equals(other.mustConstraints)) {
+                return false;
+            }
+            if (mandatory != other.mandatory) {
+                return false;
+            }
+            if (minElements == null) {
+                if (other.minElements != null) {
+                    return false;
+                }
+            } else if (!minElements.equals(other.minElements)) {
+                return false;
+            }
+            if (maxElements == null) {
+                if (other.maxElements != null) {
+                    return false;
+                }
+            } else if (!maxElements.equals(other.maxElements)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    ConstraintDefinitionImpl.class.getSimpleName());
+            sb.append("[");
+            sb.append("parent=" + parent);
+            sb.append(", whenCondition=" + whenCondition);
+            sb.append(", mustConstraints=" + mustConstraints);
+            sb.append(", mandatory=" + mandatory);
+            sb.append(", minElements=" + minElements);
+            sb.append(", maxElements=" + maxElements);
+            sb.append("]");
+            return sb.toString();
+        }
+
+    }
+
+    private static class MustDefinitionImpl implements MustDefinition {
+
+        private final String mustStr;
+        private final String description;
+        private final String reference;
+
+        private MustDefinitionImpl(String mustStr, String description,
+                String reference) {
+            this.mustStr = mustStr;
+            this.description = description;
+            this.reference = reference;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        @Override
+        public String getErrorAppTag() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @Override
+        public String getErrorMessage() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        @Override
+        public RevisionAwareXPath getXpath() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result
+                    + ((mustStr == null) ? 0 : mustStr.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            MustDefinitionImpl other = (MustDefinitionImpl) obj;
+            if (mustStr == null) {
+                if (other.mustStr != null) {
+                    return false;
+                }
+            } else if (!mustStr.equals(other.mustStr)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            return MustDefinitionImpl.class.getSimpleName() + "[mustStr="
+                    + mustStr + "]";
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ContainerSchemaNodeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ContainerSchemaNodeBuilder.java
new file mode 100644 (file)
index 0000000..953b22e
--- /dev/null
@@ -0,0 +1,362 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+import org.opendaylight.controller.yang.model.api.ConstraintDefinition;
+import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.api.UsesNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.AbstractChildNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationTargetBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionAwareBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+
+public class ContainerSchemaNodeBuilder extends AbstractChildNodeBuilder
+        implements TypeDefinitionAwareBuilder, AugmentationTargetBuilder,
+        DataSchemaNodeBuilder {
+
+    private final ContainerSchemaNodeImpl instance;
+    private final ConstraintsBuilder constraintsBuilder;
+
+    private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
+    private final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+    private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
+
+    ContainerSchemaNodeBuilder(QName qname) {
+        super(qname);
+        instance = new ContainerSchemaNodeImpl(qname);
+        constraintsBuilder = new ConstraintsBuilder();
+    }
+
+    @Override
+    public ContainerSchemaNode build() {
+        // CHILD NODES
+        Map<QName, DataSchemaNode> childs = new HashMap<QName, DataSchemaNode>();
+        for (DataSchemaNodeBuilder node : childNodes) {
+            childs.put(node.getQName(), node.build());
+        }
+        instance.setChildNodes(childs);
+
+        // GROUPINGS
+        Set<GroupingDefinition> groupingDefinitions = new HashSet<GroupingDefinition>();
+        for (GroupingBuilder builder : groupings) {
+            groupingDefinitions.add(builder.build());
+        }
+        instance.setGroupings(groupingDefinitions);
+
+        // TYPEDEFS
+        Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();
+        for (TypeDefinitionBuilder entry : addedTypedefs) {
+            typedefs.add(entry.build());
+        }
+        instance.setTypeDefinitions(typedefs);
+
+        // USES
+        Set<UsesNode> uses = new HashSet<UsesNode>();
+        for (UsesNodeBuilder builder : addedUsesNodes) {
+            uses.add(builder.build());
+        }
+        instance.setUses(uses);
+
+        instance.setConstraints(constraintsBuilder.build());
+        instance.setAvailableAugmentations(augmentations);
+
+        return instance;
+    }
+
+    @Override
+    public void addTypedef(TypeDefinitionBuilder type) {
+        addedTypedefs.add(type);
+    }
+
+    @Override
+    public void addAugmentation(AugmentationSchema augment) {
+        augmentations.add(augment);
+    }
+
+    @Override
+    public void setPath(SchemaPath schemaPath) {
+        instance.setPath(schemaPath);
+    }
+
+    @Override
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    @Override
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    @Override
+    public void setStatus(Status status) {
+        instance.setStatus(status);
+    }
+
+    @Override
+    public void setAugmenting(boolean augmenting) {
+        instance.setAugmenting(augmenting);
+    }
+
+    @Override
+    public void setConfiguration(boolean configuration) {
+        instance.setConfiguration(configuration);
+    }
+
+    @Override
+    public ConstraintsBuilder getConstraintsBuilder() {
+        return constraintsBuilder;
+    }
+
+    @Override
+    public void addUsesNode(UsesNodeBuilder usesNodeBuilder) {
+        addedUsesNodes.add(usesNodeBuilder);
+    }
+
+    public void setPresenceContainer(boolean presence) {
+        instance.setPresenceContainer(presence);
+    }
+
+    private class ContainerSchemaNodeImpl implements ContainerSchemaNode {
+
+        private final QName qname;
+        private SchemaPath path;
+        private String description;
+        private String reference;
+        private Status status = Status.CURRENT;
+        private boolean augmenting;
+        private boolean configuration;
+        private ConstraintDefinition constraints;
+        private Set<AugmentationSchema> augmentations = Collections.emptySet();
+        private Map<QName, DataSchemaNode> childNodes = Collections.emptyMap();
+        private Set<GroupingDefinition> groupings = Collections.emptySet();
+        private Set<TypeDefinition<?>> typeDefinitions = Collections.emptySet();
+        private Set<UsesNode> uses = Collections.emptySet();
+        private boolean presence;
+
+        private ContainerSchemaNodeImpl(QName qname) {
+            this.qname = qname;
+        }
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return path;
+        }
+
+        private void setPath(SchemaPath path) {
+            this.path = path;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            if(status != null) {
+                this.status = status;
+            }
+        }
+
+        @Override
+        public boolean isAugmenting() {
+            return augmenting;
+        }
+
+        private void setAugmenting(boolean augmenting) {
+            this.augmenting = augmenting;
+        }
+
+        @Override
+        public boolean isConfiguration() {
+            return configuration;
+        }
+
+        private void setConfiguration(boolean configuration) {
+            this.configuration = configuration;
+        }
+
+        @Override
+        public ConstraintDefinition getConstraints() {
+            return constraints;
+        }
+
+        private void setConstraints(ConstraintDefinition constraints) {
+            this.constraints = constraints;
+        }
+
+        @Override
+        public Set<AugmentationSchema> getAvailableAugmentations() {
+            return augmentations;
+        }
+
+        private void setAvailableAugmentations(
+                Set<AugmentationSchema> augmentations) {
+            if (augmentations != null) {
+                this.augmentations = augmentations;
+            }
+        }
+
+        @Override
+        public Set<DataSchemaNode> getChildNodes() {
+            return new HashSet<DataSchemaNode>(childNodes.values());
+        }
+
+        private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {
+            if (childNodes != null) {
+                this.childNodes = childNodes;
+            }
+        }
+
+        @Override
+        public Set<GroupingDefinition> getGroupings() {
+            return groupings;
+        }
+
+        private void setGroupings(Set<GroupingDefinition> groupings) {
+            if (groupings != null) {
+                this.groupings = groupings;
+            }
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(QName name) {
+            return childNodes.get(name);
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(String name) {
+            DataSchemaNode result = null;
+            for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
+                if (entry.getKey().getLocalName().equals(name)) {
+                    result = entry.getValue();
+                    break;
+                }
+            }
+            return result;
+        }
+
+        @Override
+        public Set<UsesNode> getUses() {
+            return uses;
+        }
+
+        private void setUses(Set<UsesNode> uses) {
+            if (uses != null) {
+                this.uses = uses;
+            }
+        }
+
+        @Override
+        public boolean isPresenceContainer() {
+            return presence;
+        }
+
+        private void setPresenceContainer(boolean presence) {
+            this.presence = presence;
+        }
+
+        @Override
+        public Set<TypeDefinition<?>> getTypeDefinitions() {
+            return typeDefinitions;
+        }
+
+        private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {
+            if (typeDefinitions != null) {
+                this.typeDefinitions = typeDefinitions;
+            }
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            ContainerSchemaNodeImpl other = (ContainerSchemaNodeImpl) obj;
+            if (qname == null) {
+                if (other.qname != null) {
+                    return false;
+                }
+            } else if (!qname.equals(other.qname)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    ContainerSchemaNodeImpl.class.getSimpleName());
+            sb.append("[");
+            sb.append("qname=" + qname);
+            sb.append("]");
+            return sb.toString();
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/DeviationBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/DeviationBuilder.java
new file mode 100644 (file)
index 0000000..6e1bb64
--- /dev/null
@@ -0,0 +1,144 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import org.opendaylight.controller.yang.model.api.Deviation;
+import org.opendaylight.controller.yang.model.api.Deviation.Deviate;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
+import org.opendaylight.controller.yang.model.parser.util.YangModelBuilderUtil;
+
+public class DeviationBuilder implements Builder {
+
+    private final DeviationImpl instance;
+
+    DeviationBuilder(String targetPathStr) {
+        SchemaPath targetPath = YangModelBuilderUtil
+                .parseAugmentPath(targetPathStr);
+        instance = new DeviationImpl(targetPath);
+    }
+
+    @Override
+    public Deviation build() {
+        return instance;
+    }
+
+    public void setDeviate(String deviate) {
+        if (deviate.equals("not-supported")) {
+            instance.setDeviate(Deviate.NOT_SUPPORTED);
+        } else if (deviate.equals("add")) {
+            instance.setDeviate(Deviate.ADD);
+        } else if (deviate.equals("replace")) {
+            instance.setDeviate(Deviate.REPLACE);
+        } else if (deviate.equals("delete")) {
+            instance.setDeviate(Deviate.DELETE);
+        } else {
+            throw new IllegalArgumentException(
+                    "Unsupported type of 'deviate' statement: " + deviate);
+        }
+    }
+
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    private static class DeviationImpl implements Deviation {
+
+        private SchemaPath targetPath;
+        private Deviate deviate;
+        private String reference;
+
+        private DeviationImpl(SchemaPath targetPath) {
+            this.targetPath = targetPath;
+        }
+
+        @Override
+        public SchemaPath getTargetPath() {
+            return targetPath;
+        }
+
+        @Override
+        public Deviate getDeviate() {
+            return deviate;
+        }
+
+        private void setDeviate(Deviate deviate) {
+            this.deviate = deviate;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result
+                    + ((targetPath == null) ? 0 : targetPath.hashCode());
+            result = prime * result
+                    + ((deviate == null) ? 0 : deviate.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            DeviationImpl other = (DeviationImpl) obj;
+            if (targetPath == null) {
+                if (other.targetPath != null) {
+                    return false;
+                }
+            } else if (!targetPath.equals(other.targetPath)) {
+                return false;
+            }
+            if (deviate == null) {
+                if (other.deviate != null) {
+                    return false;
+                }
+            } else if (!deviate.equals(other.deviate)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(DeviationImpl.class.getSimpleName());
+            sb.append("[");
+            sb.append("targetPath="+ targetPath);
+            sb.append(", deviate="+ deviate);
+            sb.append(", reference="+ reference);
+            sb.append("]");
+            return sb.toString();
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ExtensionBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ExtensionBuilder.java
new file mode 100644 (file)
index 0000000..735feb1
--- /dev/null
@@ -0,0 +1,257 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
+
+public class ExtensionBuilder implements SchemaNodeBuilder {
+
+    private final ExtensionDefinitionImpl instance;
+    private final QName qname;
+    private final List<UnknownSchemaNodeBuilder> addedExtensions;
+
+    ExtensionBuilder(QName qname) {
+        this.qname = qname;
+        instance = new ExtensionDefinitionImpl(qname);
+        addedExtensions = new ArrayList<UnknownSchemaNodeBuilder>();
+    }
+
+    @Override
+    public ExtensionDefinition build() {
+        List<UnknownSchemaNode> extensions = new ArrayList<UnknownSchemaNode>();
+        for (UnknownSchemaNodeBuilder e : addedExtensions) {
+            extensions.add(e.build());
+        }
+        instance.setUnknownSchemaNodes(extensions);
+        return instance;
+    }
+
+    public void addExtension(UnknownSchemaNodeBuilder extension) {
+        addedExtensions.add(extension);
+    }
+
+    public void setYinElement(boolean yin) {
+        instance.setYinElement(yin);
+    }
+
+    @Override
+    public QName getQName() {
+        return qname;
+    }
+
+    @Override
+    public void setPath(SchemaPath schemaPath) {
+        instance.setPath(schemaPath);
+    }
+
+    @Override
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    @Override
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    @Override
+    public void setStatus(Status status) {
+        instance.setStatus(status);
+    }
+
+    private static class ExtensionDefinitionImpl implements ExtensionDefinition {
+        private final QName qname;
+        private SchemaPath schemaPath;
+        private String description;
+        private String reference;
+        private Status status = Status.CURRENT;
+        private List<UnknownSchemaNode> unknownSchemaNodes = Collections
+                .emptyList();
+        private boolean yin;
+
+        private ExtensionDefinitionImpl(QName qname) {
+            this.qname = qname;
+        }
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return schemaPath;
+        }
+
+        private void setPath(SchemaPath schemaPath) {
+            this.schemaPath = schemaPath;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            if (status != null) {
+                this.status = status;
+            }
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return unknownSchemaNodes;
+        }
+
+        private void setUnknownSchemaNodes(
+                List<UnknownSchemaNode> unknownSchemaNodes) {
+            if(unknownSchemaNodes != null) {
+                this.unknownSchemaNodes = unknownSchemaNodes;
+            }
+        }
+
+        @Override
+        public String getArgument() {
+            return qname.getLocalName();
+        }
+
+        @Override
+        public boolean isYinElement() {
+            return yin;
+        }
+
+        private void setYinElement(boolean yin) {
+            this.yin = yin;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result
+                    + ((schemaPath == null) ? 0 : schemaPath.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result
+                    + ((status == null) ? 0 : status.hashCode());
+            result = prime
+                    * result
+                    + ((unknownSchemaNodes == null) ? 0
+                            : unknownSchemaNodes.hashCode());
+            result = prime * result + (yin ? 1231 : 1237);
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            ExtensionDefinitionImpl other = (ExtensionDefinitionImpl) obj;
+            if (qname == null) {
+                if (other.qname != null) {
+                    return false;
+                }
+            } else if (!qname.equals(other.qname)) {
+                return false;
+            }
+            if (schemaPath == null) {
+                if (other.schemaPath != null) {
+                    return false;
+                }
+            } else if (!schemaPath.equals(other.schemaPath)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (status == null) {
+                if (other.status != null) {
+                    return false;
+                }
+            } else if (!status.equals(other.status)) {
+                return false;
+            }
+            if (unknownSchemaNodes == null) {
+                if (other.unknownSchemaNodes != null) {
+                    return false;
+                }
+            } else if (!unknownSchemaNodes.equals(other.unknownSchemaNodes)) {
+                return false;
+            }
+            if (yin != other.yin) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    ExtensionDefinitionImpl.class.getSimpleName());
+            sb.append("[");
+            sb.append("qname=" + qname);
+            sb.append(", schemaPath=" + schemaPath);
+            sb.append(", description=" + description);
+            sb.append(", reference=" + reference);
+            sb.append(", status=" + status);
+            sb.append(", extensionSchemaNodes=" + unknownSchemaNodes);
+            sb.append(", yin=" + yin);
+            sb.append("]");
+            return sb.toString();
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/FeatureBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/FeatureBuilder.java
new file mode 100644 (file)
index 0000000..23c74fd
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.FeatureDefinition;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
+
+public class FeatureBuilder implements SchemaNodeBuilder {
+
+    private final FeatureDefinitionImpl instance;
+    private final QName qname;
+
+    FeatureBuilder(QName qname) {
+        this.qname = qname;
+        instance = new FeatureDefinitionImpl(qname);
+    }
+
+    @Override
+    public FeatureDefinitionImpl build() {
+        return instance;
+    }
+
+    @Override
+    public QName getQName() {
+        return qname;
+    }
+
+    @Override
+    public void setPath(SchemaPath path) {
+        instance.setPath(path);
+    }
+
+    @Override
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    @Override
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    @Override
+    public void setStatus(Status status) {
+        instance.setStatus(status);
+    }
+
+    private static class FeatureDefinitionImpl implements FeatureDefinition {
+        private final QName qname;
+        private SchemaPath path;
+        private String description;
+        private String reference;
+        private Status status;
+        private List<UnknownSchemaNode> unknownSchemaNodes = Collections
+                .emptyList();
+
+        private FeatureDefinitionImpl(QName qname) {
+            this.qname = qname;
+        }
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return path;
+        }
+
+        private void setPath(SchemaPath path) {
+            this.path = path;
+            ;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            this.status = status;
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return unknownSchemaNodes;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result + ((path == null) ? 0 : path.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result
+                    + ((status == null) ? 0 : status.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            FeatureDefinitionImpl other = (FeatureDefinitionImpl) obj;
+            if (qname == null) {
+                if (other.qname != null) {
+                    return false;
+                }
+            } else if (!qname.equals(other.qname)) {
+                return false;
+            }
+            if (path == null) {
+                if (other.path != null) {
+                    return false;
+                }
+            } else if (!path.equals(other.path)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (status == null) {
+                if (other.status != null) {
+                    return false;
+                }
+            } else if (!status.equals(other.status)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    FeatureDefinitionImpl.class.getSimpleName());
+            sb.append("[name=" + qname);
+            sb.append(", path=" + path);
+            sb.append(", description=" + description);
+            sb.append(", reference=" + reference);
+            sb.append(", status=" + status + "]");
+            return sb.toString();
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/GroupingBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/GroupingBuilderImpl.java
new file mode 100644 (file)
index 0000000..1bacca8
--- /dev/null
@@ -0,0 +1,350 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.api.UsesNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+
+public class GroupingBuilderImpl implements GroupingBuilder {
+
+    private final GroupingDefinitionImpl instance;
+    private final Set<DataSchemaNodeBuilder> childNodes = new HashSet<DataSchemaNodeBuilder>();
+    private final Set<GroupingBuilder> groupings = new HashSet<GroupingBuilder>();
+    private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
+    private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();
+
+    GroupingBuilderImpl(QName qname) {
+        this.instance = new GroupingDefinitionImpl(qname);
+    }
+
+    @Override
+    public GroupingDefinition build() {
+        // CHILD NODES
+        Map<QName, DataSchemaNode> childs = new HashMap<QName, DataSchemaNode>();
+        for (DataSchemaNodeBuilder node : childNodes) {
+            childs.put(node.getQName(), node.build());
+        }
+        instance.setChildNodes(childs);
+
+        // GROUPINGS
+        Set<GroupingDefinition> groupingDefinitions = new HashSet<GroupingDefinition>();
+        for (GroupingBuilder builder : groupings) {
+            groupingDefinitions.add(builder.build());
+        }
+        instance.setGroupings(groupingDefinitions);
+
+        // TYPEDEFS
+        Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();
+        for (TypeDefinitionBuilder entry : addedTypedefs) {
+            typedefs.add(entry.build());
+        }
+        instance.setTypeDefinitions(typedefs);
+
+        // USES
+        Set<UsesNode> usesNodeDefinitions = new HashSet<UsesNode>();
+        for (UsesNodeBuilder builder : usesNodes) {
+            usesNodeDefinitions.add(builder.build());
+        }
+        instance.setUses(usesNodeDefinitions);
+
+        return instance;
+    }
+
+    /**
+     * Always returns null.
+     */
+    @Override
+    public QName getQName() {
+        return null;
+    }
+
+    @Override
+    public void addTypedef(TypeDefinitionBuilder type) {
+        addedTypedefs.add(type);
+    }
+
+    @Override
+    public void setPath(SchemaPath schemaPath) {
+        instance.setPath(schemaPath);
+    }
+
+    @Override
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    @Override
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    @Override
+    public void setStatus(Status status) {
+        instance.setStatus(status);
+    }
+
+    @Override
+    public void addChildNode(DataSchemaNodeBuilder childNode) {
+        childNodes.add(childNode);
+    }
+
+    @Override
+    public void addGrouping(GroupingBuilder grouping) {
+        groupings.add(grouping);
+    }
+
+    @Override
+    public void addUsesNode(UsesNodeBuilder usesBuilder) {
+        usesNodes.add(usesBuilder);
+    }
+
+    private static class GroupingDefinitionImpl implements GroupingDefinition {
+        private final QName qname;
+        private SchemaPath path;
+        private String description;
+        private String reference;
+        private Status status;
+        private Map<QName, DataSchemaNode> childNodes;
+        private Set<GroupingDefinition> groupings;
+        private Set<TypeDefinition<?>> typeDefinitions;
+        private Set<UsesNode> uses;
+
+        private GroupingDefinitionImpl(QName qname) {
+            this.qname = qname;
+        }
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return path;
+        }
+
+        private void setPath(SchemaPath path) {
+            this.path = path;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            this.status = status;
+        }
+
+        @Override
+        public Set<DataSchemaNode> getChildNodes() {
+            return new HashSet<DataSchemaNode>(childNodes.values());
+        }
+
+        private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {
+            this.childNodes = childNodes;
+        }
+
+        @Override
+        public Set<GroupingDefinition> getGroupings() {
+            return groupings;
+        }
+
+        private void setGroupings(Set<GroupingDefinition> groupings) {
+            this.groupings = groupings;
+        }
+
+        @Override
+        public Set<UsesNode> getUses() {
+            return uses;
+        }
+
+        private void setUses(Set<UsesNode> uses) {
+            this.uses = uses;
+        }
+
+        @Override
+        public Set<TypeDefinition<?>> getTypeDefinitions() {
+            return typeDefinitions;
+        }
+
+        private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {
+            this.typeDefinitions = typeDefinitions;
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return Collections.emptyList();
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(QName name) {
+            return childNodes.get(name);
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(String name) {
+            DataSchemaNode result = null;
+            for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
+                if (entry.getKey().getLocalName().equals(name)) {
+                    result = entry.getValue();
+                    break;
+                }
+            }
+            return result;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result + ((path == null) ? 0 : path.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result
+                    + ((status == null) ? 0 : status.hashCode());
+            result = prime * result
+                    + ((childNodes == null) ? 0 : childNodes.hashCode());
+            result = prime * result
+                    + ((groupings == null) ? 0 : groupings.hashCode());
+            result = prime
+                    * result
+                    + ((typeDefinitions == null) ? 0 : typeDefinitions
+                            .hashCode());
+            result = prime * result + ((uses == null) ? 0 : uses.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            GroupingDefinitionImpl other = (GroupingDefinitionImpl) obj;
+            if (qname == null) {
+                if (other.qname != null) {
+                    return false;
+                }
+            } else if (!qname.equals(other.qname)) {
+                return false;
+            }
+            if (path == null) {
+                if (other.path != null) {
+                    return false;
+                }
+            } else if (!path.equals(other.path)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (status == null) {
+                if (other.status != null) {
+                    return false;
+                }
+            } else if (!status.equals(other.status)) {
+                return false;
+            }
+            if (childNodes == null) {
+                if (other.childNodes != null) {
+                    return false;
+                }
+            } else if (!childNodes.equals(other.childNodes)) {
+                return false;
+            }
+            if (groupings == null) {
+                if (other.groupings != null) {
+                    return false;
+                }
+            } else if (!groupings.equals(other.groupings)) {
+                return false;
+            }
+            if (typeDefinitions == null) {
+                if (other.typeDefinitions != null) {
+                    return false;
+                }
+            } else if (!typeDefinitions.equals(other.typeDefinitions)) {
+                return false;
+            }
+            if (uses == null) {
+                if (other.uses != null) {
+                    return false;
+                }
+            } else if (!uses.equals(other.uses)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    GroupingDefinitionImpl.class.getSimpleName());
+            sb.append("[");
+            sb.append("qname=" + qname);
+            sb.append("]");
+            return sb.toString();
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafListSchemaNodeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafListSchemaNodeBuilder.java
new file mode 100644 (file)
index 0000000..99d3e64
--- /dev/null
@@ -0,0 +1,323 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.ConstraintDefinition;
+import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeAwareBuilder;
+
+public class LeafListSchemaNodeBuilder implements SchemaNodeBuilder,
+        TypeAwareBuilder, DataSchemaNodeBuilder {
+
+    private final LeafListSchemaNodeImpl instance;
+    private final QName qname;
+    private final ConstraintsBuilder constraintsBuilder;
+    private TypeDefinition<?> type;
+
+    LeafListSchemaNodeBuilder(QName qname) {
+        this.qname = qname;
+        instance = new LeafListSchemaNodeImpl(qname);
+        constraintsBuilder = new ConstraintsBuilder();
+    }
+
+    @Override
+    public LeafListSchemaNode build() {
+        instance.setConstraints(constraintsBuilder.build());
+        return instance;
+    }
+
+    @Override
+    public QName getQName() {
+        return qname;
+    }
+
+    @Override
+    public void setPath(SchemaPath path) {
+        instance.setPath(path);
+    }
+
+    @Override
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    @Override
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    @Override
+    public void setStatus(Status status) {
+        if(status != null) {
+            instance.setStatus(status);
+        }
+    }
+
+    @Override
+    public TypeDefinition<?> getType() {
+        return type;
+    }
+
+    @Override
+    public void setType(TypeDefinition<?> type) {
+        this.type = type;
+        instance.setType(type);
+    }
+
+    @Override
+    public void setAugmenting(boolean augmenting) {
+        instance.setAugmenting(augmenting);
+    }
+
+    @Override
+    public void setConfiguration(boolean configuration) {
+        instance.setConfiguration(configuration);
+    }
+
+    @Override
+    public ConstraintsBuilder getConstraintsBuilder() {
+        return constraintsBuilder;
+    }
+
+    public void setUserOrdered(boolean userOrdered) {
+        instance.setUserOrdered(userOrdered);
+    }
+
+    private class LeafListSchemaNodeImpl implements LeafListSchemaNode {
+        private final QName qname;
+        private SchemaPath path;
+        private String description;
+        private String reference;
+        private Status status = Status.CURRENT;
+        private boolean augmenting;
+        private boolean configuration;
+        private ConstraintDefinition constraints;
+        private TypeDefinition<?> type;
+        private boolean userOrdered;
+        private List<UnknownSchemaNode> unknownSchemaNodes = Collections.emptyList();
+
+        private LeafListSchemaNodeImpl(QName qname) {
+            this.qname = qname;
+        }
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return path;
+        }
+
+        private void setPath(SchemaPath path) {
+            this.path = path;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            this.status = status;
+        }
+
+        @Override
+        public boolean isAugmenting() {
+            return augmenting;
+        }
+
+        private void setAugmenting(boolean augmenting) {
+            this.augmenting = augmenting;
+        }
+
+        @Override
+        public boolean isConfiguration() {
+            return configuration;
+        }
+
+        private void setConfiguration(boolean configuration) {
+            this.configuration = configuration;
+        }
+
+        @Override
+        public ConstraintDefinition getConstraints() {
+            return constraints;
+        }
+
+        private void setConstraints(ConstraintDefinition constraints) {
+            this.constraints = constraints;
+        }
+
+        @Override
+        public TypeDefinition<?> getType() {
+            return type;
+        }
+
+        public void setType(TypeDefinition<? extends TypeDefinition<?>> type) {
+            this.type = type;
+        }
+
+        @Override
+        public boolean isUserOrdered() {
+            return userOrdered;
+        }
+
+        private void setUserOrdered(boolean userOrdered) {
+            this.userOrdered = userOrdered;
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return unknownSchemaNodes;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result + ((path == null) ? 0 : path.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result
+                    + ((status == null) ? 0 : status.hashCode());
+            result = prime * result + (augmenting ? 1231 : 1237);
+            result = prime * result + (configuration ? 1231 : 1237);
+            result = prime * result
+                    + ((constraints == null) ? 0 : constraints.hashCode());
+            result = prime * result + ((type == null) ? 0 : type.hashCode());
+            result = prime * result + (userOrdered ? 1231 : 1237);
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            LeafListSchemaNodeImpl other = (LeafListSchemaNodeImpl) obj;
+            if (qname == null) {
+                if (other.qname != null) {
+                    return false;
+                }
+            } else if (!qname.equals(other.qname)) {
+                return false;
+            }
+            if (path == null) {
+                if (other.path != null) {
+                    return false;
+                }
+            } else if (!path.equals(other.path)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (status == null) {
+                if (other.status != null) {
+                    return false;
+                }
+            } else if (!status.equals(other.status)) {
+                return false;
+            }
+            if (augmenting != other.augmenting) {
+                return false;
+            }
+            if (configuration != other.configuration) {
+                return false;
+            }
+            if (constraints == null) {
+                if (other.constraints != null) {
+                    return false;
+                }
+            } else if (!constraints.equals(other.constraints)) {
+                return false;
+            }
+            if (type == null) {
+                if (other.type != null) {
+                    return false;
+                }
+            } else if (!type.equals(other.type)) {
+                return false;
+            }
+            if (userOrdered != other.userOrdered) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    LeafListSchemaNodeImpl.class.getSimpleName());
+            sb.append("[");
+            sb.append("qname=" + qname);
+            sb.append(", path=" + path);
+            sb.append(", description=" + description);
+            sb.append(", reference=" + reference);
+            sb.append(", status=" + status);
+            sb.append(", augmenting=" + augmenting);
+            sb.append(", configuration=" + configuration);
+            sb.append(", constraints=" + constraints);
+            sb.append(", type=" + type);
+            sb.append(", userOrdered=" + userOrdered);
+            sb.append("]");
+            return sb.toString();
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafSchemaNodeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafSchemaNodeBuilder.java
new file mode 100644 (file)
index 0000000..5c28e1b
--- /dev/null
@@ -0,0 +1,307 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.ConstraintDefinition;
+import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeAwareBuilder;
+
+public class LeafSchemaNodeBuilder implements DataSchemaNodeBuilder,
+        SchemaNodeBuilder, TypeAwareBuilder {
+
+    private final QName qname;
+    private final LeafSchemaNodeImpl instance;
+    private final ConstraintsBuilder constraintsBuilder;
+    private TypeDefinition<?> type;
+
+    LeafSchemaNodeBuilder(QName qname) {
+        this.qname = qname;
+        instance = new LeafSchemaNodeImpl(qname);
+        constraintsBuilder = new ConstraintsBuilder();
+    }
+
+    @Override
+    public LeafSchemaNode build() {
+        instance.setConstraints(constraintsBuilder.build());
+        return instance;
+    }
+
+    @Override
+    public QName getQName() {
+        return qname;
+    }
+
+    @Override
+    public void setPath(SchemaPath path) {
+        instance.setPath(path);
+    }
+
+    @Override
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    @Override
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    @Override
+    public void setStatus(Status status) {
+        if(status != null) {
+            instance.setStatus(status);
+        }
+    }
+
+    @Override
+    public void setAugmenting(boolean augmenting) {
+        instance.setAugmenting(augmenting);
+    }
+
+    @Override
+    public void setConfiguration(boolean configuration) {
+        instance.setConfiguration(configuration);
+    }
+
+    @Override
+    public ConstraintsBuilder getConstraintsBuilder() {
+        return constraintsBuilder;
+    }
+
+    @Override
+    public TypeDefinition<?> getType() {
+        return type;
+    }
+
+    @Override
+    public void setType(TypeDefinition<?> type) {
+        this.type = type;
+        instance.setType(type);
+    }
+
+    private class LeafSchemaNodeImpl implements LeafSchemaNode {
+        private final QName qname;
+        private SchemaPath path;
+        private String description;
+        private String reference;
+        private Status status = Status.CURRENT;
+        private boolean augmenting;
+        private boolean configuration;
+        private ConstraintDefinition constraints;
+        private TypeDefinition<?> type;
+        private List<UnknownSchemaNode> unknownSchemaNodes = Collections.emptyList();
+
+        private LeafSchemaNodeImpl(QName qname) {
+            this.qname = qname;
+        }
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return path;
+        }
+
+        private void setPath(SchemaPath path) {
+            this.path = path;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            if (status != null) {
+                this.status = status;
+            }
+        }
+
+        @Override
+        public boolean isAugmenting() {
+            return augmenting;
+        }
+
+        private void setAugmenting(boolean augmenting) {
+            this.augmenting = augmenting;
+        }
+
+        @Override
+        public boolean isConfiguration() {
+            return configuration;
+        }
+
+        private void setConfiguration(boolean configuration) {
+            this.configuration = configuration;
+        }
+
+        @Override
+        public ConstraintDefinition getConstraints() {
+            return constraints;
+        }
+
+        private void setConstraints(ConstraintDefinition constraints) {
+            this.constraints = constraints;
+        }
+
+        @Override
+        public TypeDefinition<?> getType() {
+            return type;
+        }
+
+        private void setType(TypeDefinition<? extends TypeDefinition<?>> type) {
+            this.type = type;
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return unknownSchemaNodes;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result + ((path == null) ? 0 : path.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result
+                    + ((status == null) ? 0 : status.hashCode());
+            result = prime * result + (augmenting ? 1231 : 1237);
+            result = prime * result + (configuration ? 1231 : 1237);
+            result = prime * result
+                    + ((constraints == null) ? 0 : constraints.hashCode());
+            result = prime * result + ((type == null) ? 0 : type.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            LeafSchemaNodeImpl other = (LeafSchemaNodeImpl) obj;
+            if (qname == null) {
+                if (other.qname != null) {
+                    return false;
+                }
+            } else if (!qname.equals(other.qname)) {
+                return false;
+            }
+            if (path == null) {
+                if (other.path != null) {
+                    return false;
+                }
+            } else if (!path.equals(other.path)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (status == null) {
+                if (other.status != null) {
+                    return false;
+                }
+            } else if (!status.equals(other.status)) {
+                return false;
+            }
+            if (augmenting != other.augmenting) {
+                return false;
+            }
+            if (configuration != other.configuration) {
+                return false;
+            }
+            if (constraints == null) {
+                if (other.constraints != null) {
+                    return false;
+                }
+            } else if (!constraints.equals(other.constraints)) {
+                return false;
+            }
+            if (type == null) {
+                if (other.type != null) {
+                    return false;
+                }
+            } else if (!type.equals(other.type)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    LeafSchemaNodeImpl.class.getSimpleName());
+            sb.append("[");
+            sb.append("qname=" + qname);
+            sb.append(", path=" + path);
+            sb.append(", description=" + description);
+            sb.append(", reference=" + reference);
+            sb.append(", status=" + status);
+            sb.append(", augmenting=" + augmenting);
+            sb.append(", configuration=" + configuration);
+            sb.append(", constraints=" + constraints);
+            sb.append(", type=" + type);
+            sb.append(", constraints=" + constraints);
+            sb.append("]");
+            return sb.toString();
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ListSchemaNodeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ListSchemaNodeBuilder.java
new file mode 100644 (file)
index 0000000..2a4befe
--- /dev/null
@@ -0,0 +1,508 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+import org.opendaylight.controller.yang.model.api.ConstraintDefinition;
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.ListSchemaNode;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.api.UsesNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.AbstractChildNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationTargetBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionAwareBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+
+public class ListSchemaNodeBuilder extends AbstractChildNodeBuilder implements
+        DataSchemaNodeBuilder, SchemaNodeBuilder, AugmentationTargetBuilder,
+        TypeDefinitionAwareBuilder {
+
+    private final ListSchemaNodeImpl instance;
+    private final ConstraintsBuilder constraintsBuilder;
+
+    private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
+    private final Set<AugmentationSchema> augmentations = new HashSet<AugmentationSchema>();
+    private final Set<UsesNodeBuilder> usesNodes = new HashSet<UsesNodeBuilder>();
+
+    ListSchemaNodeBuilder(QName qname) {
+        super(qname);
+        instance = new ListSchemaNodeImpl(qname);
+        constraintsBuilder = new ConstraintsBuilder();
+    }
+
+    @Override
+    public ListSchemaNode build() {
+        // CHILD NODES
+        Map<QName, DataSchemaNode> childs = new HashMap<QName, DataSchemaNode>();
+        for (DataSchemaNodeBuilder node : childNodes) {
+            childs.put(node.getQName(), node.build());
+        }
+        instance.setChildNodes(childs);
+
+        // TYPEDEFS
+        Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();
+        for (TypeDefinitionBuilder entry : addedTypedefs) {
+            typedefs.add(entry.build());
+        }
+        instance.setTypeDefinitions(typedefs);
+
+        // USES
+        Set<UsesNode> usesNodeDefinitions = new HashSet<UsesNode>();
+        for (UsesNodeBuilder builder : usesNodes) {
+            usesNodeDefinitions.add(builder.build());
+        }
+        instance.setUses(usesNodeDefinitions);
+
+        // GROUPINGS
+        Set<GroupingDefinition> groupingDefinitions = new HashSet<GroupingDefinition>();
+        for (GroupingBuilder builder : groupings) {
+            groupingDefinitions.add(builder.build());
+        }
+        instance.setGroupings(groupingDefinitions);
+
+        instance.setConstraints(constraintsBuilder.build());
+        instance.setAvailableAugmentations(augmentations);
+
+        return instance;
+    }
+
+    @Override
+    public void addTypedef(TypeDefinitionBuilder type) {
+        addedTypedefs.add(type);
+    }
+
+    @Override
+    public void setPath(SchemaPath path) {
+        instance.setPath(path);
+    }
+
+    @Override
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    @Override
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    @Override
+    public void setStatus(Status status) {
+        if(status != null) {
+            instance.setStatus(status);
+        }
+    }
+
+    @Override
+    public void addUsesNode(UsesNodeBuilder usesBuilder) {
+        usesNodes.add(usesBuilder);
+    }
+
+    @Override
+    public void addAugmentation(AugmentationSchema augmentationSchema) {
+        augmentations.add(augmentationSchema);
+    }
+
+    public void setKeyDefinition(List<QName> keyDefinition) {
+        instance.setKeyDefinition(keyDefinition);
+    }
+
+    @Override
+    public void setAugmenting(boolean augmenting) {
+        instance.setAugmenting(augmenting);
+    }
+
+    @Override
+    public void setConfiguration(boolean configuration) {
+        instance.setConfiguration(configuration);
+    }
+
+    @Override
+    public ConstraintsBuilder getConstraintsBuilder() {
+        return constraintsBuilder;
+    }
+
+    public void setUserOrdered(boolean userOrdered) {
+        instance.setUserOrdered(userOrdered);
+    }
+
+    private class ListSchemaNodeImpl implements ListSchemaNode {
+        private final QName qname;
+        private SchemaPath path;
+        private String description;
+        private String reference;
+        private Status status = Status.CURRENT;
+        private List<QName> keyDefinition = Collections.emptyList();
+        private boolean augmenting;
+        private boolean configuration;
+        private ConstraintDefinition constraints;
+        private Set<AugmentationSchema> augmentations = Collections.emptySet();
+        private Map<QName, DataSchemaNode> childNodes = Collections.emptyMap();
+        private Set<TypeDefinition<?>> typeDefinitions = Collections.emptySet();
+        private Set<GroupingDefinition> groupings = Collections.emptySet();
+        private Set<UsesNode> uses = Collections.emptySet();
+        private boolean userOrdered;
+        private List<UnknownSchemaNode> unknownSchemaNodes = Collections.emptyList();
+
+        private ListSchemaNodeImpl(QName qname) {
+            this.qname = qname;
+        }
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return path;
+        }
+
+        private void setPath(SchemaPath path) {
+            this.path = path;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            this.status = status;
+        }
+
+        @Override
+        public List<QName> getKeyDefinition() {
+            if(keyDefinition == null) {
+                return Collections.emptyList();
+            } else {
+                return keyDefinition;
+            }
+        }
+
+        private void setKeyDefinition(List<QName> keyDefinition) {
+            if(keyDefinition != null) {
+                this.keyDefinition = keyDefinition;
+            }
+        }
+
+        @Override
+        public boolean isAugmenting() {
+            return augmenting;
+        }
+
+        private void setAugmenting(boolean augmenting) {
+            this.augmenting = augmenting;
+        }
+
+        @Override
+        public boolean isConfiguration() {
+            return configuration;
+        }
+
+        private void setConfiguration(boolean configuration) {
+            this.configuration = configuration;
+        }
+
+        @Override
+        public ConstraintDefinition getConstraints() {
+            return constraints;
+        }
+
+        private void setConstraints(ConstraintDefinition constraints) {
+            this.constraints = constraints;
+        }
+
+        @Override
+        public Set<AugmentationSchema> getAvailableAugmentations() {
+            return augmentations;
+        }
+
+        private void setAvailableAugmentations(
+                Set<AugmentationSchema> augmentations) {
+            if(augmentations != null) {
+                this.augmentations = augmentations;
+            }
+        }
+
+        @Override
+        public Set<DataSchemaNode> getChildNodes() {
+            return new HashSet<DataSchemaNode>(childNodes.values());
+        }
+
+        private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {
+            if(childNodes != null) {
+                this.childNodes = childNodes;
+            }
+        }
+
+        @Override
+        public Set<GroupingDefinition> getGroupings() {
+            return groupings;
+        }
+
+        private void setGroupings(Set<GroupingDefinition> groupings) {
+            if(groupings != null) {
+                this.groupings = groupings;
+            }
+        }
+
+        @Override
+        public Set<TypeDefinition<?>> getTypeDefinitions() {
+            return typeDefinitions;
+        }
+
+        private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {
+            if(typeDefinitions != null) {
+                this.typeDefinitions = typeDefinitions;
+            }
+        }
+
+        @Override
+        public Set<UsesNode> getUses() {
+            return uses;
+        }
+
+        private void setUses(Set<UsesNode> uses) {
+            if(uses != null) {
+                this.uses = uses;
+            }
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(QName name) {
+            return childNodes.get(name);
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(String name) {
+            DataSchemaNode result = null;
+            for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
+                if (entry.getKey().getLocalName().equals(name)) {
+                    result = entry.getValue();
+                    break;
+                }
+            }
+            return result;
+        }
+
+        @Override
+        public boolean isUserOrdered() {
+            return userOrdered;
+        }
+
+        private void setUserOrdered(boolean userOrdered) {
+            this.userOrdered = userOrdered;
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return unknownSchemaNodes;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result + ((path == null) ? 0 : path.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result
+                    + ((status == null) ? 0 : status.hashCode());
+            result = prime * result
+                    + ((keyDefinition == null) ? 0 : keyDefinition.hashCode());
+            result = prime * result + (augmenting ? 1231 : 1237);
+            result = prime * result + (configuration ? 1231 : 1237);
+            result = prime * result
+                    + ((constraints == null) ? 0 : constraints.hashCode());
+            result = prime * result
+                    + ((augmentations == null) ? 0 : augmentations.hashCode());
+            result = prime * result
+                    + ((childNodes == null) ? 0 : childNodes.hashCode());
+            result = prime
+                    * result
+                    + ((typeDefinitions == null) ? 0 : typeDefinitions
+                            .hashCode());
+            result = prime * result
+                    + ((groupings == null) ? 0 : groupings.hashCode());
+            result = prime * result + ((uses == null) ? 0 : uses.hashCode());
+            result = prime * result + (userOrdered ? 1231 : 1237);
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            ListSchemaNodeImpl other = (ListSchemaNodeImpl) obj;
+            if (qname == null) {
+                if (other.qname != null) {
+                    return false;
+                }
+            } else if (!qname.equals(other.qname)) {
+                return false;
+            }
+            if (path == null) {
+                if (other.path != null) {
+                    return false;
+                }
+            } else if (!path.equals(other.path)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (status == null) {
+                if (other.status != null) {
+                    return false;
+                }
+            } else if (!status.equals(other.status)) {
+                return false;
+            }
+            if (keyDefinition == null) {
+                if (other.keyDefinition != null) {
+                    return false;
+                }
+            } else if (!keyDefinition.equals(other.keyDefinition)) {
+                return false;
+            }
+            if (augmenting != other.augmenting) {
+                return false;
+            }
+            if (configuration != other.configuration) {
+                return false;
+            }
+            if (constraints == null) {
+                if (other.constraints != null) {
+                    return false;
+                }
+            } else if (!constraints.equals(other.constraints)) {
+                return false;
+            }
+            if (augmentations == null) {
+                if (other.augmentations != null) {
+                    return false;
+                }
+            } else if (!augmentations.equals(other.augmentations)) {
+                return false;
+            }
+            if (childNodes == null) {
+                if (other.childNodes != null) {
+                    return false;
+                }
+            } else if (!childNodes.equals(other.childNodes)) {
+                return false;
+            }
+            if (typeDefinitions == null) {
+                if (other.typeDefinitions != null) {
+                    return false;
+                }
+            } else if (!typeDefinitions.equals(other.typeDefinitions)) {
+                return false;
+            }
+            if (groupings == null) {
+                if (other.groupings != null) {
+                    return false;
+                }
+            } else if (!groupings.equals(other.groupings)) {
+                return false;
+            }
+            if (uses == null) {
+                if (other.uses != null) {
+                    return false;
+                }
+            } else if (!uses.equals(other.uses)) {
+                return false;
+            }
+            if (userOrdered != other.userOrdered) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    ListSchemaNodeImpl.class.getSimpleName());
+            sb.append("[");
+            sb.append("qname=" + qname);
+            sb.append(", path=" + path);
+            sb.append(", description=" + description);
+            sb.append(", reference=" + reference);
+            sb.append(", status=" + status);
+            sb.append(", keyDefinition=" + keyDefinition);
+            sb.append(", augmenting=" + augmenting);
+            sb.append(", configuration=" + configuration);
+            sb.append(", constraints=" + constraints);
+            sb.append(", augmentations=" + augmentations);
+            sb.append(", childNodes=" + childNodes.values());
+            sb.append(", typedefinitions=" + typeDefinitions);
+            sb.append(", groupings=" + groupings);
+            sb.append(", uses=" + uses);
+            sb.append(", userOrdered=" + userOrdered);
+            sb.append("]");
+            return sb.toString();
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ModuleBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/ModuleBuilder.java
new file mode 100644 (file)
index 0000000..5f89e86
--- /dev/null
@@ -0,0 +1,1098 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.api.Deviation;
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;
+import org.opendaylight.controller.yang.model.api.FeatureDefinition;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.ModuleImport;
+import org.opendaylight.controller.yang.model.api.NotificationDefinition;
+import org.opendaylight.controller.yang.model.api.RpcDefinition;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UsesNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationSchemaBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
+import org.opendaylight.controller.yang.model.parser.builder.api.ChildNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeAwareBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionAwareBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+
+/**
+ * This builder builds Module object. If this module is dependent on external
+ * module/modules, these dependencies must be resolved before module is built,
+ * otherwise result may not be valid.
+ */
+public class ModuleBuilder implements Builder {
+
+    private final ModuleImpl instance;
+    private final String name;
+    private String prefix;
+    private Date revision;
+
+    private final Set<ModuleImport> imports = new HashSet<ModuleImport>();
+    private Set<AugmentationSchema> augmentations;
+
+    /**
+     * All nodes, that can contain other nodes
+     */
+    private final Map<List<String>, Builder> moduleNodes = new HashMap<List<String>, Builder>();
+
+    /**
+     * Holds all child (DataSchemaNode) nodes: anyxml, choice, case, container,
+     * list, leaf, leaf-list.
+     */
+    private final Map<List<String>, DataSchemaNodeBuilder> addedChilds = new HashMap<List<String>, DataSchemaNodeBuilder>();
+
+    private final Map<List<String>, GroupingBuilder> addedGroupings = new HashMap<List<String>, GroupingBuilder>();
+    private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();
+    private final Map<List<String>, UsesNodeBuilder> addedUsesNodes = new HashMap<List<String>, UsesNodeBuilder>();
+    private final Map<List<String>, RpcDefinitionBuilder> addedRpcs = new HashMap<List<String>, RpcDefinitionBuilder>();
+    private final Set<NotificationBuilder> addedNotifications = new HashSet<NotificationBuilder>();
+    private final Map<List<String>, FeatureBuilder> addedFeatures = new HashMap<List<String>, FeatureBuilder>();
+    private final Map<String, DeviationBuilder> addedDeviations = new HashMap<String, DeviationBuilder>();
+    private final Map<List<String>, TypeDefinitionBuilder> addedTypedefs = new HashMap<List<String>, TypeDefinitionBuilder>();
+    private final List<ExtensionBuilder> addedExtensions = new ArrayList<ExtensionBuilder>();
+
+    private final Map<List<String>, TypeAwareBuilder> dirtyNodes = new HashMap<List<String>, TypeAwareBuilder>();
+
+    public ModuleBuilder(String name) {
+        this.name = name;
+        instance = new ModuleImpl(name);
+    }
+
+
+
+    /**
+     * Build new Module object based on this builder.
+     */
+    @Override
+    public Module build() {
+        instance.setImports(imports);
+
+        // TYPEDEFS
+        final Set<TypeDefinition<?>> typedefs = buildModuleTypedefs(addedTypedefs);
+        instance.setTypeDefinitions(typedefs);
+
+        // CHILD NODES
+        final Map<QName, DataSchemaNode> childNodes = buildModuleChildNodes(addedChilds);
+        instance.setChildNodes(childNodes);
+
+        // GROUPINGS
+        final Set<GroupingDefinition> groupings = buildModuleGroupings(addedGroupings);
+        instance.setGroupings(groupings);
+
+        // USES
+        final Set<UsesNode> usesNodeDefinitions = buildUsesNodes(addedUsesNodes);
+        instance.setUses(usesNodeDefinitions);
+
+        // FEATURES
+        final Set<FeatureDefinition> features = buildModuleFeatures(addedFeatures);
+        instance.setFeatures(features);
+
+        // NOTIFICATIONS
+        final Set<NotificationDefinition> notifications = new HashSet<NotificationDefinition>();
+        for (NotificationBuilder entry : addedNotifications) {
+            notifications.add((NotificationDefinition) entry.build());
+        }
+        instance.setNotifications(notifications);
+
+        // AUGMENTATIONS
+        instance.setAugmentations(augmentations);
+
+        // RPCs
+        final Set<RpcDefinition> rpcs = buildModuleRpcs(addedRpcs);
+        instance.setRpcs(rpcs);
+
+        // DEVIATIONS
+        final Set<Deviation> deviations = new HashSet<Deviation>();
+        for (Map.Entry<String, DeviationBuilder> entry : addedDeviations
+                .entrySet()) {
+            deviations.add(entry.getValue().build());
+        }
+        instance.setDeviations(deviations);
+
+        // EXTENSIONS
+        final List<ExtensionDefinition> extensions = new ArrayList<ExtensionDefinition>();
+        for(ExtensionBuilder b : addedExtensions) {
+            extensions.add(b.build());
+        }
+        instance.setExtensionSchemaNodes(extensions);
+
+        return instance;
+    }
+
+    public Builder getNode(List<String> path) {
+        return moduleNodes.get(path);
+    }
+
+    public Map<List<String>, TypeAwareBuilder> getDirtyNodes() {
+        return dirtyNodes;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getPrefix() {
+        return prefix;
+    }
+
+    public Date getRevision() {
+        return revision;
+    }
+
+    public Set<AugmentationSchemaBuilder> getAddedAugments() {
+        return addedAugments;
+    }
+
+    public void addDirtyNode(List<String> path) {
+        List<String> dirtyNodePath = new ArrayList<String>(path);
+        TypeAwareBuilder nodeBuilder = (TypeAwareBuilder) moduleNodes
+                .get(dirtyNodePath);
+        dirtyNodes.put(dirtyNodePath, nodeBuilder);
+    }
+
+    public void setNamespace(URI namespace) {
+        instance.setNamespace(namespace);
+    }
+
+    public void setRevision(Date revision) {
+        this.revision = revision;
+        instance.setRevision(revision);
+    }
+
+    public void setPrefix(String prefix) {
+        this.prefix = prefix;
+        instance.setPrefix(prefix);
+    }
+
+    public void setYangVersion(String yangVersion) {
+        instance.setYangVersion(yangVersion);
+    }
+
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    public void setOrganization(String organization) {
+        instance.setOrganization(organization);
+    }
+
+    public void setContact(String contact) {
+        instance.setContact(contact);
+    }
+
+    public void setAugmentations(Set<AugmentationSchema> augmentations) {
+        this.augmentations = augmentations;
+    }
+
+    public boolean addModuleImport(final String moduleName,
+            final Date revision, final String prefix) {
+        ModuleImport moduleImport = createModuleImport(moduleName, revision,
+                prefix);
+        return imports.add(moduleImport);
+    }
+
+    public Set<ModuleImport> getModuleImports() {
+        return imports;
+    }
+
+    public ExtensionBuilder addExtension(QName qname) {
+        ExtensionBuilder builder = new ExtensionBuilder(qname);
+        return builder;
+    }
+
+    public ContainerSchemaNodeBuilder addContainerNode(QName containerName,
+            List<String> parentPath) {
+        List<String> pathToNode = new ArrayList<String>(parentPath);
+
+        ContainerSchemaNodeBuilder containerBuilder = new ContainerSchemaNodeBuilder(
+                containerName);
+
+        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
+                .get(pathToNode);
+        if (parent != null) {
+            if(parent instanceof AugmentationSchemaBuilder) {
+                containerBuilder.setAugmenting(true);
+            }
+            parent.addChildNode(containerBuilder);
+        }
+
+        pathToNode.add(containerName.getLocalName());
+        moduleNodes.put(pathToNode, containerBuilder);
+        addedChilds.put(pathToNode, containerBuilder);
+
+        return containerBuilder;
+    }
+
+    public ListSchemaNodeBuilder addListNode(QName listName,
+            List<String> parentPath) {
+        List<String> pathToNode = new ArrayList<String>(parentPath);
+
+        ListSchemaNodeBuilder listBuilder = new ListSchemaNodeBuilder(listName);
+
+        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes
+                .get(pathToNode);
+        if (parent != null) {
+            if(parent instanceof AugmentationSchemaBuilder) {
+                listBuilder.setAugmenting(true);
+            }
+            parent.addChildNode(listBuilder);
+        }
+
+        pathToNode.add(listName.getLocalName());
+        moduleNodes.put(pathToNode, listBuilder);
+        addedChilds.put(pathToNode, listBuilder);
+
+        return listBuilder;
+    }
+
+    public LeafSchemaNodeBuilder addLeafNode(QName leafName,
+            List<String> parentPath) {
+        List<String> pathToNode = new ArrayList<String>(parentPath);
+
+        LeafSchemaNodeBuilder leafBuilder = new LeafSchemaNodeBuilder(leafName);
+
+        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes.get(pathToNode);
+        if (parent != null) {
+            if(parent instanceof AugmentationSchemaBuilder) {
+                leafBuilder.setAugmenting(true);
+            }
+            parent.addChildNode(leafBuilder);
+        }
+
+        pathToNode.add(leafName.getLocalName());
+        addedChilds.put(pathToNode, leafBuilder);
+        moduleNodes.put(pathToNode, leafBuilder);
+
+        return leafBuilder;
+    }
+
+    public LeafListSchemaNodeBuilder addLeafListNode(QName leafListName,
+            List<String> parentPath) {
+        List<String> pathToNode = new ArrayList<String>(parentPath);
+
+        LeafListSchemaNodeBuilder leafListBuilder = new LeafListSchemaNodeBuilder(
+                leafListName);
+        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes.get(pathToNode);
+        if (parent != null) {
+            if(parent instanceof AugmentationSchemaBuilder) {
+                leafListBuilder.setAugmenting(true);
+            }
+            parent.addChildNode(leafListBuilder);
+        }
+
+        pathToNode.add(leafListName.getLocalName());
+        addedChilds.put(pathToNode, leafListBuilder);
+        moduleNodes.put(pathToNode, leafListBuilder);
+
+        return leafListBuilder;
+    }
+
+    public GroupingBuilder addGrouping(QName qname, List<String> parentPath) {
+        List<String> pathToGroup = new ArrayList<String>(parentPath);
+
+        GroupingBuilder builder = new GroupingBuilderImpl(qname);
+        ChildNodeBuilder parentNodeBuilder = (ChildNodeBuilder) moduleNodes.get(pathToGroup);
+        if (parentNodeBuilder != null) {
+            parentNodeBuilder.addGrouping(builder);
+        }
+
+        pathToGroup.add(qname.getLocalName());
+        moduleNodes.put(pathToGroup, builder);
+        addedGroupings.put(pathToGroup, builder);
+
+        return builder;
+    }
+
+    public AugmentationSchemaBuilder addAugment(String name,
+            List<String> parentPath) {
+        List<String> pathToAugment = new ArrayList<String>(parentPath);
+
+        AugmentationSchemaBuilder builder = new AugmentationSchemaBuilderImpl(name);
+
+        // augment can only be in 'module' or 'uses' statement
+        UsesNodeBuilder parent = addedUsesNodes.get(pathToAugment);
+        if (parent != null) {
+            parent.addAugment(builder);
+        }
+
+        pathToAugment.add(name);
+        moduleNodes.put(pathToAugment, builder);
+        addedAugments.add(builder);
+
+        return builder;
+    }
+
+    public UsesNodeBuilder addUsesNode(String groupingPathStr,
+            List<String> parentPath) {
+        List<String> pathToUses = new ArrayList<String>(parentPath);
+
+        UsesNodeBuilder usesBuilder = new UsesNodeBuilderImpl(groupingPathStr);
+
+        ChildNodeBuilder parent = (ChildNodeBuilder) moduleNodes.get(pathToUses);
+        if (parent != null) {
+            if(parent instanceof AugmentationSchemaBuilder) {
+                usesBuilder.setAugmenting(true);
+            }
+            parent.addUsesNode(usesBuilder);
+        }
+
+        pathToUses.add(groupingPathStr);
+        addedUsesNodes.put(pathToUses, usesBuilder);
+
+        return usesBuilder;
+    }
+
+    public RpcDefinitionBuilder addRpc(QName qname, List<String> parentPath) {
+        List<String> pathToRpc = new ArrayList<String>(parentPath);
+
+        RpcDefinitionBuilder rpcBuilder = new RpcDefinitionBuilder(qname);
+
+        pathToRpc.add(qname.getLocalName());
+        addedRpcs.put(pathToRpc, rpcBuilder);
+
+        QName inputQName = new QName(qname.getNamespace(), qname.getRevision(),
+                qname.getPrefix(), "input");
+        ContainerSchemaNodeBuilder inputBuilder = new ContainerSchemaNodeBuilder(inputQName);
+        List<String> pathToInput = new ArrayList<String>(pathToRpc);
+        pathToInput.add("input");
+        moduleNodes.put(pathToInput, inputBuilder);
+        rpcBuilder.setInput(inputBuilder);
+
+        QName outputQName = new QName(qname.getNamespace(),
+                qname.getRevision(), qname.getPrefix(), "output");
+        ContainerSchemaNodeBuilder outputBuilder = new ContainerSchemaNodeBuilder(outputQName);
+        List<String> pathToOutput = new ArrayList<String>(pathToRpc);
+        pathToOutput.add("output");
+        moduleNodes.put(pathToOutput, outputBuilder);
+        rpcBuilder.setOutput(outputBuilder);
+
+        return rpcBuilder;
+    }
+
+    public NotificationBuilder addNotification(QName notificationName,
+            List<String> parentPath) {
+        List<String> pathToNotification = new ArrayList<String>(parentPath);
+
+        NotificationBuilder notificationBuilder = new NotificationBuilder(
+                notificationName);
+
+        pathToNotification.add(notificationName.getLocalName());
+        moduleNodes.put(pathToNotification, notificationBuilder);
+        addedNotifications.add(notificationBuilder);
+
+        return notificationBuilder;
+    }
+
+    public FeatureBuilder addFeature(QName featureName, List<String> parentPath) {
+        List<String> pathToFeature = new ArrayList<String>(parentPath);
+        pathToFeature.add(featureName.getLocalName());
+
+        FeatureBuilder builder = new FeatureBuilder(featureName);
+        addedFeatures.put(pathToFeature, builder);
+        return builder;
+    }
+
+    public TypedefBuilder addTypedef(QName typeDefName, List<String> parentPath) {
+        List<String> pathToType = new ArrayList<String>(parentPath);
+        TypedefBuilder builder = new TypedefBuilder(typeDefName);
+        TypeDefinitionAwareBuilder parent = (TypeDefinitionAwareBuilder) moduleNodes.get(pathToType);
+        if (parent != null) {
+            parent.addTypedef(builder);
+        }
+        pathToType.add(typeDefName.getLocalName());
+        addedTypedefs.put(pathToType, builder);
+        moduleNodes.put(pathToType, builder);
+        return builder;
+    }
+
+    public Set<TypeDefinitionBuilder> getModuleTypedefs() {
+        Set<TypeDefinitionBuilder> typedefs = new HashSet<TypeDefinitionBuilder>();
+        for (Map.Entry<List<String>, TypeDefinitionBuilder> entry : addedTypedefs.entrySet()) {
+            if (entry.getKey().size() == 2) {
+                typedefs.add(entry.getValue());
+            }
+        }
+        return typedefs;
+    }
+
+    public void setType(TypeDefinition<?> type, List<String> parentPath) {
+        TypeAwareBuilder parent = (TypeAwareBuilder) moduleNodes.get(parentPath);
+        parent.setType(type);
+    }
+
+    public DeviationBuilder addDeviation(String targetPath) {
+        DeviationBuilder builder = new DeviationBuilder(targetPath);
+        addedDeviations.put(targetPath, builder);
+        return builder;
+    }
+
+    public void addConfiguration(boolean configuration, List<String> parentPath) {
+        Builder builder = moduleNodes.get(parentPath);
+        if (builder instanceof DeviationBuilder) {
+            // skip
+            // TODO
+        } else {
+            DataSchemaNodeBuilder configBuilder = (DataSchemaNodeBuilder) moduleNodes.get(parentPath);
+            configBuilder.setConfiguration(configuration);
+        }
+    }
+
+    public UnknownSchemaNodeBuilder addUnknownSchemaNode(QName qname, List<String> parentPath) {
+        UnknownSchemaNodeBuilder builder = new UnknownSchemaNodeBuilder(qname);
+        return builder;
+    }
+
+
+    private class ModuleImpl implements Module {
+        private URI namespace;
+        private final String name;
+        private Date revision;
+        private String prefix;
+        private String yangVersion;
+        private String description;
+        private String reference;
+        private String organization;
+        private String contact;
+        private Set<ModuleImport> imports = Collections.emptySet();
+        private Set<FeatureDefinition> features = Collections.emptySet();
+        private Set<TypeDefinition<?>> typeDefinitions = Collections.emptySet();
+        private Set<NotificationDefinition> notifications = Collections.emptySet();
+        private Set<AugmentationSchema> augmentations = Collections.emptySet();
+        private Set<RpcDefinition> rpcs = Collections.emptySet();
+        private Set<Deviation> deviations = Collections.emptySet();
+        private Map<QName, DataSchemaNode> childNodes = Collections.emptyMap();
+        private Set<GroupingDefinition> groupings = Collections.emptySet();
+        private Set<UsesNode> uses = Collections.emptySet();
+        private List<ExtensionDefinition> extensionSchemaNodes = Collections.emptyList();
+
+        private ModuleImpl(String name) {
+            this.name = name;
+        }
+
+        @Override
+        public URI getNamespace() {
+            return namespace;
+        }
+
+        private void setNamespace(URI namespace) {
+            this.namespace = namespace;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public Date getRevision() {
+            return revision;
+        }
+
+        private void setRevision(Date revision) {
+            this.revision = revision;
+        }
+
+        @Override
+        public String getPrefix() {
+            return prefix;
+        }
+
+        private void setPrefix(String prefix) {
+            this.prefix = prefix;
+        }
+
+        @Override
+        public String getYangVersion() {
+            return yangVersion;
+        }
+
+        private void setYangVersion(String yangVersion) {
+            this.yangVersion = yangVersion;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public String getOrganization() {
+            return organization;
+        }
+
+        private void setOrganization(String organization) {
+            this.organization = organization;
+        }
+
+        @Override
+        public String getContact() {
+            return contact;
+        }
+
+        private void setContact(String contact) {
+            this.contact = contact;
+        }
+
+        @Override
+        public Set<ModuleImport> getImports() {
+            return imports;
+        }
+
+        private void setImports(Set<ModuleImport> imports) {
+            this.imports = imports;
+        }
+
+        @Override
+        public Set<FeatureDefinition> getFeatures() {
+            return features;
+        }
+
+        private void setFeatures(Set<FeatureDefinition> features) {
+            this.features = features;
+        }
+
+        @Override
+        public Set<TypeDefinition<?>> getTypeDefinitions() {
+            return typeDefinitions;
+        }
+
+        private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {
+            this.typeDefinitions = typeDefinitions;
+        }
+
+        @Override
+        public Set<NotificationDefinition> getNotifications() {
+            return notifications;
+        }
+
+        private void setNotifications(Set<NotificationDefinition> notifications) {
+            this.notifications = notifications;
+        }
+
+        @Override
+        public Set<AugmentationSchema> getAugmentations() {
+            return augmentations;
+        }
+
+        private void setAugmentations(Set<AugmentationSchema> augmentations) {
+            this.augmentations = augmentations;
+        }
+
+        @Override
+        public Set<RpcDefinition> getRpcs() {
+            return rpcs;
+        }
+
+        private void setRpcs(Set<RpcDefinition> rpcs) {
+            this.rpcs = rpcs;
+        }
+
+        @Override
+        public Set<Deviation> getDeviations() {
+            return deviations;
+        }
+
+        private void setDeviations(Set<Deviation> deviations) {
+            this.deviations = deviations;
+        }
+
+        @Override
+        public Set<DataSchemaNode> getChildNodes() {
+            return new HashSet<DataSchemaNode>(childNodes.values());
+        }
+
+        private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {
+            this.childNodes = childNodes;
+        }
+
+        @Override
+        public Set<GroupingDefinition> getGroupings() {
+            return groupings;
+        }
+
+        private void setGroupings(Set<GroupingDefinition> groupings) {
+            this.groupings = groupings;
+        }
+
+        @Override
+        public Set<UsesNode> getUses() {
+            return uses;
+        }
+
+        private void setUses(Set<UsesNode> uses) {
+            this.uses = uses;
+        }
+
+        @Override
+        public List<ExtensionDefinition> getExtensionSchemaNodes() {
+            return extensionSchemaNodes;
+        }
+
+        private void setExtensionSchemaNodes(List<ExtensionDefinition> extensionSchemaNodes) {
+            if(extensionSchemaNodes != null) {
+                this.extensionSchemaNodes = extensionSchemaNodes;
+            }
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(QName name) {
+            return childNodes.get(name);
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(String name) {
+            DataSchemaNode result = null;
+            for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
+                if (entry.getKey().getLocalName().equals(name)) {
+                    result = entry.getValue();
+                    break;
+                }
+            }
+            return result;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((namespace == null) ? 0 : namespace.hashCode());
+            result = prime * result + ((name == null) ? 0 : name.hashCode());
+            result = prime * result + ((revision == null) ? 0 : revision.hashCode());
+            result = prime * result + ((prefix == null) ? 0 : prefix.hashCode());
+            result = prime * result + ((yangVersion == null) ? 0 : yangVersion.hashCode());
+            result = prime * result + ((description == null) ? 0 : description.hashCode());
+            result = prime * result + ((reference == null) ? 0 : reference.hashCode());
+
+            result = prime * result + ((organization == null) ? 0 : organization.hashCode());
+            result = prime * result + ((contact == null) ? 0 : contact.hashCode());
+            result = prime * result + ((imports == null) ? 0 : imports.hashCode());
+            result = prime * result + ((features == null) ? 0 : features.hashCode());
+            result = prime * result + ((typeDefinitions == null) ? 0 : typeDefinitions.hashCode());
+            result = prime * result + ((notifications == null) ? 0 : notifications.hashCode());
+            result = prime * result + ((augmentations == null) ? 0 : augmentations.hashCode());
+            result = prime * result + ((rpcs == null) ? 0 : rpcs.hashCode());
+            result = prime * result + ((deviations == null) ? 0 : deviations.hashCode());
+            result = prime * result + ((childNodes == null) ? 0 : childNodes.hashCode());
+            result = prime * result + ((groupings == null) ? 0 : groupings.hashCode());
+            result = prime * result + ((uses == null) ? 0 : uses.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            ModuleImpl other = (ModuleImpl) obj;
+            if (namespace == null) {
+                if (other.namespace != null) {
+                    return false;
+                }
+            } else if (!namespace.equals(other.namespace)) {
+                return false;
+            }
+            if (name == null) {
+                if (other.name != null) {
+                    return false;
+                }
+            } else if (!name.equals(other.name)) {
+                return false;
+            }
+            if (revision == null) {
+                if (other.revision != null) {
+                    return false;
+                }
+            } else if (!revision.equals(other.revision)) {
+                return false;
+            }
+            if (prefix == null) {
+                if (other.prefix != null) {
+                    return false;
+                }
+            } else if (!prefix.equals(other.prefix)) {
+                return false;
+            }
+            if (yangVersion == null) {
+                if (other.yangVersion != null) {
+                    return false;
+                }
+            } else if (!yangVersion.equals(other.yangVersion)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (organization == null) {
+                if (other.organization != null) {
+                    return false;
+                }
+            } else if (!organization.equals(other.organization)) {
+                return false;
+            }
+            if (contact == null) {
+                if (other.contact != null) {
+                    return false;
+                }
+            } else if (!contact.equals(other.contact)) {
+                return false;
+            }
+            if (imports == null) {
+                if (other.imports != null) {
+                    return false;
+                }
+            } else if (!imports.equals(other.imports)) {
+                return false;
+            }
+            if (features == null) {
+                if (other.features != null) {
+                    return false;
+                }
+            } else if (!features.equals(other.features)) {
+                return false;
+            }
+            if (typeDefinitions == null) {
+                if (other.typeDefinitions != null) {
+                    return false;
+                }
+            } else if (!typeDefinitions.equals(other.typeDefinitions)) {
+                return false;
+            }
+            if (notifications == null) {
+                if (other.notifications != null) {
+                    return false;
+                }
+            } else if (!notifications.equals(other.notifications)) {
+                return false;
+            }
+            if (augmentations == null) {
+                if (other.augmentations != null) {
+                    return false;
+                }
+            } else if (!augmentations.equals(other.augmentations)) {
+                return false;
+            }
+            if (rpcs == null) {
+                if (other.rpcs != null) {
+                    return false;
+                }
+            } else if (!rpcs.equals(other.rpcs)) {
+                return false;
+            }
+            if (deviations == null) {
+                if (other.deviations != null) {
+                    return false;
+                }
+            } else if (!deviations.equals(other.deviations)) {
+                return false;
+            }
+            if (childNodes == null) {
+                if (other.childNodes != null) {
+                    return false;
+                }
+            } else if (!childNodes.equals(other.childNodes)) {
+                return false;
+            }
+            if (groupings == null) {
+                if (other.groupings != null) {
+                    return false;
+                }
+            } else if (!groupings.equals(other.groupings)) {
+                return false;
+            }
+            if (uses == null) {
+                if (other.uses != null) {
+                    return false;
+                }
+            } else if (!uses.equals(other.uses)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    ModuleImpl.class.getSimpleName());
+            sb.append("[\n");
+            sb.append("name=" + name + ",\n");
+            sb.append("namespace=" + namespace + ",\n");
+            sb.append("revision=" + revision + ",\n");
+            sb.append("prefix=" + prefix + ",\n");
+            sb.append("yangVersion=" + yangVersion + ",\n");
+            sb.append("description=" + description + ",\n");
+            sb.append("reference=" + reference + ",\n");
+            sb.append("organization=" + organization + ",\n");
+            sb.append("contact=" + contact + ",\n");
+            sb.append("childNodes=" + childNodes.values() + ",\n");
+            sb.append("groupings=" + groupings + ",\n");
+            sb.append("imports=" + imports + ",\n");
+            sb.append("features=" + features + ",\n");
+            sb.append("typeDefinitions=" + typeDefinitions + ",\n");
+            sb.append("notifications=" + notifications + ",\n");
+            sb.append("augmentations=" + augmentations + ",\n");
+            sb.append("rpcs=" + rpcs + ",\n");
+            sb.append("deviations=" + deviations + "\n");
+            sb.append("uses=" + uses + "\n");
+            sb.append("]");
+            return sb.toString();
+        }
+    }
+
+    private ModuleImport createModuleImport(final String moduleName,
+            final Date revision, final String prefix) {
+        ModuleImport moduleImport = new ModuleImport() {
+            @Override
+            public String getModuleName() {
+                return moduleName;
+            }
+
+            @Override
+            public Date getRevision() {
+                return revision;
+            }
+
+            @Override
+            public String getPrefix() {
+                return prefix;
+            }
+
+            @Override
+            public int hashCode() {
+                final int prime = 31;
+                int result = 1;
+                result = prime * result
+                        + ((moduleName == null) ? 0 : moduleName.hashCode());
+                result = prime * result
+                        + ((revision == null) ? 0 : revision.hashCode());
+                result = prime * result
+                        + ((prefix == null) ? 0 : prefix.hashCode());
+                return result;
+            }
+
+            @Override
+            public boolean equals(Object obj) {
+                if (this == obj) {
+                    return true;
+                }
+                if (obj == null) {
+                    return false;
+                }
+                if (getClass() != obj.getClass()) {
+                    return false;
+                }
+                ModuleImport other = (ModuleImport) obj;
+                if (getModuleName() == null) {
+                    if (other.getModuleName() != null) {
+                        return false;
+                    }
+                } else if (!getModuleName().equals(other.getModuleName())) {
+                    return false;
+                }
+                if (getRevision() == null) {
+                    if (other.getRevision() != null) {
+                        return false;
+                    }
+                } else if (!getRevision().equals(other.getRevision())) {
+                    return false;
+                }
+                if (getPrefix() == null) {
+                    if (other.getPrefix() != null) {
+                        return false;
+                    }
+                } else if (!getPrefix().equals(other.getPrefix())) {
+                    return false;
+                }
+                return true;
+            }
+
+            @Override
+            public String toString() {
+                return "ModuleImport[moduleName=" + moduleName + ", revision="
+                        + revision + ", prefix=" + prefix + "]";
+            }
+        };
+        return moduleImport;
+    }
+
+    /**
+     * Traverse through given addedChilds and add only direct module childs.
+     * Direct module child path size is 2 (1. module name, 2. child name).
+     *
+     * @param addedChilds
+     * @return map of children, where key is child QName and value is child
+     *         itself
+     */
+    private Map<QName, DataSchemaNode> buildModuleChildNodes(
+            Map<List<String>, DataSchemaNodeBuilder> addedChilds) {
+        final Map<QName, DataSchemaNode> childNodes = new HashMap<QName, DataSchemaNode>();
+        for (Map.Entry<List<String>, DataSchemaNodeBuilder> entry : addedChilds
+                .entrySet()) {
+            if (entry.getKey().size() == 2) {
+                DataSchemaNode node = entry.getValue().build();
+                QName qname = entry.getValue().getQName();
+                childNodes.put(qname, node);
+            }
+        }
+        return childNodes;
+    }
+
+    /**
+     * Traverse through given addedGroupings and add only direct module
+     * groupings. Direct module grouping path size is 2 (1. module name, 2.
+     * grouping name).
+     *
+     * @param addedGroupings
+     * @return set of built GroupingDefinition objects
+     */
+    private Set<GroupingDefinition> buildModuleGroupings(
+            Map<List<String>, GroupingBuilder> addedGroupings) {
+        final Set<GroupingDefinition> groupings = new HashSet<GroupingDefinition>();
+        for (Map.Entry<List<String>, GroupingBuilder> entry : addedGroupings
+                .entrySet()) {
+            if (entry.getKey().size() == 2) {
+                groupings.add(entry.getValue().build());
+            }
+        }
+        return groupings;
+    }
+
+    /**
+     * Traverse through given addedRpcs and build RpcDefinition objects.
+     *
+     * @param addedRpcs
+     * @return set of built RpcDefinition objects
+     */
+    private Set<RpcDefinition> buildModuleRpcs(
+            Map<List<String>, RpcDefinitionBuilder> addedRpcs) {
+        final Set<RpcDefinition> rpcs = new HashSet<RpcDefinition>();
+        RpcDefinitionBuilder builder;
+        for (Map.Entry<List<String>, RpcDefinitionBuilder> entry : addedRpcs
+                .entrySet()) {
+            builder = entry.getValue();
+            RpcDefinition rpc = builder.build();
+            rpcs.add(rpc);
+        }
+        return rpcs;
+    }
+
+    /**
+     * Traverse through given addedTypedefs and add only direct module typedef
+     * statements. Direct module typedef path size is 2 (1. module name, 2.
+     * typedef name).
+     *
+     * @param addedTypedefs
+     * @return set of built module typedef statements
+     */
+    private Set<TypeDefinition<?>> buildModuleTypedefs(
+            Map<List<String>, TypeDefinitionBuilder> addedTypedefs) {
+        Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();
+        for (Map.Entry<List<String>, TypeDefinitionBuilder> entry : addedTypedefs
+                .entrySet()) {
+            if (entry.getKey().size() == 2) {
+                TypeDefinition<? extends TypeDefinition<?>> node = entry
+                        .getValue().build();
+                typedefs.add(node);
+            }
+        }
+        return typedefs;
+    }
+
+    /**
+     * Traverse through given addedUsesNodes and add only direct module uses
+     * nodes. Direct module uses node path size is 2 (1. module name, 2. uses
+     * name).
+     *
+     * @param addedUsesNodes
+     * @return set of built module uses nodes
+     */
+    private Set<UsesNode> buildUsesNodes(
+            Map<List<String>, UsesNodeBuilder> addedUsesNodes) {
+        final Set<UsesNode> usesNodeDefinitions = new HashSet<UsesNode>();
+        for (Map.Entry<List<String>, UsesNodeBuilder> entry : addedUsesNodes
+                .entrySet()) {
+            if (entry.getKey().size() == 2) {
+                usesNodeDefinitions.add(entry.getValue().build());
+            }
+        }
+        return usesNodeDefinitions;
+    }
+
+    /**
+     * Traverse through given addedFeatures and add only direct module features.
+     * Direct module feature path size is 2 (1. module name, 2. feature name).
+     *
+     * @param addedFeatures
+     * @return set of built module features
+     */
+    private Set<FeatureDefinition> buildModuleFeatures(
+            Map<List<String>, FeatureBuilder> addedFeatures) {
+        Set<FeatureDefinition> features = new HashSet<FeatureDefinition>();
+        for (Map.Entry<List<String>, FeatureBuilder> entry : addedFeatures
+                .entrySet()) {
+            if (entry.getKey().size() == 2) {
+                features.add(entry.getValue().build());
+            }
+        }
+        return features;
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/NotificationBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/NotificationBuilder.java
new file mode 100644 (file)
index 0000000..783b21e
--- /dev/null
@@ -0,0 +1,343 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.NotificationDefinition;
+import org.opendaylight.controller.yang.model.api.SchemaNode;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.api.UsesNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.AbstractChildNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionAwareBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+
+public class NotificationBuilder extends AbstractChildNodeBuilder implements
+        TypeDefinitionAwareBuilder, SchemaNodeBuilder {
+
+    private final NotificationDefinitionImpl instance;
+    private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
+    private final Set<UsesNodeBuilder> addedUsesNodes = new HashSet<UsesNodeBuilder>();
+
+    NotificationBuilder(QName qname) {
+        super(qname);
+        instance = new NotificationDefinitionImpl(qname);
+    }
+
+    @Override
+    public SchemaNode build() {
+        // CHILD NODES
+        Map<QName, DataSchemaNode> childs = new HashMap<QName, DataSchemaNode>();
+        for (DataSchemaNodeBuilder node : childNodes) {
+            childs.put(node.getQName(), node.build());
+        }
+        instance.setChildNodes(childs);
+
+        // GROUPINGS
+        Set<GroupingDefinition> groupingDefinitions = new HashSet<GroupingDefinition>();
+        for (GroupingBuilder builder : groupings) {
+            groupingDefinitions.add(builder.build());
+        }
+        instance.setGroupings(groupingDefinitions);
+
+        // TYPEDEFS
+        Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();
+        for (TypeDefinitionBuilder entry : addedTypedefs) {
+            typedefs.add(entry.build());
+        }
+        instance.setTypeDefinitions(typedefs);
+
+        // USES
+        Set<UsesNode> uses = new HashSet<UsesNode>();
+        for (UsesNodeBuilder builder : addedUsesNodes) {
+            uses.add(builder.build());
+        }
+        instance.setUses(uses);
+
+        return instance;
+    }
+
+    @Override
+    public void addTypedef(TypeDefinitionBuilder type) {
+        addedTypedefs.add(type);
+    }
+
+    @Override
+    public void addUsesNode(UsesNodeBuilder usesNodeBuilder) {
+        addedUsesNodes.add(usesNodeBuilder);
+    }
+
+    @Override
+    public void setPath(SchemaPath schemaPath) {
+        instance.setPath(schemaPath);
+    }
+
+    @Override
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    @Override
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    @Override
+    public void setStatus(Status status) {
+        instance.setStatus(status);
+    }
+
+    private class NotificationDefinitionImpl implements NotificationDefinition {
+
+        private final QName qname;
+        private SchemaPath path;
+        private String description;
+        private String reference;
+        private Status status;
+        private Map<QName, DataSchemaNode> childNodes = Collections.emptyMap();
+        private Set<GroupingDefinition> groupings = Collections.emptySet();
+        private Set<TypeDefinition<?>> typeDefinitions = Collections.emptySet();
+        private Set<UsesNode> uses = Collections.emptySet();
+        private List<UnknownSchemaNode> unknownSchemaNodes = Collections.emptyList();
+
+        private NotificationDefinitionImpl(QName qname) {
+            this.qname = qname;
+        }
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return path;
+        }
+
+        private void setPath(SchemaPath path) {
+            this.path = path;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            this.status = status;
+        }
+
+        @Override
+        public Set<DataSchemaNode> getChildNodes() {
+            return new HashSet<DataSchemaNode>(childNodes.values());
+        }
+
+        private void setChildNodes(Map<QName, DataSchemaNode> childNodes) {
+            if(childNodes != null) {
+                this.childNodes = childNodes;
+            }
+        }
+
+        @Override
+        public Set<GroupingDefinition> getGroupings() {
+            return groupings;
+        }
+
+        private void setGroupings(Set<GroupingDefinition> groupings) {
+            if(groupings != null) {
+                this.groupings = groupings;
+            }
+        }
+
+        @Override
+        public Set<UsesNode> getUses() {
+            return uses;
+        }
+
+        private void setUses(Set<UsesNode> uses) {
+            if(uses != null) {
+                this.uses = uses;
+            }
+        }
+
+        @Override
+        public Set<TypeDefinition<?>> getTypeDefinitions() {
+            return typeDefinitions;
+        }
+
+        private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {
+            if(typeDefinitions != null) {
+                this.typeDefinitions = typeDefinitions;
+            }
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return unknownSchemaNodes;
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(QName name) {
+            return childNodes.get(name);
+        }
+
+        @Override
+        public DataSchemaNode getDataChildByName(String name) {
+            DataSchemaNode result = null;
+            for (Map.Entry<QName, DataSchemaNode> entry : childNodes.entrySet()) {
+                if (entry.getKey().getLocalName().equals(name)) {
+                    result = entry.getValue();
+                    break;
+                }
+            }
+            return result;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result + ((path == null) ? 0 : path.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result
+                    + ((status == null) ? 0 : status.hashCode());
+            result = prime * result
+                    + ((childNodes == null) ? 0 : childNodes.hashCode());
+            result = prime * result
+                    + ((groupings == null) ? 0 : groupings.hashCode());
+            result = prime * result
+                    + ((typeDefinitions == null) ? 0 : typeDefinitions.hashCode());
+            result = prime * result + ((uses == null) ? 0 : uses.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            NotificationDefinitionImpl other = (NotificationDefinitionImpl) obj;
+            if (qname == null) {
+                if (other.qname != null) {
+                    return false;
+                }
+            } else if (!qname.equals(other.qname)) {
+                return false;
+            }
+            if (path == null) {
+                if (other.path != null) {
+                    return false;
+                }
+            } else if (!path.equals(other.path)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (status == null) {
+                if (other.status != null) {
+                    return false;
+                }
+            } else if (!status.equals(other.status)) {
+                return false;
+            }
+            if (childNodes == null) {
+                if (other.childNodes != null) {
+                    return false;
+                }
+            } else if (!childNodes.equals(other.childNodes)) {
+                return false;
+            }
+            if (groupings == null) {
+                if (other.groupings != null) {
+                    return false;
+                }
+            } else if (!groupings.equals(other.groupings)) {
+                return false;
+            }
+            if (typeDefinitions == null) {
+                if (other.typeDefinitions != null) {
+                    return false;
+                }
+            } else if (!typeDefinitions.equals(other.typeDefinitions)) {
+                return false;
+            }
+            if (uses == null) {
+                if (other.uses != null) {
+                    return false;
+                }
+            } else if (!uses.equals(other.uses)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    NotificationDefinitionImpl.class.getSimpleName());
+            sb.append("[qname=" + qname + "]");
+            return sb.toString();
+        }
+    }
+
+}
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.model.parser.api.ChildNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.DataSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.api.SchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionAwareBuilder;\r
-import org.opendaylight.controller.model.parser.api.TypeDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.controller.yang.model.api.RpcDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-\r
-public class RpcDefinitionBuilder implements ChildNodeBuilder,\r
-        SchemaNodeBuilder, TypeDefinitionAwareBuilder {\r
-\r
-    private final RpcDefinitionImpl instance;\r
-    private final QName qname;\r
-    private ContainerSchemaNodeBuilder inputBuilder;\r
-    private ContainerSchemaNodeBuilder outputBuilder;\r
-    private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();\r
-    private final Set<GroupingBuilder> addedGroupings = new HashSet<GroupingBuilder>();\r
-\r
-    RpcDefinitionBuilder(QName qname) {\r
-        this.qname = qname;\r
-        this.instance = new RpcDefinitionImpl(qname);\r
-    }\r
-\r
-    @Override\r
-    public RpcDefinition build() {\r
-        final ContainerSchemaNode input = inputBuilder.build();\r
-        final ContainerSchemaNode output = outputBuilder.build();\r
-        instance.setInput(input);\r
-        instance.setOutput(output);\r
-\r
-        // TYPEDEFS\r
-        Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();\r
-        for (TypeDefinitionBuilder entry : addedTypedefs) {\r
-            typedefs.add(entry.build());\r
-        }\r
-        instance.setTypeDefinitions(typedefs);\r
-\r
-        // GROUPINGS\r
-        final Set<GroupingDefinition> groupings = new HashSet<GroupingDefinition>();\r
-        for (GroupingBuilder entry : addedGroupings) {\r
-            groupings.add(entry.build());\r
-        }\r
-        instance.setGroupings(groupings);\r
-\r
-        return instance;\r
-    }\r
-\r
-    void setInput(ContainerSchemaNodeBuilder inputBuilder) {\r
-        this.inputBuilder = inputBuilder;\r
-    }\r
-\r
-    void setOutput(ContainerSchemaNodeBuilder outputBuilder) {\r
-        this.outputBuilder = outputBuilder;\r
-    }\r
-\r
-    @Override\r
-    public void addTypedef(TypeDefinitionBuilder type) {\r
-        addedTypedefs.add(type);\r
-    }\r
-\r
-    @Override\r
-    public void setPath(SchemaPath schemaPath) {\r
-        instance.setPath(schemaPath);\r
-    }\r
-\r
-    @Override\r
-    public void setDescription(String description) {\r
-        instance.setDescription(description);\r
-    }\r
-\r
-    @Override\r
-    public void setReference(String reference) {\r
-        instance.setReference(reference);\r
-    }\r
-\r
-    @Override\r
-    public void setStatus(Status status) {\r
-        instance.setStatus(status);\r
-    }\r
-\r
-    @Override\r
-    public QName getQName() {\r
-        return null;\r
-    }\r
-\r
-    @Override\r
-    public void addChildNode(DataSchemaNodeBuilder childNode) {\r
-        throw new UnsupportedOperationException(\r
-                "Can not add child node to rpc definition: rpc can not contains child nodes.");\r
-    }\r
-\r
-    @Override\r
-    public void addGrouping(GroupingBuilder grouping) {\r
-        addedGroupings.add(grouping);\r
-    }\r
-\r
-    @Override\r
-    public void addUsesNode(UsesNodeBuilder usesBuilder) {\r
-        throw new UnsupportedOperationException(\r
-                "Can not add uses node to rpc definition: rpc can not contains uses nodes.");\r
-    }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        return qname.hashCode();\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (obj == null) {\r
-            return false;\r
-        }\r
-        if (!(obj instanceof RpcDefinitionBuilder)) {\r
-            return false;\r
-        }\r
-        RpcDefinitionBuilder other = (RpcDefinitionBuilder) obj;\r
-        if (other.qname == null) {\r
-            if (this.qname != null) {\r
-                return false;\r
-            }\r
-        } else if (!other.qname.equals(this.qname)) {\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
-    private static class RpcDefinitionImpl implements RpcDefinition {\r
-\r
-        private final QName qname;\r
-        private SchemaPath path;\r
-        private String description;\r
-        private String reference;\r
-        private Status status;\r
-\r
-        private ContainerSchemaNode input;\r
-        private ContainerSchemaNode output;\r
-\r
-        private Set<TypeDefinition<?>> typeDefinitions;\r
-        private Set<GroupingDefinition> groupings;\r
-\r
-        private RpcDefinitionImpl(QName qname) {\r
-            this.qname = qname;\r
-        }\r
-\r
-        @Override\r
-        public QName getQName() {\r
-            return qname;\r
-        }\r
-\r
-        @Override\r
-        public SchemaPath getPath() {\r
-            return path;\r
-        }\r
-\r
-        private void setPath(SchemaPath path) {\r
-            this.path = path;\r
-        }\r
-\r
-        @Override\r
-        public String getDescription() {\r
-            return description;\r
-        }\r
-\r
-        private void setDescription(String description) {\r
-            this.description = description;\r
-        }\r
-\r
-        @Override\r
-        public String getReference() {\r
-            return reference;\r
-        }\r
-\r
-        private void setReference(String reference) {\r
-            this.reference = reference;\r
-        }\r
-\r
-        @Override\r
-        public Status getStatus() {\r
-            return status;\r
-        }\r
-\r
-        private void setStatus(Status status) {\r
-            this.status = status;\r
-        }\r
-\r
-        @Override\r
-        public ContainerSchemaNode getInput() {\r
-            return input;\r
-        }\r
-\r
-        private void setInput(ContainerSchemaNode input) {\r
-            this.input = input;\r
-        }\r
-\r
-        @Override\r
-        public ContainerSchemaNode getOutput() {\r
-            return output;\r
-        }\r
-\r
-        private void setOutput(ContainerSchemaNode output) {\r
-            this.output = output;\r
-        }\r
-\r
-        @Override\r
-        public Set<TypeDefinition<?>> getTypeDefinitions() {\r
-            return typeDefinitions;\r
-        }\r
-\r
-        private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {\r
-            this.typeDefinitions = typeDefinitions;\r
-        }\r
-\r
-        @Override\r
-        public Set<GroupingDefinition> getGroupings() {\r
-            return groupings;\r
-        }\r
-\r
-        private void setGroupings(Set<GroupingDefinition> groupings) {\r
-            this.groupings = groupings;\r
-        }\r
-\r
-        @Override\r
-        public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-            // TODO Auto-generated method stub\r
-            return null;\r
-        }\r
-\r
-        @Override\r
-        public String toString() {\r
-            StringBuilder sb = new StringBuilder(\r
-                    RpcDefinitionImpl.class.getSimpleName() + "[");\r
-            sb.append("qname=" + qname);\r
-            sb.append(", path=" + path);\r
-            sb.append(", description=" + description);\r
-            sb.append(", reference=" + reference);\r
-            sb.append(", status=" + status);\r
-            sb.append(", input=" + input);\r
-            sb.append(", output=" + output + "]");\r
-            return sb.toString();\r
-        }\r
-    }\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.RpcDefinition;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.ChildNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionAwareBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+
+public class RpcDefinitionBuilder implements ChildNodeBuilder,
+        SchemaNodeBuilder, TypeDefinitionAwareBuilder {
+
+    private final RpcDefinitionImpl instance;
+    private final QName qname;
+    private ContainerSchemaNodeBuilder inputBuilder;
+    private ContainerSchemaNodeBuilder outputBuilder;
+    private final Set<TypeDefinitionBuilder> addedTypedefs = new HashSet<TypeDefinitionBuilder>();
+    private final Set<GroupingBuilder> addedGroupings = new HashSet<GroupingBuilder>();
+
+    RpcDefinitionBuilder(QName qname) {
+        this.qname = qname;
+        this.instance = new RpcDefinitionImpl(qname);
+    }
+
+    @Override
+    public RpcDefinition build() {
+        final ContainerSchemaNode input = inputBuilder.build();
+        final ContainerSchemaNode output = outputBuilder.build();
+        instance.setInput(input);
+        instance.setOutput(output);
+
+        // TYPEDEFS
+        Set<TypeDefinition<?>> typedefs = new HashSet<TypeDefinition<?>>();
+        for (TypeDefinitionBuilder entry : addedTypedefs) {
+            typedefs.add(entry.build());
+        }
+        instance.setTypeDefinitions(typedefs);
+
+        // GROUPINGS
+        final Set<GroupingDefinition> groupings = new HashSet<GroupingDefinition>();
+        for (GroupingBuilder entry : addedGroupings) {
+            groupings.add(entry.build());
+        }
+        instance.setGroupings(groupings);
+
+        return instance;
+    }
+
+    void setInput(ContainerSchemaNodeBuilder inputBuilder) {
+        this.inputBuilder = inputBuilder;
+    }
+
+    void setOutput(ContainerSchemaNodeBuilder outputBuilder) {
+        this.outputBuilder = outputBuilder;
+    }
+
+    @Override
+    public void addTypedef(TypeDefinitionBuilder type) {
+        addedTypedefs.add(type);
+    }
+
+    @Override
+    public void setPath(SchemaPath schemaPath) {
+        instance.setPath(schemaPath);
+    }
+
+    @Override
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    @Override
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    @Override
+    public void setStatus(Status status) {
+        instance.setStatus(status);
+    }
+
+    @Override
+    public QName getQName() {
+        return null;
+    }
+
+    @Override
+    public void addChildNode(DataSchemaNodeBuilder childNode) {
+        throw new UnsupportedOperationException(
+                "Can not add child node to rpc definition: rpc can not contains child nodes.");
+    }
+
+    @Override
+    public void addGrouping(GroupingBuilder grouping) {
+        addedGroupings.add(grouping);
+    }
+
+    @Override
+    public void addUsesNode(UsesNodeBuilder usesBuilder) {
+        throw new UnsupportedOperationException(
+                "Can not add uses node to rpc definition: rpc can not contains uses nodes.");
+    }
+
+    @Override
+    public int hashCode() {
+        return qname.hashCode();
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (obj == null) {
+            return false;
+        }
+        if (!(obj instanceof RpcDefinitionBuilder)) {
+            return false;
+        }
+        RpcDefinitionBuilder other = (RpcDefinitionBuilder) obj;
+        if (other.qname == null) {
+            if (this.qname != null) {
+                return false;
+            }
+        } else if (!other.qname.equals(this.qname)) {
+            return false;
+        }
+        return true;
+    }
+
+    private static class RpcDefinitionImpl implements RpcDefinition {
+
+        private final QName qname;
+        private SchemaPath path;
+        private String description;
+        private String reference;
+        private Status status;
+        private ContainerSchemaNode input;
+        private ContainerSchemaNode output;
+        private Set<TypeDefinition<?>> typeDefinitions;
+        private Set<GroupingDefinition> groupings;
+        private List<UnknownSchemaNode> unknownSchemaNodes = Collections.emptyList();
+
+        private RpcDefinitionImpl(QName qname) {
+            this.qname = qname;
+        }
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return path;
+        }
+
+        private void setPath(SchemaPath path) {
+            this.path = path;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            this.status = status;
+        }
+
+        @Override
+        public ContainerSchemaNode getInput() {
+            return input;
+        }
+
+        private void setInput(ContainerSchemaNode input) {
+            this.input = input;
+        }
+
+        @Override
+        public ContainerSchemaNode getOutput() {
+            return output;
+        }
+
+        private void setOutput(ContainerSchemaNode output) {
+            this.output = output;
+        }
+
+        @Override
+        public Set<TypeDefinition<?>> getTypeDefinitions() {
+            return typeDefinitions;
+        }
+
+        private void setTypeDefinitions(Set<TypeDefinition<?>> typeDefinitions) {
+            this.typeDefinitions = typeDefinitions;
+        }
+
+        @Override
+        public Set<GroupingDefinition> getGroupings() {
+            return groupings;
+        }
+
+        private void setGroupings(Set<GroupingDefinition> groupings) {
+            this.groupings = groupings;
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return unknownSchemaNodes;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result + ((path == null) ? 0 : path.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result
+                    + ((status == null) ? 0 : status.hashCode());
+            result = prime * result
+                    + ((input == null) ? 0 : input.hashCode());
+            result = prime * result
+                    + ((output == null) ? 0 : output.hashCode());
+            result = prime * result
+                    + ((typeDefinitions == null) ? 0 : typeDefinitions.hashCode());
+            result = prime * result
+                    + ((groupings == null) ? 0 : groupings.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            RpcDefinitionImpl other = (RpcDefinitionImpl) obj;
+            if (qname == null) {
+                if (other.qname != null) {
+                    return false;
+                }
+            } else if (!qname.equals(other.qname)) {
+                return false;
+            }
+            if (path == null) {
+                if (other.path != null) {
+                    return false;
+                }
+            } else if (!path.equals(other.path)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (status == null) {
+                if (other.status != null) {
+                    return false;
+                }
+            } else if (!status.equals(other.status)) {
+                return false;
+            }
+            if (input == null) {
+                if (other.input != null) {
+                    return false;
+                }
+            } else if (!input.equals(other.input)) {
+                return false;
+            }
+            if (output == null) {
+                if (other.output != null) {
+                    return false;
+                }
+            } else if (!output.equals(other.output)) {
+                return false;
+            }
+            if (typeDefinitions == null) {
+                if (other.typeDefinitions != null) {
+                    return false;
+                }
+            } else if (!typeDefinitions.equals(other.typeDefinitions)) {
+                return false;
+            }
+            if (groupings == null) {
+                if (other.groupings != null) {
+                    return false;
+                }
+            } else if (!groupings.equals(other.groupings)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    RpcDefinitionImpl.class.getSimpleName() + "[");
+            sb.append("qname=" + qname);
+            sb.append(", path=" + path);
+            sb.append(", description=" + description);
+            sb.append(", reference=" + reference);
+            sb.append(", status=" + status);
+            sb.append(", input=" + input);
+            sb.append(", output=" + output + "]");
+            return sb.toString();
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/TypedefBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/TypedefBuilder.java
new file mode 100644 (file)
index 0000000..1a2c43d
--- /dev/null
@@ -0,0 +1,297 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.model.util.UnknownType;
+import org.opendaylight.controller.model.util.YangTypesConverter;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeAwareBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
+
+public class TypedefBuilder implements TypeDefinitionBuilder,
+        SchemaNodeBuilder, TypeAwareBuilder {
+
+    private final QName qname;
+    private SchemaPath schemaPath;
+    private TypeDefinition<?> baseType;
+
+    private String description;
+    private String reference;
+    private Status status;
+    private String units;
+
+    TypedefBuilder(QName qname) {
+        this.qname = qname;
+    }
+
+    @Override
+    public TypeDefinition<? extends TypeDefinition<?>> build() {
+        final TypeDefinition<?> type = YangTypesConverter
+                .javaTypeForBaseYangType(qname);
+        if (type != null) {
+            return type;
+        } else {
+            if (baseType != null) {
+                // typedef
+                TypeDefinitionImpl instance = new TypeDefinitionImpl(qname);
+                instance.setDescription(description);
+                instance.setReference(reference);
+                instance.setStatus(status);
+                instance.setPath(schemaPath);
+                instance.setBaseType(baseType);
+                instance.setUnits(units);
+                return instance;
+            } else {
+                // type
+                final UnknownType.Builder unknownBuilder = new UnknownType.Builder(
+                        qname, description, reference);
+                unknownBuilder.status(status);
+                return unknownBuilder.build();
+            }
+        }
+    }
+
+    @Override
+    public QName getQName() {
+        return qname;
+    }
+
+    @Override
+    public void setPath(final SchemaPath schemaPath) {
+        this.schemaPath = schemaPath;
+    }
+
+    @Override
+    public void setDescription(final String description) {
+        this.description = description;
+    }
+
+    @Override
+    public void setReference(final String reference) {
+        this.reference = reference;
+    }
+
+    @Override
+    public void setStatus(final Status status) {
+        if (status != null) {
+            this.status = status;
+        }
+    }
+
+    @Override
+    public void setUnits(String units) {
+        this.units = units;
+    }
+
+    @Override
+    public TypeDefinition<?> getType() {
+        return baseType;
+    }
+
+    @Override
+    public void setType(TypeDefinition<?> baseType) {
+        this.baseType = baseType;
+    }
+
+    @Override
+    public TypeDefinition<?> getBaseType() {
+        return baseType;
+    }
+
+    private static class TypeDefinitionImpl<T extends TypeDefinition<T>>
+            implements TypeDefinition<T> {
+
+        private final QName qname;
+        private SchemaPath path;
+        private String description;
+        private String reference;
+        private Status status = Status.CURRENT;
+        private T baseType;
+        private String units;
+        private List<UnknownSchemaNode> unknownSchemaNodes = Collections.emptyList();
+
+        private TypeDefinitionImpl(QName qname) {
+            this.qname = qname;
+        }
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return path;
+        }
+
+        private void setPath(SchemaPath path) {
+            this.path = path;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            this.status = status;
+        }
+
+        @Override
+        public T getBaseType() {
+            return baseType;
+        }
+
+        private void setBaseType(T type) {
+            this.baseType = type;
+        }
+
+        @Override
+        public String getUnits() {
+            return units;
+        }
+
+        private void setUnits(String units) {
+            this.units = units;
+        }
+
+        @Override
+        public Object getDefaultValue() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return unknownSchemaNodes;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result + ((path == null) ? 0 : path.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result
+                    + ((status == null) ? 0 : status.hashCode());
+            result = prime * result
+                    + ((baseType == null) ? 0 : baseType.hashCode());
+            result = prime * result + ((units == null) ? 0 : units.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            TypeDefinitionImpl other = (TypeDefinitionImpl) obj;
+            if (qname == null) {
+                if (other.qname != null) {
+                    return false;
+                }
+            } else if (!qname.equals(other.qname)) {
+                return false;
+            }
+            if (path == null) {
+                if (other.path != null) {
+                    return false;
+                }
+            } else if (!path.equals(other.path)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (status == null) {
+                if (other.status != null) {
+                    return false;
+                }
+            } else if (!status.equals(other.status)) {
+                return false;
+            }
+            if (baseType == null) {
+                if (other.baseType != null) {
+                    return false;
+                }
+            } else if (!baseType.equals(other.baseType)) {
+                return false;
+            }
+            if (units == null) {
+                if (other.units != null) {
+                    return false;
+                }
+            } else if (!units.equals(other.units)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            final StringBuilder sb = new StringBuilder(
+                    TypeDefinitionImpl.class.getSimpleName());
+            sb.append("[");
+            sb.append("qname=" + qname);
+            sb.append(", path=" + path);
+            sb.append(", description=" + description);
+            sb.append(", reference=" + reference);
+            sb.append(", status=" + status);
+            sb.append(", baseType=" + baseType + "]");
+            return sb.toString();
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UnknownSchemaNodeBuilder.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UnknownSchemaNodeBuilder.java
new file mode 100644 (file)
index 0000000..d0bb01c
--- /dev/null
@@ -0,0 +1,126 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
+
+public class UnknownSchemaNodeBuilder implements SchemaNodeBuilder {
+
+    private final QName qname;
+    private final UnknownSchemaNodeImpl instance;
+
+    UnknownSchemaNodeBuilder(final QName qname) {
+        this.qname = qname;
+        instance = new UnknownSchemaNodeImpl(qname);
+    }
+
+
+    @Override
+    public UnknownSchemaNode build() {
+        return instance;
+    }
+
+    @Override
+    public QName getQName() {
+        return qname;
+    }
+
+    @Override
+    public void setPath(SchemaPath schemaPath) {
+        instance.setPath(schemaPath);
+    }
+
+    @Override
+    public void setDescription(String description) {
+        instance.setDescription(description);
+    }
+
+    @Override
+    public void setReference(String reference) {
+        instance.setReference(reference);
+    }
+
+    @Override
+    public void setStatus(Status status) {
+        instance.setStatus(status);
+    }
+
+    private static class UnknownSchemaNodeImpl implements UnknownSchemaNode {
+        private final QName qname;
+        private SchemaPath path;
+        private String description;
+        private String reference;
+        private Status status = Status.CURRENT;
+        private List<UnknownSchemaNode> unknownSchemaNodes = Collections.emptyList();
+
+        private UnknownSchemaNodeImpl(QName qname) {
+            this.qname = qname;
+        }
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return path;
+        }
+        private void setPath(SchemaPath path) {
+            this.path = path;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        private void setDescription(String description) {
+            this.description = description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        private void setReference(String reference) {
+            this.reference = reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        private void setStatus(Status status) {
+            if(status != null) {
+                this.status = status;
+            }
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return unknownSchemaNodes;
+        }
+
+        private void setUnknownSchemaNodes(List<UnknownSchemaNode> unknownSchemaNodes) {
+            if(unknownSchemaNodes != null) {
+                this.unknownSchemaNodes = unknownSchemaNodes;
+            }
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UsesNodeBuilderImpl.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/builder/impl/UsesNodeBuilderImpl.java
new file mode 100644 (file)
index 0000000..2096c3b
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.UsesNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationSchemaBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.Builder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+
+public class UsesNodeBuilderImpl implements UsesNodeBuilder, Builder {
+
+    private final UsesNodeImpl instance;
+    private final Set<AugmentationSchemaBuilder> addedAugments = new HashSet<AugmentationSchemaBuilder>();
+
+    UsesNodeBuilderImpl(String groupingPathStr) {
+        SchemaPath groupingPath = parseUsesPath(groupingPathStr);
+        instance = new UsesNodeImpl(groupingPath);
+    }
+
+    @Override
+    public UsesNode build() {
+        // AUGMENTATIONS
+        final Set<AugmentationSchema> augments = new HashSet<AugmentationSchema>();
+        for (AugmentationSchemaBuilder builder : addedAugments) {
+            augments.add(builder.build());
+        }
+        instance.setAugmentations(augments);
+
+        return instance;
+    }
+
+    @Override
+    public void addAugment(AugmentationSchemaBuilder augmentBuilder) {
+        addedAugments.add(augmentBuilder);
+    }
+
+    @Override
+    public void setAugmenting(boolean augmenting) {
+        instance.setAugmenting(augmenting);
+    }
+
+    private SchemaPath parseUsesPath(String augmentPath) {
+        String[] splittedPath = augmentPath.split("/");
+        List<QName> path = new ArrayList<QName>();
+        QName name;
+        for (String pathElement : splittedPath) {
+            String[] splittedElement = pathElement.split(":");
+            if (splittedElement.length == 1) {
+                name = new QName(null, null, null, splittedElement[0]);
+            } else {
+                name = new QName(null, null, splittedElement[0],
+                        splittedElement[1]);
+            }
+            path.add(name);
+        }
+        final boolean absolute = augmentPath.startsWith("/");
+        return new SchemaPath(path, absolute);
+    }
+
+    private static class UsesNodeImpl implements UsesNode {
+
+        private final SchemaPath groupingPath;
+        private Set<AugmentationSchema> augmentations = Collections.emptySet();
+        private boolean augmenting;
+
+        private UsesNodeImpl(SchemaPath groupingPath) {
+            this.groupingPath = groupingPath;
+        }
+
+        @Override
+        public SchemaPath getGroupingPath() {
+            return groupingPath;
+        }
+
+        @Override
+        public Set<AugmentationSchema> getAugmentations() {
+            return augmentations;
+        }
+
+        private void setAugmentations(Set<AugmentationSchema> augmentations) {
+            if (augmentations != null) {
+                this.augmentations = augmentations;
+            }
+        }
+
+        @Override
+        public boolean isAugmenting() {
+            return augmenting;
+        }
+
+        private void setAugmenting(boolean augmenting) {
+            this.augmenting = augmenting;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((groupingPath == null) ? 0 : groupingPath.hashCode());
+            result = prime * result + ((augmentations == null) ? 0 : augmentations.hashCode());
+            result = prime * result + (augmenting ? 1231 : 1237);
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            UsesNodeImpl other = (UsesNodeImpl) obj;
+            if (groupingPath == null) {
+                if (other.groupingPath != null) {
+                    return false;
+                }
+            } else if (!groupingPath.equals(other.groupingPath)) {
+                return false;
+            }
+            if (augmentations == null) {
+                if (other.augmentations != null) {
+                    return false;
+                }
+            } else if (!augmentations.equals(other.augmentations)) {
+                return false;
+            }
+            if (augmenting != other.augmenting) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            StringBuilder sb = new StringBuilder(
+                    UsesNodeImpl.class.getSimpleName());
+            sb.append("[groupingPath=" + groupingPath +"]");
+            return sb.toString();
+        }
+
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserImpl.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserImpl.java
new file mode 100644 (file)
index 0000000..d86b49d
--- /dev/null
@@ -0,0 +1,321 @@
+/*
+ * 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.yang.model.parser.impl;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.tree.ParseTree;
+import org.antlr.v4.runtime.tree.ParseTreeWalker;
+import org.opendaylight.controller.antlrv4.code.gen.YangLexer;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser;
+import org.opendaylight.controller.model.util.UnknownType;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+import org.opendaylight.controller.yang.model.api.ExtensionDefinition;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.api.ModuleImport;
+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.parser.api.YangModelParser;
+import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationSchemaBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationTargetBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.ChildNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.DataSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeAwareBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.TypeDefinitionBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class YangModelParserImpl implements YangModelParser {
+
+    private static final Logger logger = LoggerFactory
+            .getLogger(YangModelParserImpl.class);
+
+    @Override
+    public Module parseYangModel(String yangFile) {
+        final Map<String, TreeMap<Date, ModuleBuilder>> modules = loadFiles(yangFile);
+        Set<Module> result = build(modules);
+        return result.iterator().next();
+    }
+
+    @Override
+    public Set<Module> parseYangModels(String... yangFiles) {
+        final Map<String, TreeMap<Date, ModuleBuilder>> modules = loadFiles(yangFiles);
+        Set<Module> result = build(modules);
+        return result;
+    }
+
+    @Override
+    public SchemaContext resolveSchemaContext(Set<Module> modules) {
+        return new SchemaContextImpl(modules);
+    }
+
+    private Set<Module> build(Map<String, TreeMap<Date, ModuleBuilder>> modules) {
+        // first validate
+        for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+            for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue().entrySet()) {
+                ModuleBuilder moduleBuilder = childEntry.getValue();
+                validateBuilder(modules, moduleBuilder);
+            }
+        }
+
+        // then build
+        final Set<Module> result = new HashSet<Module>();
+        for (Map.Entry<String, TreeMap<Date, ModuleBuilder>> entry : modules.entrySet()) {
+            final Map<Date, Module> modulesByRevision = new HashMap<Date, Module>();
+            for (Map.Entry<Date, ModuleBuilder> childEntry : entry.getValue().entrySet()) {
+                ModuleBuilder moduleBuilder = childEntry.getValue();
+                modulesByRevision.put(childEntry.getKey(),moduleBuilder.build());
+                result.add(moduleBuilder.build());
+            }
+        }
+
+        return result;
+    }
+
+    private void validateBuilder(Map<String, TreeMap<Date, ModuleBuilder>> modules, ModuleBuilder builder) {
+        resolveTypedefs(modules, builder);
+        resolveAugments(modules, builder);
+    }
+
+    private void resolveTypedefs(Map<String, TreeMap<Date, ModuleBuilder>> modules, ModuleBuilder builder) {
+        Map<List<String>, TypeAwareBuilder> dirtyNodes = builder.getDirtyNodes();
+        if (dirtyNodes.size() == 0) {
+            return;
+        } else {
+            for (Map.Entry<List<String>, TypeAwareBuilder> entry : dirtyNodes.entrySet()) {
+                TypeAwareBuilder tab = entry.getValue();
+                TypeDefinitionBuilder tdb = findTypeDefinitionBuilder(modules,entry.getValue(), builder);
+                tab.setType(tdb.build());
+            }
+        }
+    }
+
+    private TypeDefinitionBuilder findTypeDefinitionBuilder(Map<String, TreeMap<Date, ModuleBuilder>> modules, TypeAwareBuilder typeBuilder, ModuleBuilder builder) {
+        UnknownType type = (UnknownType) typeBuilder.getType();
+        QName typeQName = type.getQName();
+        String typeName = type.getQName().getLocalName();
+        String prefix = typeQName.getPrefix();
+
+        ModuleBuilder dependentModuleBuilder;
+        if (prefix.equals(builder.getPrefix())) {
+            dependentModuleBuilder = builder;
+        } else {
+            ModuleImport dependentModuleImport = getDependentModuleImport(builder, prefix);
+            String dependentModuleName = dependentModuleImport.getModuleName();
+            Date dependentModuleRevision = dependentModuleImport.getRevision();
+            TreeMap<Date, ModuleBuilder> moduleBuildersByRevision = modules.get(dependentModuleName);
+            if(dependentModuleRevision == null) {
+                dependentModuleBuilder = moduleBuildersByRevision.lastEntry().getValue();
+            } else {
+                dependentModuleBuilder = moduleBuildersByRevision.get(dependentModuleRevision);
+            }
+        }
+
+        final Set<TypeDefinitionBuilder> typedefs = dependentModuleBuilder.getModuleTypedefs();
+
+        TypeDefinitionBuilder lookedUpBuilder = null;
+        for (TypeDefinitionBuilder tdb : typedefs) {
+            QName qname = tdb.getQName();
+            if (qname.getLocalName().equals(typeName)) {
+                lookedUpBuilder = tdb;
+                break;
+            }
+        }
+
+        if (lookedUpBuilder.getBaseType() instanceof UnknownType) {
+            return findTypeDefinitionBuilder(modules, (TypeAwareBuilder) lookedUpBuilder, dependentModuleBuilder);
+        } else {
+            return lookedUpBuilder;
+        }
+    }
+
+    private void resolveAugments(Map<String, TreeMap<Date, ModuleBuilder>> modules, ModuleBuilder builder) {
+        Set<AugmentationSchemaBuilder> augmentBuilders = builder.getAddedAugments();
+
+        Set<AugmentationSchema> augments = new HashSet<AugmentationSchema>();
+        for (AugmentationSchemaBuilder augmentBuilder : augmentBuilders) {
+            SchemaPath augmentTargetSchemaPath = augmentBuilder.getTargetPath();
+            String prefix = null;
+            List<String> augmentTargetPath = new ArrayList<String>();
+            for (QName pathPart : augmentTargetSchemaPath.getPath()) {
+                prefix = pathPart.getPrefix();
+                augmentTargetPath.add(pathPart.getLocalName());
+            }
+            ModuleImport dependentModuleImport = getDependentModuleImport(builder, prefix);
+            String dependentModuleName = dependentModuleImport.getModuleName();
+            augmentTargetPath.add(0, dependentModuleName);
+
+            Date dependentModuleRevision = dependentModuleImport.getRevision();
+
+            TreeMap<Date, ModuleBuilder> moduleBuildersByRevision = modules.get(dependentModuleName);
+            ModuleBuilder dependentModule;
+            if(dependentModuleRevision == null) {
+                dependentModule = moduleBuildersByRevision.lastEntry().getValue();
+            } else {
+                dependentModule = moduleBuildersByRevision.get(dependentModuleRevision);
+            }
+
+            AugmentationTargetBuilder augmentTarget = (AugmentationTargetBuilder) dependentModule.getNode(augmentTargetPath);
+            AugmentationSchema result = augmentBuilder.build();
+            augmentTarget.addAugmentation(result);
+            fillAugmentTarget(augmentBuilder, (ChildNodeBuilder) augmentTarget);
+            augments.add(result);
+        }
+        builder.setAugmentations(augments);
+    }
+
+    private void fillAugmentTarget(AugmentationSchemaBuilder augment,
+            ChildNodeBuilder target) {
+        for (DataSchemaNodeBuilder builder : augment.getChildNodes()) {
+            builder.setAugmenting(true);
+            target.addChildNode(builder);
+        }
+    }
+
+    private Map<String, TreeMap<Date, ModuleBuilder>> loadFiles(String... yangFiles) {
+        final Map<String, TreeMap<Date, ModuleBuilder>> modules = new HashMap<String, TreeMap<Date, ModuleBuilder>>();
+
+        final YangModelParserListenerImpl yangModelParser = new YangModelParserListenerImpl();
+        final ParseTreeWalker walker = new ParseTreeWalker();
+
+        List<ParseTree> trees = parseFiles(yangFiles);
+
+        ModuleBuilder[] builders = new ModuleBuilder[trees.size()];
+
+        for (int i = 0; i < trees.size(); i++) {
+            walker.walk(yangModelParser, trees.get(i));
+            builders[i] = yangModelParser.getModuleBuilder();
+        }
+
+        for (ModuleBuilder builder : builders) {
+            final String builderName = builder.getName();
+            Date builderRevision = builder.getRevision();
+            if(builderRevision == null) {
+                builderRevision = createEpochTime();
+            }
+
+            TreeMap<Date, ModuleBuilder> builderByRevision = modules.get(builderName);
+            if (builderByRevision == null) {
+                builderByRevision = new TreeMap<Date, ModuleBuilder>();
+            }
+            builderByRevision.put(builderRevision, builder);
+
+            modules.put(builderName, builderByRevision);
+        }
+        return modules;
+    }
+
+    private List<ParseTree> parseFiles(String... yangFileNames) {
+        List<ParseTree> trees = new ArrayList<ParseTree>();
+        for (String fileName : yangFileNames) {
+            trees.add(parseFile(fileName));
+        }
+        return trees;
+    }
+
+    private ParseTree parseFile(String yangFileName) {
+        ParseTree result = null;
+        try {
+            final File yangFile = new File(yangFileName);
+            final FileInputStream inStream = new FileInputStream(yangFile);
+            final ANTLRInputStream input = new ANTLRInputStream(inStream);
+            final YangLexer lexer = new YangLexer(input);
+            final CommonTokenStream tokens = new CommonTokenStream(lexer);
+            final YangParser parser = new YangParser(tokens);
+            result = parser.yang();
+        } catch (IOException e) {
+            logger.warn("Exception while reading yang file: " + yangFileName, e);
+        }
+        return result;
+    }
+
+    private ModuleImport getDependentModuleImport(ModuleBuilder builder, String prefix) {
+        ModuleImport moduleImport = null;
+        for (ModuleImport mi : builder.getModuleImports()) {
+            if (mi.getPrefix().equals(prefix)) {
+                moduleImport = mi;
+                break;
+            }
+        }
+        return moduleImport;
+    }
+
+    private Date createEpochTime() {
+        Calendar c = Calendar.getInstance();
+        c.setTimeInMillis(0);
+        return c.getTime();
+    }
+
+    private static class SchemaContextImpl implements SchemaContext {
+        private final Set<Module> modules;
+
+        private SchemaContextImpl(Set<Module> modules) {
+            this.modules = modules;
+        }
+
+        @Override
+        public Set<DataSchemaNode> getDataDefinitions() {
+            final Set<DataSchemaNode> dataDefs = new HashSet<DataSchemaNode>();
+            for (Module m : modules) {
+                dataDefs.addAll(m.getChildNodes());
+            }
+            return dataDefs;
+        }
+
+        @Override
+        public Set<Module> getModules() {
+            return modules;
+        }
+
+        @Override
+        public Set<NotificationDefinition> getNotifications() {
+            final Set<NotificationDefinition> notifications = new HashSet<NotificationDefinition>();
+            for (Module m : modules) {
+                notifications.addAll(m.getNotifications());
+            }
+            return notifications;
+        }
+
+        @Override
+        public Set<RpcDefinition> getOperations() {
+            final Set<RpcDefinition> rpcs = new HashSet<RpcDefinition>();
+            for (Module m : modules) {
+                rpcs.addAll(m.getRpcs());
+            }
+            return rpcs;
+        }
+
+        @Override
+        public Set<ExtensionDefinition> getExtensions() {
+            final Set<ExtensionDefinition> extensions = new HashSet<ExtensionDefinition>();
+            for (Module m : modules) {
+                extensions.addAll(m.getExtensionSchemaNodes());
+            }
+            return extensions;
+        }
+    }
+
+}
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.impl;\r
-\r
-import static org.opendaylight.controller.model.parser.util.YangModelBuilderHelper.*;\r
-\r
-import java.net.URI;\r
-import java.net.URISyntaxException;\r
-import java.text.DateFormat;\r
-import java.text.ParseException;\r
-import java.text.SimpleDateFormat;\r
-import java.util.Date;\r
-import java.util.List;\r
-import java.util.Stack;\r
-\r
-import org.antlr.v4.runtime.tree.ParseTree;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParserBaseListener;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Config_argContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Config_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Container_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Description_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_add_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_delete_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_not_supported_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_replace_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Import_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Key_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Leaf_list_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Leaf_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.List_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Module_header_stmtsContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Namespace_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Ordered_by_argContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Ordered_by_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Prefix_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Presence_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Reference_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_date_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_stmtsContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Status_stmtContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.StringContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Type_body_stmtsContext;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser.Yang_version_stmtContext;\r
-import org.opendaylight.controller.model.api.type.EnumTypeDefinition;\r
-import org.opendaylight.controller.model.api.type.LengthConstraint;\r
-import org.opendaylight.controller.model.api.type.PatternConstraint;\r
-import org.opendaylight.controller.model.api.type.RangeConstraint;\r
-import org.opendaylight.controller.model.parser.api.AugmentationSchemaBuilder;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.builder.ContainerSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.builder.DeviationBuilder;\r
-import org.opendaylight.controller.model.parser.builder.FeatureBuilder;\r
-import org.opendaylight.controller.model.parser.builder.LeafListSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.builder.LeafSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.builder.ListSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.builder.ModuleBuilder;\r
-import org.opendaylight.controller.model.parser.builder.MustDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.builder.NotificationBuilder;\r
-import org.opendaylight.controller.model.parser.builder.RpcDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.builder.TypedefBuilder;\r
-import org.opendaylight.controller.model.parser.util.YangModelBuilderHelper;\r
-import org.opendaylight.controller.model.util.BitsType;\r
-import org.opendaylight.controller.model.util.EnumerationType;\r
-import org.opendaylight.controller.model.util.Leafref;\r
-import org.opendaylight.controller.model.util.StringType;\r
-import org.opendaylight.controller.model.util.YangTypesConverter;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-public class YangModelParserImpl extends YangParserBaseListener {\r
-\r
-    private static final Logger logger = LoggerFactory\r
-            .getLogger(YangModelParserImpl.class);\r
-\r
-    private ModuleBuilder moduleBuilder;\r
-\r
-    private String moduleName;\r
-    private URI namespace;\r
-    private String yangModelPrefix;\r
-    private Date revision;\r
-\r
-    private final DateFormat simpleDateFormat = new SimpleDateFormat(\r
-            "yyyy-mm-dd");\r
-    private final Stack<String> actualPath = new Stack<String>();\r
-\r
-    @Override\r
-    public void enterModule_stmt(YangParser.Module_stmtContext ctx) {\r
-        moduleName = stringFromNode(ctx);\r
-        actualPath.push(moduleName);\r
-        moduleBuilder = new ModuleBuilder(moduleName);\r
-    }\r
-\r
-    @Override\r
-    public void exitModule_stmt(YangParser.Module_stmtContext ctx) {\r
-        final String moduleName = actualPath.pop();\r
-        logger.debug("Exiting module " + moduleName);\r
-    }\r
-\r
-    @Override\r
-    public void enterModule_header_stmts(final Module_header_stmtsContext ctx) {\r
-        super.enterModule_header_stmts(ctx);\r
-\r
-        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
-            final ParseTree treeNode = ctx.getChild(i);\r
-            if (treeNode instanceof Namespace_stmtContext) {\r
-                String namespaceStr = stringFromNode(treeNode);\r
-                try {\r
-                    this.namespace = new URI(namespaceStr);\r
-                    moduleBuilder.setNamespace(namespace);\r
-                } catch (URISyntaxException e) {\r
-                    logger.warn("Failed to parse module namespace", e);\r
-                }\r
-            } else if (treeNode instanceof Prefix_stmtContext) {\r
-                yangModelPrefix = stringFromNode(treeNode);\r
-                moduleBuilder.setPrefix(yangModelPrefix);\r
-            } else if (treeNode instanceof Yang_version_stmtContext) {\r
-                final String yangVersion = stringFromNode(treeNode);\r
-                moduleBuilder.setYangVersion(yangVersion);\r
-            }\r
-        }\r
-    }\r
-\r
-    // TODO: resolve submodule parsing\r
-    @Override\r
-    public void enterSubmodule_header_stmts(\r
-            YangParser.Submodule_header_stmtsContext ctx) {\r
-        String submoduleName = stringFromNode(ctx);\r
-        QName submoduleQName = new QName(namespace, revision, yangModelPrefix,\r
-                submoduleName);\r
-        moduleBuilder.addSubmodule(submoduleQName);\r
-        updatePath(submoduleName);\r
-    }\r
-\r
-    @Override\r
-    public void exitSubmodule_header_stmts(\r
-            YangParser.Submodule_header_stmtsContext ctx) {\r
-        final String submodule = actualPath.pop();\r
-        logger.debug("exiting submodule " + submodule);\r
-    }\r
-\r
-    @Override\r
-    public void enterOrganization_stmt(YangParser.Organization_stmtContext ctx) {\r
-        final String organization = stringFromNode(ctx);\r
-        moduleBuilder.setOrganization(organization);\r
-    }\r
-\r
-    @Override\r
-    public void enterContact_stmt(YangParser.Contact_stmtContext ctx) {\r
-        String contact = stringFromNode(ctx);\r
-        moduleBuilder.setContact(contact);\r
-    }\r
-\r
-    @Override\r
-    public void enterRevision_stmts(Revision_stmtsContext ctx) {\r
-        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
-            final ParseTree treeNode = ctx.getChild(i);\r
-            if (treeNode instanceof Revision_stmtContext) {\r
-                final String revisionDateStr = stringFromNode(treeNode);\r
-                try {\r
-                    revision = simpleDateFormat.parse(revisionDateStr);\r
-                } catch (ParseException e) {\r
-                    logger.warn("Failed to parse revision string: "\r
-                            + revisionDateStr);\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void enterDescription_stmt(YangParser.Description_stmtContext ctx) {\r
-        // if this is module description...\r
-        if (actualPath.size() == 1) {\r
-            moduleBuilder.setDescription(stringFromNode(ctx));\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void enterImport_stmt(Import_stmtContext ctx) {\r
-        super.enterImport_stmt(ctx);\r
-\r
-        final String importName = stringFromNode(ctx);\r
-        String importPrefix = null;\r
-        Date importRevision = null;\r
-\r
-        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
-            final ParseTree treeNode = ctx.getChild(i);\r
-            if (treeNode instanceof Prefix_stmtContext) {\r
-                importPrefix = stringFromNode(treeNode);\r
-            }\r
-            if (treeNode instanceof Revision_date_stmtContext) {\r
-                String importRevisionStr = stringFromNode(treeNode);\r
-                try {\r
-                    importRevision = simpleDateFormat.parse(importRevisionStr);\r
-                } catch (Exception e) {\r
-                    logger.warn("Failed to parse import revision-date.", e);\r
-                }\r
-            }\r
-        }\r
-        moduleBuilder.addModuleImport(importName, importRevision, importPrefix);\r
-    }\r
-\r
-    @Override\r
-    public void enterAugment_stmt(YangParser.Augment_stmtContext ctx) {\r
-        final String augmentPath = stringFromNode(ctx);\r
-        AugmentationSchemaBuilder builder = moduleBuilder.addAugment(\r
-                augmentPath, actualPath);\r
-        updatePath(augmentPath);\r
-\r
-        for (int i = 0; i < ctx.getChildCount(); i++) {\r
-            ParseTree child = ctx.getChild(i);\r
-            if (child instanceof Description_stmtContext) {\r
-                String desc = stringFromNode(child);\r
-                builder.setDescription(desc);\r
-            } else if (child instanceof Reference_stmtContext) {\r
-                String ref = stringFromNode(child);\r
-                builder.setReference(ref);\r
-            } else if (child instanceof Status_stmtContext) {\r
-                Status status = getStatus((Status_stmtContext) child);\r
-                builder.setStatus(status);\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void exitAugment_stmt(YangParser.Augment_stmtContext ctx) {\r
-        final String augment = actualPath.pop();\r
-        logger.debug("exiting augment " + augment);\r
-    }\r
-\r
-    @Override\r
-    public void enterMust_stmt(YangParser.Must_stmtContext ctx) {\r
-        String mustText = "";\r
-        String description = null;\r
-        String reference = null;\r
-        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
-            ParseTree child = ctx.getChild(i);\r
-            if (child instanceof StringContext) {\r
-                final StringContext context = (StringContext) child;\r
-                for (int j = 0; j < context.getChildCount(); j++) {\r
-                    String mustPart = context.getChild(j).getText();\r
-                    if (j == 0) {\r
-                        mustText += mustPart\r
-                                .substring(0, mustPart.length() - 1);\r
-                        continue;\r
-                    }\r
-                    if (j % 2 == 0) {\r
-                        mustText += mustPart.substring(1);\r
-                    }\r
-                }\r
-            } else if (child instanceof Description_stmtContext) {\r
-                description = stringFromNode(child);\r
-            } else if (child instanceof Reference_stmtContext) {\r
-                reference = stringFromNode(child);\r
-            }\r
-        }\r
-        MustDefinitionBuilder builder = moduleBuilder.addMustDefinition(\r
-                mustText, actualPath);\r
-        builder.setDescription(description);\r
-        builder.setReference(reference);\r
-    }\r
-\r
-    @Override\r
-    public void enterTypedef_stmt(YangParser.Typedef_stmtContext ctx) {\r
-        String typedefName = stringFromNode(ctx);\r
-        QName typedefQName = new QName(namespace, revision, yangModelPrefix,\r
-                typedefName);\r
-        TypedefBuilder builder = moduleBuilder.addTypedef(typedefQName,\r
-                actualPath);\r
-        updatePath(typedefName);\r
-\r
-        builder.setPath(getActualSchemaPath(actualPath, namespace, revision,\r
-                yangModelPrefix));\r
-        parseSchemaNodeArgs(ctx, builder);\r
-    }\r
-\r
-    @Override\r
-    public void exitTypedef_stmt(YangParser.Typedef_stmtContext ctx) {\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    @Override\r
-    public void enterType_stmt(YangParser.Type_stmtContext ctx) {\r
-        String typeName = stringFromNode(ctx);\r
-        QName typeQName;\r
-        if (typeName.contains(":")) {\r
-            String[] splittedName = typeName.split(":");\r
-            // if this type contains prefix, it means that it point to type in\r
-            // external module\r
-            typeQName = new QName(null, null, splittedName[0], splittedName[1]);\r
-        } else {\r
-            typeQName = new QName(namespace, revision, yangModelPrefix,\r
-                    typeName);\r
-        }\r
-\r
-        TypeDefinition<?> type = null;\r
-\r
-        if (!YangTypesConverter.isBaseYangType(typeName)) {\r
-            if (typeName.equals("leafref")) {\r
-                // TODO: RevisionAwareXPath implementation\r
-                type = new Leafref(new RevisionAwareXPath() {\r
-                });\r
-            } else {\r
-                type = parseUnknownType(typeQName, ctx);\r
-                // mark parent node of this type statement as dirty\r
-                moduleBuilder.addDirtyNode(actualPath);\r
-            }\r
-        } else {\r
-\r
-            Type_body_stmtsContext typeBody = null;\r
-            for (int i = 0; i < ctx.getChildCount(); i++) {\r
-                if (ctx.getChild(i) instanceof Type_body_stmtsContext) {\r
-                    typeBody = (Type_body_stmtsContext) ctx.getChild(i);\r
-                    break;\r
-                }\r
-            }\r
-\r
-            if (typeBody == null) {\r
-                // if there are no constraints, just grab default base yang type\r
-                type = YangTypesConverter.javaTypeForBaseYangType(typeName);\r
-            } else {\r
-                List<RangeConstraint> rangeStatements = getRangeConstraints(typeBody);\r
-                Integer fractionDigits = getFractionDigits(typeBody);\r
-                List<LengthConstraint> lengthStatements = getLengthConstraints(typeBody);\r
-                List<PatternConstraint> patternStatements = getPatternConstraint(typeBody);\r
-                List<EnumTypeDefinition.EnumPair> enumConstants = YangModelBuilderHelper\r
-                        .getEnumConstants(typeBody);\r
-\r
-                if (typeName.equals("decimal64")) {\r
-                    type = YangTypesConverter.javaTypeForBaseYangDecimal64Type(\r
-                            rangeStatements, fractionDigits);\r
-                } else if (typeName.startsWith("int")\r
-                        || typeName.startsWith("uint")) {\r
-                    type = YangTypesConverter.javaTypeForBaseYangIntegerType(\r
-                            typeName, rangeStatements);\r
-                } else if (typeName.equals("enumeration")) {\r
-                    type = new EnumerationType(enumConstants);\r
-                } else if (typeName.equals("string")) {\r
-                    type = new StringType(lengthStatements, patternStatements);\r
-                } else if (typeName.equals("bits")) {\r
-                    type = new BitsType(getBits(typeBody, actualPath,\r
-                            namespace, revision, yangModelPrefix));\r
-                } else {\r
-                    // TODO: implement binary + instance-identifier types\r
-                }\r
-            }\r
-\r
-        }\r
-\r
-        moduleBuilder.setType(type, actualPath);\r
-        updatePath(typeName);\r
-    }\r
-\r
-    @Override\r
-    public void exitType_stmt(YangParser.Type_stmtContext ctx) {\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    @Override\r
-    public void enterGrouping_stmt(YangParser.Grouping_stmtContext ctx) {\r
-        final String groupName = stringFromNode(ctx);\r
-        QName groupQName = new QName(namespace, revision, yangModelPrefix,\r
-                groupName);\r
-        GroupingBuilder groupBuilder = moduleBuilder.addGrouping(groupQName,\r
-                actualPath);\r
-        updatePath("grouping");\r
-        updatePath(groupName);\r
-        parseSchemaNodeArgs(ctx, groupBuilder);\r
-    }\r
-\r
-    @Override\r
-    public void exitGrouping_stmt(YangParser.Grouping_stmtContext ctx) {\r
-        String actContainer = actualPath.pop();\r
-        actContainer += "-" + actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    @Override\r
-    public void enterContainer_stmt(Container_stmtContext ctx) {\r
-        super.enterContainer_stmt(ctx);\r
-        String containerName = stringFromNode(ctx);\r
-        QName containerQName = new QName(namespace, revision, yangModelPrefix,\r
-                containerName);\r
-        ContainerSchemaNodeBuilder containerBuilder = moduleBuilder\r
-                .addContainerNode(containerQName, actualPath);\r
-        updatePath(containerName);\r
-\r
-        containerBuilder.setPath(getActualSchemaPath(actualPath, namespace,\r
-                revision, yangModelPrefix));\r
-        parseSchemaNodeArgs(ctx, containerBuilder);\r
-\r
-        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
-            final ParseTree childNode = ctx.getChild(i);\r
-            if (childNode instanceof Presence_stmtContext) {\r
-                containerBuilder.setPresenceContainer(true);\r
-            } else if (childNode instanceof Config_stmtContext) {\r
-                for (int j = 0; j < childNode.getChildCount(); j++) {\r
-                    ParseTree configArg = childNode.getChild(j);\r
-                    if (configArg instanceof Config_argContext) {\r
-                        String config = stringFromNode(configArg);\r
-                        if (config.equals("true")) {\r
-                            containerBuilder.setConfiguration(true);\r
-                        } else {\r
-                            containerBuilder.setConfiguration(false);\r
-                        }\r
-                    }\r
-                }\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void exitContainer_stmt(Container_stmtContext ctx) {\r
-        super.exitContainer_stmt(ctx);\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    private boolean isLeafReadOnly(final ParseTree leaf) {\r
-        if (leaf != null) {\r
-            for (int i = 0; i < leaf.getChildCount(); ++i) {\r
-                final ParseTree configContext = leaf.getChild(i);\r
-                if (configContext instanceof Config_argContext) {\r
-                    final String value = stringFromNode(configContext);\r
-                    if (value.equals("true")) {\r
-                        return true;\r
-                    }\r
-                }\r
-            }\r
-        }\r
-        return false;\r
-    }\r
-\r
-    @Override\r
-    public void enterLeaf_stmt(Leaf_stmtContext ctx) {\r
-        super.enterLeaf_stmt(ctx);\r
-\r
-        final String leafName = stringFromNode(ctx);\r
-        QName leafQName = new QName(namespace, revision, yangModelPrefix,\r
-                leafName);\r
-        LeafSchemaNodeBuilder leafBuilder = moduleBuilder.addLeafNode(\r
-                leafQName, actualPath);\r
-        updatePath(leafName);\r
-\r
-        leafBuilder.setPath(getActualSchemaPath(actualPath, namespace,\r
-                revision, yangModelPrefix));\r
-        parseSchemaNodeArgs(ctx, leafBuilder);\r
-\r
-        for (int i = 0; i < ctx.getChildCount(); i++) {\r
-            ParseTree child = ctx.getChild(i);\r
-            if (child instanceof Config_stmtContext) {\r
-                leafBuilder.setConfiguration(isLeafReadOnly(child));\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void exitLeaf_stmt(YangParser.Leaf_stmtContext ctx) {\r
-        final String actLeaf = actualPath.pop();\r
-        logger.debug("exiting " + actLeaf);\r
-    }\r
-\r
-    @Override\r
-    public void enterUses_stmt(YangParser.Uses_stmtContext ctx) {\r
-        final String groupingPathStr = stringFromNode(ctx);\r
-        moduleBuilder.addUsesNode(groupingPathStr, actualPath);\r
-        updatePath(groupingPathStr);\r
-    }\r
-\r
-    @Override\r
-    public void exitUses_stmt(YangParser.Uses_stmtContext ctx) {\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    @Override\r
-    public void enterLeaf_list_stmt(Leaf_list_stmtContext ctx) {\r
-        super.enterLeaf_list_stmt(ctx);\r
-\r
-        final String leafListName = stringFromNode(ctx);\r
-        QName leafListQName = new QName(namespace, revision, yangModelPrefix,\r
-                leafListName);\r
-        LeafListSchemaNodeBuilder leafListBuilder = moduleBuilder\r
-                .addLeafListNode(leafListQName, actualPath);\r
-        updatePath(leafListName);\r
-\r
-        parseSchemaNodeArgs(ctx, leafListBuilder);\r
-\r
-        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
-            final ParseTree childNode = ctx.getChild(i);\r
-            if (childNode instanceof Config_stmtContext) {\r
-                leafListBuilder.setConfiguration(isLeafReadOnly(childNode));\r
-            } else if (childNode instanceof Ordered_by_stmtContext) {\r
-                final Ordered_by_stmtContext orderedBy = (Ordered_by_stmtContext) childNode;\r
-                final boolean userOrdered = parseUserOrdered(orderedBy);\r
-                leafListBuilder.setUserOrdered(userOrdered);\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void exitLeaf_list_stmt(YangParser.Leaf_list_stmtContext ctx) {\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    @Override\r
-    public void enterList_stmt(List_stmtContext ctx) {\r
-        super.enterList_stmt(ctx);\r
-\r
-        final String containerName = stringFromNode(ctx);\r
-        QName containerQName = new QName(namespace, revision, yangModelPrefix,\r
-                containerName);\r
-        ListSchemaNodeBuilder listBuilder = moduleBuilder.addListNode(\r
-                containerQName, actualPath);\r
-        updatePath(containerName);\r
-\r
-        listBuilder.setPath(getActualSchemaPath(actualPath, namespace,\r
-                revision, yangModelPrefix));\r
-        parseSchemaNodeArgs(ctx, listBuilder);\r
-\r
-        String keyDefinition = "";\r
-        for (int i = 0; i < ctx.getChildCount(); ++i) {\r
-            ParseTree childNode = ctx.getChild(i);\r
-\r
-            if (childNode instanceof Ordered_by_stmtContext) {\r
-                final Ordered_by_stmtContext orderedBy = (Ordered_by_stmtContext) childNode;\r
-                final boolean userOrdered = parseUserOrdered(orderedBy);\r
-                listBuilder.setUserOrdered(userOrdered);\r
-            } else if (childNode instanceof Key_stmtContext) {\r
-                List<QName> key = createListKey(keyDefinition, namespace,\r
-                        revision, keyDefinition);\r
-                listBuilder.setKeyDefinition(key);\r
-            }\r
-        }\r
-    }\r
-\r
-    @Override\r
-    public void exitList_stmt(List_stmtContext ctx) {\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    @Override\r
-    public void enterNotification_stmt(YangParser.Notification_stmtContext ctx) {\r
-        final String notificationName = stringFromNode(ctx);\r
-        QName notificationQName = new QName(namespace, revision,\r
-                yangModelPrefix, notificationName);\r
-        NotificationBuilder notificationBuilder = moduleBuilder\r
-                .addNotification(notificationQName, actualPath);\r
-        updatePath(notificationName);\r
-\r
-        notificationBuilder.setPath(getActualSchemaPath(actualPath, namespace,\r
-                revision, yangModelPrefix));\r
-        parseSchemaNodeArgs(ctx, notificationBuilder);\r
-    }\r
-\r
-    @Override\r
-    public void exitNotification_stmt(YangParser.Notification_stmtContext ctx) {\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    @Override\r
-    public void enterRpc_stmt(YangParser.Rpc_stmtContext ctx) {\r
-        final String rpcName = stringFromNode(ctx);\r
-        QName rpcQName = new QName(namespace, revision, yangModelPrefix,\r
-                rpcName);\r
-        RpcDefinitionBuilder rpcBuilder = moduleBuilder.addRpc(rpcQName,\r
-                actualPath);\r
-        updatePath(rpcName);\r
-\r
-        rpcBuilder.setPath(getActualSchemaPath(actualPath, namespace, revision,\r
-                yangModelPrefix));\r
-        parseSchemaNodeArgs(ctx, rpcBuilder);\r
-    }\r
-\r
-    @Override\r
-    public void exitRpc_stmt(YangParser.Rpc_stmtContext ctx) {\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    @Override\r
-    public void enterInput_stmt(YangParser.Input_stmtContext ctx) {\r
-        updatePath("input");\r
-    }\r
-\r
-    @Override\r
-    public void exitInput_stmt(YangParser.Input_stmtContext ctx) {\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    @Override\r
-    public void enterOutput_stmt(YangParser.Output_stmtContext ctx) {\r
-        updatePath("output");\r
-    }\r
-\r
-    @Override\r
-    public void exitOutput_stmt(YangParser.Output_stmtContext ctx) {\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    @Override\r
-    public void enterFeature_stmt(YangParser.Feature_stmtContext ctx) {\r
-        final String featureName = stringFromNode(ctx);\r
-        QName featureQName = new QName(namespace, revision, yangModelPrefix,\r
-                featureName);\r
-        FeatureBuilder featureBuilder = moduleBuilder.addFeature(featureQName,\r
-                actualPath);\r
-        updatePath(featureName);\r
-\r
-        featureBuilder.setPath(getActualSchemaPath(actualPath, namespace,\r
-                revision, yangModelPrefix));\r
-        parseSchemaNodeArgs(ctx, featureBuilder);\r
-    }\r
-\r
-    @Override\r
-    public void exitFeature_stmt(YangParser.Feature_stmtContext ctx) {\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    @Override\r
-    public void enterDeviation_stmt(YangParser.Deviation_stmtContext ctx) {\r
-        final String targetPath = stringFromNode(ctx);\r
-        String reference = null;\r
-        String deviate = null;\r
-        DeviationBuilder builder = moduleBuilder.addDeviation(targetPath);\r
-        updatePath(targetPath);\r
-\r
-        for (int i = 0; i < ctx.getChildCount(); i++) {\r
-            ParseTree child = ctx.getChild(i);\r
-            if (child instanceof Reference_stmtContext) {\r
-                reference = stringFromNode(child);\r
-            } else if (child instanceof Deviate_not_supported_stmtContext) {\r
-                deviate = stringFromNode(child);\r
-            } else if (child instanceof Deviate_add_stmtContext) {\r
-                deviate = stringFromNode(child);\r
-            } else if (child instanceof Deviate_replace_stmtContext) {\r
-                deviate = stringFromNode(child);\r
-            } else if (child instanceof Deviate_delete_stmtContext) {\r
-                deviate = stringFromNode(child);\r
-            }\r
-        }\r
-        builder.setReference(reference);\r
-        builder.setDeviate(deviate);\r
-    }\r
-\r
-    @Override\r
-    public void exitDeviation_stmt(YangParser.Deviation_stmtContext ctx) {\r
-        final String actContainer = actualPath.pop();\r
-        logger.debug("exiting " + actContainer);\r
-    }\r
-\r
-    public ModuleBuilder getModuleBuilder() {\r
-        return moduleBuilder;\r
-    }\r
-\r
-    private void updatePath(String containerName) {\r
-        actualPath.push(containerName);\r
-    }\r
-\r
-    /**\r
-     * Parse ordered-by statement.\r
-     * \r
-     * @param childNode\r
-     *            Ordered_by_stmtContext\r
-     * @return true, if ordered-by contains value 'user' or false otherwise\r
-     */\r
-    private boolean parseUserOrdered(Ordered_by_stmtContext childNode) {\r
-        boolean result = false;\r
-        for (int j = 0; j < childNode.getChildCount(); j++) {\r
-            ParseTree orderArg = childNode.getChild(j);\r
-            if (orderArg instanceof Ordered_by_argContext) {\r
-                String orderStr = stringFromNode(orderArg);\r
-                if (orderStr.equals("system")) {\r
-                    result = false;\r
-                } else if (orderStr.equals("user")) {\r
-                    result = true;\r
-                } else {\r
-                    logger.warn("Invalid 'ordered-by' statement.");\r
-                }\r
-            }\r
-        }\r
-        return result;\r
-    }\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.impl;
+
+import static org.opendaylight.controller.yang.model.parser.util.YangModelBuilderUtil.*;
+
+import java.net.URI;
+import java.text.DateFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Stack;
+
+import org.antlr.v4.runtime.tree.ParseTree;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Contact_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Container_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Description_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_add_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_delete_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_not_supported_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Deviate_replace_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Import_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Key_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Leaf_list_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Leaf_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.List_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Module_header_stmtsContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Namespace_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Ordered_by_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Organization_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Prefix_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Presence_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Reference_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_date_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Revision_stmtsContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Status_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Type_body_stmtsContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Yang_version_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParserBaseListener;
+import org.opendaylight.controller.model.util.YangTypesConverter;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.parser.builder.api.AugmentationSchemaBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ContainerSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.DeviationBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ExtensionBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.FeatureBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.LeafListSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.LeafSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ListSchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.NotificationBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.RpcDefinitionBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.TypedefBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.UnknownSchemaNodeBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+final class YangModelParserListenerImpl extends YangParserBaseListener {
+
+    private static final Logger logger = LoggerFactory
+            .getLogger(YangModelParserListenerImpl.class);
+
+    private ModuleBuilder moduleBuilder;
+
+    private String moduleName;
+    private URI namespace;
+    private String yangModelPrefix;
+    private Date revision;
+
+    private final DateFormat simpleDateFormat = new SimpleDateFormat(
+            "yyyy-mm-dd");
+    private final Stack<String> actualPath = new Stack<String>();
+
+
+    @Override
+    public void enterModule_stmt(YangParser.Module_stmtContext ctx) {
+        moduleName = stringFromNode(ctx);
+        actualPath.push(moduleName);
+        moduleBuilder = new ModuleBuilder(moduleName);
+
+        String description = null;
+        String reference = null;
+
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Description_stmtContext) {
+                description = stringFromNode(child);
+            } else if (child instanceof Reference_stmtContext) {
+                reference = stringFromNode(child);
+            } else {
+                if (description != null && reference != null) {
+                    break;
+                }
+            }
+        }
+        moduleBuilder.setDescription(description);
+        moduleBuilder.setReference(reference);
+    }
+
+    @Override
+    public void exitModule_stmt(YangParser.Module_stmtContext ctx) {
+        final String moduleName = actualPath.pop();
+        logger.debug("Exiting module " + moduleName);
+    }
+
+    @Override
+    public void enterModule_header_stmts(final Module_header_stmtsContext ctx) {
+        super.enterModule_header_stmts(ctx);
+
+        for (int i = 0; i < ctx.getChildCount(); ++i) {
+            final ParseTree treeNode = ctx.getChild(i);
+            if (treeNode instanceof Namespace_stmtContext) {
+                final String namespaceStr = stringFromNode(treeNode);
+                namespace = URI.create(namespaceStr);
+                moduleBuilder.setNamespace(namespace);
+            } else if (treeNode instanceof Prefix_stmtContext) {
+                yangModelPrefix = stringFromNode(treeNode);
+                moduleBuilder.setPrefix(yangModelPrefix);
+            } else if (treeNode instanceof Yang_version_stmtContext) {
+                final String yangVersion = stringFromNode(treeNode);
+                moduleBuilder.setYangVersion(yangVersion);
+            }
+        }
+    }
+
+    @Override
+    public void enterMeta_stmts(YangParser.Meta_stmtsContext ctx) {
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Organization_stmtContext) {
+                final String organization = stringFromNode(child);
+                moduleBuilder.setOrganization(organization);
+            } else if (child instanceof Contact_stmtContext) {
+                final String contact = stringFromNode(child);
+                moduleBuilder.setContact(contact);
+            } else if (child instanceof Description_stmtContext) {
+                final String description = stringFromNode(child);
+                moduleBuilder.setDescription(description);
+            } else if (child instanceof Reference_stmtContext) {
+                final String reference = stringFromNode(child);
+                moduleBuilder.setReference(reference);
+            }
+        }
+    }
+
+    @Override
+    public void exitSubmodule_header_stmts(
+            YangParser.Submodule_header_stmtsContext ctx) {
+        final String submodule = actualPath.pop();
+        logger.debug("exiting submodule " + submodule);
+    }
+
+    @Override
+    public void enterRevision_stmts(Revision_stmtsContext ctx) {
+        for (int i = 0; i < ctx.getChildCount(); ++i) {
+            final ParseTree treeNode = ctx.getChild(i);
+            if (treeNode instanceof Revision_stmtContext) {
+                final String revisionDateStr = stringFromNode(treeNode);
+                try {
+                    revision = simpleDateFormat.parse(revisionDateStr);
+                    moduleBuilder.setRevision(revision);
+                } catch (ParseException e) {
+                    final String message = "Failed to parse revision string: "+ revisionDateStr;
+                    logger.warn(message);
+                }
+            }
+        }
+    }
+
+    @Override
+    public void enterImport_stmt(Import_stmtContext ctx) {
+        super.enterImport_stmt(ctx);
+
+        final String importName = stringFromNode(ctx);
+        String importPrefix = null;
+        Date importRevision = null;
+
+        for (int i = 0; i < ctx.getChildCount(); ++i) {
+            final ParseTree treeNode = ctx.getChild(i);
+            if (treeNode instanceof Prefix_stmtContext) {
+                importPrefix = stringFromNode(treeNode);
+            }
+            if (treeNode instanceof Revision_date_stmtContext) {
+                String importRevisionStr = stringFromNode(treeNode);
+                try {
+                    importRevision = simpleDateFormat.parse(importRevisionStr);
+                } catch(ParseException e) {
+                    logger.warn("Failed to parse import revision-date: "+ importRevisionStr);
+                }
+            }
+        }
+        moduleBuilder.addModuleImport(importName, importRevision, importPrefix);
+    }
+
+    @Override
+    public void enterAugment_stmt(YangParser.Augment_stmtContext ctx) {
+        final String augmentPath = stringFromNode(ctx);
+        AugmentationSchemaBuilder builder = moduleBuilder.addAugment(
+                augmentPath, getActualPath());
+        updatePath(augmentPath);
+
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Description_stmtContext) {
+                String desc = stringFromNode(child);
+                builder.setDescription(desc);
+            } else if (child instanceof Reference_stmtContext) {
+                String ref = stringFromNode(child);
+                builder.setReference(ref);
+            } else if (child instanceof Status_stmtContext) {
+                Status status = parseStatus((Status_stmtContext) child);
+                builder.setStatus(status);
+            }
+        }
+    }
+
+    @Override
+    public void exitAugment_stmt(YangParser.Augment_stmtContext ctx) {
+        final String augment = actualPath.pop();
+        logger.debug("exiting augment " + augment);
+    }
+
+    @Override
+    public void enterExtension_stmt(YangParser.Extension_stmtContext ctx) {
+        String argument = stringFromNode(ctx);
+        QName qname = new QName(namespace, revision, yangModelPrefix, argument);
+        ExtensionBuilder builder = moduleBuilder.addExtension(qname);
+        parseSchemaNodeArgs(ctx, builder);
+    }
+
+    @Override
+    public void enterTypedef_stmt(YangParser.Typedef_stmtContext ctx) {
+        String typedefName = stringFromNode(ctx);
+        QName typedefQName = new QName(namespace, revision, yangModelPrefix,
+                typedefName);
+        TypedefBuilder builder = moduleBuilder.addTypedef(typedefQName,
+                getActualPath());
+        updatePath(typedefName);
+
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision,
+                yangModelPrefix));
+        parseSchemaNodeArgs(ctx, builder);
+        builder.setUnits(parseUnits(ctx));
+    }
+
+    @Override
+    public void exitTypedef_stmt(YangParser.Typedef_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterType_stmt(YangParser.Type_stmtContext ctx) {
+        String typeName = stringFromNode(ctx);
+        QName typeQName;
+        if (typeName.contains(":")) {
+            String[] splittedName = typeName.split(":");
+            String prefix = splittedName[0];
+            String name = splittedName[1];
+            if (prefix.equals(yangModelPrefix)) {
+                typeQName = new QName(namespace, revision, prefix, name);
+            } else {
+                typeQName = new QName(null, null, prefix, name);
+            }
+        } else {
+            typeQName = new QName(namespace, revision, yangModelPrefix,
+                    typeName);
+        }
+
+        TypeDefinition<?> type = null;
+        Type_body_stmtsContext typeBody = null;
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            if (ctx.getChild(i) instanceof Type_body_stmtsContext) {
+                typeBody = (Type_body_stmtsContext) ctx.getChild(i);
+                break;
+            }
+        }
+
+        // if this is base yang type...
+        if(YangTypesConverter.isBaseYangType(typeName)) {
+            if (typeBody == null) {
+                // if there are no constraints, just grab default base yang type
+                type = YangTypesConverter.javaTypeForBaseYangType(typeName);
+            } else {
+                type = parseTypeBody(typeName, typeBody, actualPath, namespace, revision, yangModelPrefix);
+            }
+        } else {
+            type = parseUnknownTypeBody(typeQName, typeBody);
+            // mark parent node of this type statement as dirty
+            moduleBuilder.addDirtyNode(actualPath);
+        }
+
+        moduleBuilder.setType(type, actualPath);
+        updatePath(typeName);
+    }
+
+    @Override
+    public void exitType_stmt(YangParser.Type_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterGrouping_stmt(YangParser.Grouping_stmtContext ctx) {
+        final String groupName = stringFromNode(ctx);
+        QName groupQName = new QName(namespace, revision, yangModelPrefix,
+                groupName);
+        GroupingBuilder groupBuilder = moduleBuilder.addGrouping(groupQName,
+                actualPath);
+        updatePath("grouping");
+        updatePath(groupName);
+        parseSchemaNodeArgs(ctx, groupBuilder);
+    }
+
+    @Override
+    public void exitGrouping_stmt(YangParser.Grouping_stmtContext ctx) {
+        String actContainer = actualPath.pop();
+        actContainer += "-" + actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterContainer_stmt(Container_stmtContext ctx) {
+        super.enterContainer_stmt(ctx);
+        String containerName = stringFromNode(ctx);
+        QName containerQName = new QName(namespace, revision, yangModelPrefix,
+                containerName);
+        ContainerSchemaNodeBuilder containerBuilder = moduleBuilder
+                .addContainerNode(containerQName, actualPath);
+        updatePath(containerName);
+
+        containerBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
+        parseSchemaNodeArgs(ctx, containerBuilder);
+        parseConstraints(ctx, containerBuilder.getConstraintsBuilder());
+
+        for (int i = 0; i < ctx.getChildCount(); ++i) {
+            final ParseTree childNode = ctx.getChild(i);
+            if (childNode instanceof Presence_stmtContext) {
+                containerBuilder.setPresenceContainer(true);
+                break;
+            }
+        }
+    }
+
+    @Override
+    public void exitContainer_stmt(Container_stmtContext ctx) {
+        super.exitContainer_stmt(ctx);
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterLeaf_stmt(Leaf_stmtContext ctx) {
+        super.enterLeaf_stmt(ctx);
+
+        final String leafName = stringFromNode(ctx);
+        QName leafQName = new QName(namespace, revision, yangModelPrefix,
+                leafName);
+        LeafSchemaNodeBuilder leafBuilder = moduleBuilder.addLeafNode(
+                leafQName, actualPath);
+        updatePath(leafName);
+
+        leafBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
+        parseSchemaNodeArgs(ctx, leafBuilder);
+        parseConstraints(ctx, leafBuilder.getConstraintsBuilder());
+    }
+
+    @Override
+    public void exitLeaf_stmt(YangParser.Leaf_stmtContext ctx) {
+        final String actLeaf = actualPath.pop();
+        logger.debug("exiting " + actLeaf);
+    }
+
+    @Override
+    public void enterUses_stmt(YangParser.Uses_stmtContext ctx) {
+        final String groupingPathStr = stringFromNode(ctx);
+        moduleBuilder.addUsesNode(groupingPathStr, actualPath);
+        updatePath(groupingPathStr);
+    }
+
+    @Override
+    public void exitUses_stmt(YangParser.Uses_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterLeaf_list_stmt(Leaf_list_stmtContext ctx) {
+        super.enterLeaf_list_stmt(ctx);
+
+        final String leafListName = stringFromNode(ctx);
+        QName leafListQName = new QName(namespace, revision, yangModelPrefix,
+                leafListName);
+        LeafListSchemaNodeBuilder leafListBuilder = moduleBuilder
+                .addLeafListNode(leafListQName, actualPath);
+        updatePath(leafListName);
+
+        parseSchemaNodeArgs(ctx, leafListBuilder);
+        parseConstraints(ctx, leafListBuilder.getConstraintsBuilder());
+
+        for (int i = 0; i < ctx.getChildCount(); ++i) {
+            final ParseTree childNode = ctx.getChild(i);
+            if (childNode instanceof Ordered_by_stmtContext) {
+                final Ordered_by_stmtContext orderedBy = (Ordered_by_stmtContext) childNode;
+                final boolean userOrdered = parseUserOrdered(orderedBy);
+                leafListBuilder.setUserOrdered(userOrdered);
+                break;
+            }
+        }
+    }
+
+    @Override
+    public void exitLeaf_list_stmt(YangParser.Leaf_list_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterList_stmt(List_stmtContext ctx) {
+        super.enterList_stmt(ctx);
+
+        final String containerName = stringFromNode(ctx);
+        QName containerQName = new QName(namespace, revision, yangModelPrefix,
+                containerName);
+        ListSchemaNodeBuilder listBuilder = moduleBuilder.addListNode(
+                containerQName, actualPath);
+        updatePath(containerName);
+
+        listBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
+        parseSchemaNodeArgs(ctx, listBuilder);
+        parseConstraints(ctx, listBuilder.getConstraintsBuilder());
+
+        String keyDefinition = "";
+        for (int i = 0; i < ctx.getChildCount(); ++i) {
+            ParseTree childNode = ctx.getChild(i);
+            if (childNode instanceof Ordered_by_stmtContext) {
+                final Ordered_by_stmtContext orderedBy = (Ordered_by_stmtContext) childNode;
+                final boolean userOrdered = parseUserOrdered(orderedBy);
+                listBuilder.setUserOrdered(userOrdered);
+            } else if (childNode instanceof Key_stmtContext) {
+                keyDefinition = stringFromNode(childNode);
+                List<QName> key = createListKey(keyDefinition, namespace,
+                        revision, yangModelPrefix);
+                listBuilder.setKeyDefinition(key);
+            }
+        }
+    }
+
+    @Override
+    public void exitList_stmt(List_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterNotification_stmt(YangParser.Notification_stmtContext ctx) {
+        final String notificationName = stringFromNode(ctx);
+        QName notificationQName = new QName(namespace, revision,
+                yangModelPrefix, notificationName);
+        NotificationBuilder notificationBuilder = moduleBuilder
+                .addNotification(notificationQName, actualPath);
+        updatePath(notificationName);
+
+        notificationBuilder.setPath(createActualSchemaPath(actualPath, namespace,
+                revision, yangModelPrefix));
+        parseSchemaNodeArgs(ctx, notificationBuilder);
+    }
+
+    @Override
+    public void exitNotification_stmt(YangParser.Notification_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    // Unknown types
+    @Override
+    public void enterIdentifier_stmt(YangParser.Identifier_stmtContext ctx) {
+        String name = stringFromNode(ctx);
+
+        QName qname;
+        if(name != null) {
+            String[] splittedName = name.split(":");
+            if(splittedName.length == 2) {
+                qname = new QName(null, null, splittedName[0], splittedName[1]);
+            } else {
+                qname = new QName(namespace, revision, yangModelPrefix, splittedName[0]);
+            }
+        } else {
+            qname = new QName(namespace, revision, yangModelPrefix, name);
+        }
+
+        UnknownSchemaNodeBuilder builder = moduleBuilder.addUnknownSchemaNode(qname, getActualPath());
+        updatePath(name);
+
+        builder.setPath(createActualSchemaPath(actualPath, namespace, revision, yangModelPrefix));
+        parseSchemaNodeArgs(ctx, builder);
+    }
+
+    @Override
+    public void exitIdentifier_stmt(YangParser.Identifier_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterRpc_stmt(YangParser.Rpc_stmtContext ctx) {
+        final String rpcName = stringFromNode(ctx);
+        QName rpcQName = new QName(namespace, revision, yangModelPrefix,
+                rpcName);
+        RpcDefinitionBuilder rpcBuilder = moduleBuilder.addRpc(rpcQName,
+                actualPath);
+        updatePath(rpcName);
+
+        rpcBuilder.setPath(createActualSchemaPath(actualPath, namespace, revision,
+                yangModelPrefix));
+        parseSchemaNodeArgs(ctx, rpcBuilder);
+    }
+
+    @Override
+    public void exitRpc_stmt(YangParser.Rpc_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterInput_stmt(YangParser.Input_stmtContext ctx) {
+        updatePath("input");
+    }
+
+    @Override
+    public void exitInput_stmt(YangParser.Input_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterOutput_stmt(YangParser.Output_stmtContext ctx) {
+        updatePath("output");
+    }
+
+    @Override
+    public void exitOutput_stmt(YangParser.Output_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterFeature_stmt(YangParser.Feature_stmtContext ctx) {
+        final String featureName = stringFromNode(ctx);
+        QName featureQName = new QName(namespace, revision, yangModelPrefix,
+                featureName);
+        FeatureBuilder featureBuilder = moduleBuilder.addFeature(featureQName,
+                actualPath);
+        updatePath(featureName);
+
+        featureBuilder.setPath(createActualSchemaPath(actualPath, namespace,
+                revision, yangModelPrefix));
+        parseSchemaNodeArgs(ctx, featureBuilder);
+    }
+
+    @Override
+    public void exitFeature_stmt(YangParser.Feature_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterDeviation_stmt(YangParser.Deviation_stmtContext ctx) {
+        final String targetPath = stringFromNode(ctx);
+        String reference = null;
+        String deviate = null;
+        DeviationBuilder builder = moduleBuilder.addDeviation(targetPath);
+        updatePath(targetPath);
+
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Reference_stmtContext) {
+                reference = stringFromNode(child);
+            } else if (child instanceof Deviate_not_supported_stmtContext) {
+                deviate = stringFromNode(child);
+            } else if (child instanceof Deviate_add_stmtContext) {
+                deviate = stringFromNode(child);
+            } else if (child instanceof Deviate_replace_stmtContext) {
+                deviate = stringFromNode(child);
+            } else if (child instanceof Deviate_delete_stmtContext) {
+                deviate = stringFromNode(child);
+            }
+        }
+        builder.setReference(reference);
+        builder.setDeviate(deviate);
+    }
+
+    @Override
+    public void exitDeviation_stmt(YangParser.Deviation_stmtContext ctx) {
+        final String actContainer = actualPath.pop();
+        logger.debug("exiting " + actContainer);
+    }
+
+    @Override
+    public void enterConfig_stmt(YangParser.Config_stmtContext ctx) {
+        boolean configuration = parseConfig(ctx);
+        moduleBuilder.addConfiguration(configuration, actualPath);
+    }
+
+    public ModuleBuilder getModuleBuilder() {
+        return moduleBuilder;
+    }
+
+    private void updatePath(String containerName) {
+        actualPath.push(containerName);
+    }
+
+    private List<String> getActualPath() {
+        return Collections.unmodifiableList(actualPath);
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/YangModelBuilderUtil.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/main/java/org/opendaylight/controller/yang/model/parser/util/YangModelBuilderUtil.java
new file mode 100644 (file)
index 0000000..022798e
--- /dev/null
@@ -0,0 +1,1094 @@
+/*
+ * 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/eplv10.html
+ */
+package org.opendaylight.controller.yang.model.parser.util;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Stack;
+
+import org.antlr.v4.runtime.tree.ParseTree;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Bit_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Bits_specificationContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Config_argContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Config_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Decimal64_specificationContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Description_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Enum_specificationContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Enum_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Fraction_digits_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Leafref_specificationContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Length_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Mandatory_argContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Mandatory_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Max_elements_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Min_elements_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Must_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Numerical_restrictionsContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Ordered_by_argContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Ordered_by_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Path_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Pattern_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Position_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Range_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Reference_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Require_instance_argContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Require_instance_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Status_argContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Status_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.StringContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.String_restrictionsContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Type_body_stmtsContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.Units_stmtContext;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser.When_stmtContext;
+import org.opendaylight.controller.model.api.type.BitsTypeDefinition;
+import org.opendaylight.controller.model.api.type.BitsTypeDefinition.Bit;
+import org.opendaylight.controller.model.api.type.EnumTypeDefinition;
+import org.opendaylight.controller.model.api.type.LengthConstraint;
+import org.opendaylight.controller.model.api.type.PatternConstraint;
+import org.opendaylight.controller.model.api.type.RangeConstraint;
+import org.opendaylight.controller.model.util.BaseConstraints;
+import org.opendaylight.controller.model.util.BinaryType;
+import org.opendaylight.controller.model.util.BitsType;
+import org.opendaylight.controller.model.util.EnumerationType;
+import org.opendaylight.controller.model.util.InstanceIdentifier;
+import org.opendaylight.controller.model.util.Leafref;
+import org.opendaylight.controller.model.util.RevisionAwareXPathImpl;
+import org.opendaylight.controller.model.util.StringType;
+import org.opendaylight.controller.model.util.UnknownType;
+import org.opendaylight.controller.model.util.YangTypesConverter;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.SchemaNodeBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ConstraintsBuilder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class YangModelBuilderUtil {
+
+    private static final Logger logger = LoggerFactory
+            .getLogger(YangModelBuilderUtil.class);
+
+    /**
+     * Parse given tree and get first string value.
+     *
+     * @param treeNode
+     *            tree to parse
+     * @return first string value from given tree
+     */
+    public static String stringFromNode(final ParseTree treeNode) {
+        final String result = "";
+        for (int i = 0; i < treeNode.getChildCount(); ++i) {
+            if (treeNode.getChild(i) instanceof StringContext) {
+                final StringContext context = (StringContext) treeNode
+                        .getChild(i);
+                if (context != null) {
+                    return context.getChild(0).getText().replace("\"", "");
+                }
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Parse 'description', 'reference' and 'status' statements and fill in
+     * given builder.
+     *
+     * @param ctx
+     *            context to parse
+     * @param builder
+     *            builder to fill in with parsed statements
+     */
+    public static void parseSchemaNodeArgs(ParseTree ctx,
+            SchemaNodeBuilder builder) {
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Description_stmtContext) {
+                String desc = stringFromNode(child);
+                builder.setDescription(desc);
+            } else if (child instanceof Reference_stmtContext) {
+                String ref = stringFromNode(child);
+                builder.setReference(ref);
+            } else if (child instanceof Status_stmtContext) {
+                Status status = parseStatus((Status_stmtContext) child);
+                builder.setStatus(status);
+            }
+        }
+    }
+
+    /**
+     * Parse given context and return its value;
+     *
+     * @param ctx
+     *            status context
+     * @return value parsed from context
+     */
+    public static Status parseStatus(Status_stmtContext ctx) {
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree statusArg = ctx.getChild(i);
+            if (statusArg instanceof Status_argContext) {
+                String statusArgStr = stringFromNode(statusArg);
+                if (statusArgStr.equals("current")) {
+                    return Status.CURRENT;
+                } else if (statusArgStr.equals("deprecated")) {
+                    return Status.DEPRECATED;
+                } else if (statusArgStr.equals("obsolete")) {
+                    return Status.OBSOLETE;
+                } else {
+                    logger.warn("Invalid 'status' statement: " + statusArgStr);
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Parse given tree and returns units statement as string.
+     *
+     * @param ctx
+     *            context to parse
+     * @return value of units statement as string or null if there is no units
+     *         statement
+     */
+    public static String parseUnits(ParseTree ctx) {
+        String units = null;
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Units_stmtContext) {
+                units = stringFromNode(child);
+                break;
+            }
+        }
+        return units;
+    }
+
+    /**
+     * Create SchemaPath object from given path list with namespace, revision
+     * and prefix based on given values.
+     *
+     * @param actualPath
+     * @param namespace
+     * @param revision
+     * @param prefix
+     * @return SchemaPath object.
+     */
+    public static SchemaPath createActualSchemaPath(List<String> actualPath,
+            URI namespace, Date revision, String prefix) {
+        final List<QName> path = new ArrayList<QName>();
+        QName qname;
+        for (String pathElement : actualPath) {
+            qname = new QName(namespace, revision, prefix, pathElement);
+            path.add(qname);
+        }
+        return new SchemaPath(path, true);
+    }
+
+    /**
+     * Create SchemaPath from given string.
+     *
+     * @param augmentPath
+     *            string representation of path
+     * @return SchemaPath object
+     */
+    public static SchemaPath parseAugmentPath(String augmentPath) {
+        boolean absolute = augmentPath.startsWith("/");
+        String[] splittedPath = augmentPath.split("/");
+        List<QName> path = new ArrayList<QName>();
+        QName name;
+        for (String pathElement : splittedPath) {
+            if (pathElement.length() > 0) {
+                String[] splittedElement = pathElement.split(":");
+                if (splittedElement.length == 1) {
+                    name = new QName(null, null, null, splittedElement[0]);
+                } else {
+                    name = new QName(null, null, splittedElement[0],
+                            splittedElement[1]);
+                }
+                path.add(name);
+            }
+        }
+        return new SchemaPath(path, absolute);
+    }
+
+    /**
+     * Create java.util.List of QName objects from given key definition as
+     * string.
+     *
+     * @param keyDefinition
+     *            key definition as string
+     * @param namespace
+     *            current namespace
+     * @param revision
+     *            current revision
+     * @param prefix
+     *            current prefix
+     * @return YANG list key as java.util.List of QName objects
+     */
+    public static List<QName> createListKey(String keyDefinition,
+            URI namespace, Date revision, String prefix) {
+        List<QName> key = new ArrayList<QName>();
+        String[] splittedKey = keyDefinition.split(" ");
+
+        QName qname = null;
+        for (String keyElement : splittedKey) {
+            if (keyElement.length() != 0) {
+                qname = new QName(namespace, revision, prefix, keyElement);
+                key.add(qname);
+            }
+        }
+        return key;
+    }
+
+    private static List<EnumTypeDefinition.EnumPair> getEnumConstants(
+            Type_body_stmtsContext ctx, List<String> path, URI namespace,
+            Date revision, String prefix) {
+        List<EnumTypeDefinition.EnumPair> enumConstants = new ArrayList<EnumTypeDefinition.EnumPair>();
+
+        out: for (int j = 0; j < ctx.getChildCount(); j++) {
+            ParseTree enumSpecChild = ctx.getChild(j);
+            if (enumSpecChild instanceof Enum_specificationContext) {
+                for (int k = 0; k < enumSpecChild.getChildCount(); k++) {
+                    ParseTree enumChild = enumSpecChild.getChild(k);
+                    if (enumChild instanceof Enum_stmtContext) {
+                        enumConstants.add(createEnumPair(
+                                (Enum_stmtContext) enumChild, k, path,
+                                namespace, revision, prefix));
+                        if (k == enumSpecChild.getChildCount() - 1) {
+                            break out;
+                        }
+                    }
+                }
+            }
+        }
+        return enumConstants;
+    }
+
+    private static EnumTypeDefinition.EnumPair createEnumPair(
+            Enum_stmtContext ctx, final int value, List<String> path,
+            final URI namespace, final Date revision, final String prefix) {
+        final String name = stringFromNode(ctx);
+        final QName qname = new QName(namespace, revision, prefix, name);
+        String description = null;
+        String reference = null;
+        Status status = null;
+        List<String> enumPairPath = new ArrayList<String>(path);
+        enumPairPath.add(name);
+
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Description_stmtContext) {
+                description = stringFromNode(child);
+            } else if (child instanceof Reference_stmtContext) {
+                reference = stringFromNode(child);
+            } else if (child instanceof Status_stmtContext) {
+                status = parseStatus((Status_stmtContext) child);
+            }
+        }
+
+        EnumPairImpl result = new EnumPairImpl();
+        result.qname = qname;
+        result.path = createActualSchemaPath(enumPairPath, namespace, revision,
+                prefix);
+        result.description = description;
+        result.reference = reference;
+        result.status = status;
+        // TODO: extensionSchemaNodes
+        result.name = name;
+        result.value = value;
+        return result;
+    }
+
+    private static class EnumPairImpl implements EnumTypeDefinition.EnumPair {
+
+        private QName qname;
+        private SchemaPath path;
+        private String description;
+        private String reference;
+        private Status status;
+        private List<UnknownSchemaNode> extensionSchemaNodes = Collections
+                .emptyList();
+        private String name;
+        private Integer value;
+
+        @Override
+        public QName getQName() {
+            return qname;
+        }
+
+        @Override
+        public SchemaPath getPath() {
+            return path;
+        }
+
+        @Override
+        public String getDescription() {
+            return description;
+        }
+
+        @Override
+        public String getReference() {
+            return reference;
+        }
+
+        @Override
+        public Status getStatus() {
+            return status;
+        }
+
+        @Override
+        public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+            return extensionSchemaNodes;
+        }
+
+        @Override
+        public String getName() {
+            return name;
+        }
+
+        @Override
+        public Integer getValue() {
+            return value;
+        }
+
+        @Override
+        public int hashCode() {
+            final int prime = 31;
+            int result = 1;
+            result = prime * result + ((qname == null) ? 0 : qname.hashCode());
+            result = prime * result + ((path == null) ? 0 : path.hashCode());
+            result = prime * result
+                    + ((description == null) ? 0 : description.hashCode());
+            result = prime * result
+                    + ((reference == null) ? 0 : reference.hashCode());
+            result = prime * result
+                    + ((status == null) ? 0 : status.hashCode());
+            result = prime
+                    * result
+                    + ((extensionSchemaNodes == null) ? 0
+                            : extensionSchemaNodes.hashCode());
+            result = prime * result + ((name == null) ? 0 : name.hashCode());
+            result = prime * result + ((value == null) ? 0 : value.hashCode());
+            return result;
+        }
+
+        @Override
+        public boolean equals(Object obj) {
+            if (this == obj) {
+                return true;
+            }
+            if (obj == null) {
+                return false;
+            }
+            if (getClass() != obj.getClass()) {
+                return false;
+            }
+            EnumPairImpl other = (EnumPairImpl) obj;
+            if (qname == null) {
+                if (other.qname != null) {
+                    return false;
+                }
+            } else if (!qname.equals(other.qname)) {
+                return false;
+            }
+            if (path == null) {
+                if (other.path != null) {
+                    return false;
+                }
+            } else if (!path.equals(other.path)) {
+                return false;
+            }
+            if (description == null) {
+                if (other.description != null) {
+                    return false;
+                }
+            } else if (!description.equals(other.description)) {
+                return false;
+            }
+            if (reference == null) {
+                if (other.reference != null) {
+                    return false;
+                }
+            } else if (!reference.equals(other.reference)) {
+                return false;
+            }
+            if (status == null) {
+                if (other.status != null) {
+                    return false;
+                }
+            } else if (!status.equals(other.status)) {
+                return false;
+            }
+            if (extensionSchemaNodes == null) {
+                if (other.extensionSchemaNodes != null) {
+                    return false;
+                }
+            } else if (!extensionSchemaNodes.equals(other.extensionSchemaNodes)) {
+                return false;
+            }
+            if (name == null) {
+                if (other.name != null) {
+                    return false;
+                }
+            } else if (!name.equals(other.name)) {
+                return false;
+            }
+            if (value == null) {
+                if (other.value != null) {
+                    return false;
+                }
+            } else if (!value.equals(other.value)) {
+                return false;
+            }
+            return true;
+        }
+
+        @Override
+        public String toString() {
+            return EnumTypeDefinition.EnumPair.class.getSimpleName() + "[name="
+                    + name + ", value=" + value + "]";
+        }
+    };
+
+    private static List<RangeConstraint> getRangeConstraints(
+            Type_body_stmtsContext ctx) {
+        final List<RangeConstraint> rangeConstraints = new ArrayList<RangeConstraint>();
+        for (int j = 0; j < ctx.getChildCount(); j++) {
+            ParseTree numRestrChild = ctx.getChild(j);
+            if (numRestrChild instanceof Numerical_restrictionsContext) {
+                for (int k = 0; k < numRestrChild.getChildCount(); k++) {
+                    ParseTree rangeChild = numRestrChild.getChild(k);
+                    if (rangeChild instanceof Range_stmtContext) {
+                        rangeConstraints
+                                .addAll(parseRangeConstraints((Range_stmtContext) rangeChild));
+                        break;
+                    }
+                }
+            }
+        }
+        return rangeConstraints;
+    }
+
+    private static List<RangeConstraint> parseRangeConstraints(
+            Range_stmtContext ctx) {
+        List<RangeConstraint> rangeConstraints = new ArrayList<RangeConstraint>();
+        String description = null;
+        String reference = null;
+
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Description_stmtContext) {
+                description = stringFromNode(child);
+            } else if (child instanceof Reference_stmtContext) {
+                reference = stringFromNode(child);
+            }
+        }
+
+        String rangeStr = stringFromNode(ctx);
+        String trimmed = rangeStr.replace(" ", "");
+        String[] splittedRange = trimmed.split("\\|");
+        for (String rangeDef : splittedRange) {
+            String[] splittedRangeDef = rangeDef.split("\\.\\.");
+            Long min;
+            Long max;
+            if (splittedRangeDef.length == 1) {
+                min = max = parseRangeValue(splittedRangeDef[0]);
+            } else {
+                min = parseRangeValue(splittedRangeDef[0]);
+                max = parseRangeValue(splittedRangeDef[1]);
+            }
+            RangeConstraint range = BaseConstraints.rangeConstraint(min, max,
+                    description, reference);
+            rangeConstraints.add(range);
+        }
+
+        return rangeConstraints;
+    }
+
+    private static List<LengthConstraint> getLengthConstraints(
+            Type_body_stmtsContext ctx) {
+        List<LengthConstraint> lengthConstraints = new ArrayList<LengthConstraint>();
+        for (int j = 0; j < ctx.getChildCount(); j++) {
+            ParseTree stringRestrChild = ctx.getChild(j);
+            if (stringRestrChild instanceof String_restrictionsContext) {
+                for (int k = 0; k < stringRestrChild.getChildCount(); k++) {
+                    ParseTree lengthChild = stringRestrChild.getChild(k);
+                    if (lengthChild instanceof Length_stmtContext) {
+                        lengthConstraints
+                                .addAll(parseLengthConstraints((Length_stmtContext) lengthChild));
+                    }
+                }
+            }
+        }
+        return lengthConstraints;
+    }
+
+    private static List<LengthConstraint> parseLengthConstraints(
+            Length_stmtContext ctx) {
+        List<LengthConstraint> lengthConstraints = new ArrayList<LengthConstraint>();
+        String description = null;
+        String reference = null;
+
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Description_stmtContext) {
+                description = stringFromNode(child);
+            } else if (child instanceof Reference_stmtContext) {
+                reference = stringFromNode(child);
+            }
+        }
+
+        String lengthStr = stringFromNode(ctx);
+        String trimmed = lengthStr.replace(" ", "");
+        String[] splittedRange = trimmed.split("\\|");
+        for (String rangeDef : splittedRange) {
+            String[] splittedRangeDef = rangeDef.split("\\.\\.");
+            Long min;
+            Long max;
+            if (splittedRangeDef.length == 1) {
+                min = max = parseRangeValue(splittedRangeDef[0]);
+            } else {
+                min = parseRangeValue(splittedRangeDef[0]);
+                max = parseRangeValue(splittedRangeDef[1]);
+            }
+            LengthConstraint range = BaseConstraints.lengthConstraint(min, max,
+                    description, reference);
+            lengthConstraints.add(range);
+        }
+
+        return lengthConstraints;
+    }
+
+    private static Long parseRangeValue(String value) {
+        Long result = null;
+        if (value.equals("min")) {
+            result = Long.MIN_VALUE;
+        } else if (value.equals("max")) {
+            result = Long.MAX_VALUE;
+        } else {
+            result = Long.valueOf(value);
+        }
+        return result;
+    }
+
+    private static List<PatternConstraint> getPatternConstraint(
+            Type_body_stmtsContext ctx) {
+        List<PatternConstraint> patterns = new ArrayList<PatternConstraint>();
+
+        out: for (int j = 0; j < ctx.getChildCount(); j++) {
+            ParseTree stringRestrChild = ctx.getChild(j);
+            if (stringRestrChild instanceof String_restrictionsContext) {
+                for (int k = 0; k < stringRestrChild.getChildCount(); k++) {
+                    ParseTree lengthChild = stringRestrChild.getChild(k);
+                    if (lengthChild instanceof Pattern_stmtContext) {
+                        patterns.add(parsePatternConstraint((Pattern_stmtContext) lengthChild));
+                        if (k == lengthChild.getChildCount() - 1) {
+                            break out;
+                        }
+                    }
+                }
+            }
+        }
+        return patterns;
+    }
+
+    /**
+     * Internal helper method.
+     *
+     * @param ctx
+     *            pattern context
+     * @return PatternConstraint object
+     */
+    private static PatternConstraint parsePatternConstraint(
+            Pattern_stmtContext ctx) {
+        String description = null;
+        String reference = null;
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Description_stmtContext) {
+                description = stringFromNode(child);
+            } else if (child instanceof Reference_stmtContext) {
+                reference = stringFromNode(child);
+            }
+        }
+        String pattern = stringFromNode(ctx);
+        return BaseConstraints.patternConstraint(pattern, description,
+                reference);
+    }
+
+    private static Integer getFractionDigits(Type_body_stmtsContext ctx) {
+        for (int j = 0; j < ctx.getChildCount(); j++) {
+            ParseTree dec64specChild = ctx.getChild(j);
+            if (dec64specChild instanceof Decimal64_specificationContext) {
+                return parseFractionDigits((Decimal64_specificationContext) dec64specChild);
+            }
+        }
+        return null;
+    }
+
+    private static Integer parseFractionDigits(
+            Decimal64_specificationContext ctx) {
+        for (int k = 0; k < ctx.getChildCount(); k++) {
+            ParseTree fdChild = ctx.getChild(k);
+            if (fdChild instanceof Fraction_digits_stmtContext) {
+                return Integer.valueOf(stringFromNode(fdChild));
+            }
+        }
+        return null;
+    }
+
+    private static List<BitsTypeDefinition.Bit> getBits(
+            Type_body_stmtsContext ctx, List<String> actualPath, URI namespace,
+            Date revision, String prefix) {
+        List<BitsTypeDefinition.Bit> bits = new ArrayList<BitsTypeDefinition.Bit>();
+        for (int j = 0; j < ctx.getChildCount(); j++) {
+            ParseTree bitsSpecChild = ctx.getChild(j);
+            if (bitsSpecChild instanceof Bits_specificationContext) {
+                for (int k = 0; k < bitsSpecChild.getChildCount(); k++) {
+                    ParseTree bitChild = bitsSpecChild.getChild(k);
+                    if (bitChild instanceof Bit_stmtContext) {
+                        bits.add(parseBit((Bit_stmtContext) bitChild,
+                                actualPath, namespace, revision, prefix));
+                    }
+                }
+            }
+        }
+        return bits;
+    }
+
+    private static boolean isRequireInstance(Type_body_stmtsContext ctx) {
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Require_instance_stmtContext) {
+                for (int j = 0; j < child.getChildCount(); j++) {
+                    ParseTree reqArg = child.getChild(j);
+                    if (reqArg instanceof Require_instance_argContext) {
+                        return Boolean.valueOf(stringFromNode(reqArg));
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    private static BitsTypeDefinition.Bit parseBit(final Bit_stmtContext ctx,
+            List<String> actualPath, final URI namespace, final Date revision,
+            final String prefix) {
+        String name = stringFromNode(ctx);
+        final QName qname = new QName(namespace, revision, prefix, name);
+        Long position = null;
+
+        String description = null;
+        String reference = null;
+        Status status = Status.CURRENT;
+
+        Stack<String> bitPath = new Stack<String>();
+        bitPath.addAll(actualPath);
+        bitPath.add(name);
+
+        SchemaPath schemaPath = createActualSchemaPath(bitPath, namespace,
+                revision, prefix);
+
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Position_stmtContext) {
+                String positionStr = stringFromNode(child);
+                position = Long.valueOf(positionStr);
+                if (position < 0 || position > 4294967295L) {
+                    throw new IllegalArgumentException(
+                            "position value MUST be in the range 0 to 4294967295, but was: "
+                                    + position);
+                }
+            } else if (child instanceof Description_stmtContext) {
+                description = stringFromNode(child);
+            } else if (child instanceof Reference_stmtContext) {
+                reference = stringFromNode(child);
+            } else if (child instanceof Status_stmtContext) {
+                status = parseStatus((Status_stmtContext) child);
+            }
+        }
+
+        // TODO: extensionDefinitions
+        return createBit(qname, schemaPath, description, reference, status,
+                null, position);
+    }
+
+    private static BitsTypeDefinition.Bit createBit(final QName qname,
+            final SchemaPath schemaPath, final String description,
+            final String reference, final Status status,
+            final List<UnknownSchemaNode> extensionDefinitions,
+            final Long position) {
+        return new BitsTypeDefinition.Bit() {
+
+            @Override
+            public QName getQName() {
+                return qname;
+            }
+
+            @Override
+            public SchemaPath getPath() {
+                return schemaPath;
+            }
+
+            @Override
+            public String getDescription() {
+                return description;
+            }
+
+            @Override
+            public String getReference() {
+                return reference;
+            }
+
+            @Override
+            public Status getStatus() {
+                return status;
+            }
+
+            @Override
+            public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+                return extensionDefinitions;
+            }
+
+            @Override
+            public Long getPosition() {
+                return position;
+            }
+
+            @Override
+            public String getName() {
+                return qname.getLocalName();
+            }
+
+            @Override
+            public int hashCode() {
+                final int prime = 31;
+                int result = 1;
+                result = prime * result
+                        + ((qname == null) ? 0 : qname.hashCode());
+                result = prime * result
+                        + ((schemaPath == null) ? 0 : schemaPath.hashCode());
+                result = prime * result
+                        + ((description == null) ? 0 : description.hashCode());
+                result = prime * result
+                        + ((reference == null) ? 0 : reference.hashCode());
+                result = prime * result
+                        + ((status == null) ? 0 : status.hashCode());
+                result = prime * result
+                        + ((position == null) ? 0 : position.hashCode());
+                result = prime
+                        * result
+                        + ((extensionDefinitions == null) ? 0
+                                : extensionDefinitions.hashCode());
+                return result;
+            }
+
+            @Override
+            public boolean equals(Object obj) {
+                if (this == obj) {
+                    return true;
+                }
+                if (obj == null) {
+                    return false;
+                }
+                if (getClass() != obj.getClass()) {
+                    return false;
+                }
+                Bit other = (Bit) obj;
+                if (qname == null) {
+                    if (other.getQName() != null) {
+                        return false;
+                    }
+                } else if (!qname.equals(other.getQName())) {
+                    return false;
+                }
+                if (schemaPath == null) {
+                    if (other.getPath() != null) {
+                        return false;
+                    }
+                } else if (!schemaPath.equals(other.getPath())) {
+                    return false;
+                }
+                if (description == null) {
+                    if (other.getDescription() != null) {
+                        return false;
+                    }
+                } else if (!description.equals(other.getDescription())) {
+                    return false;
+                }
+                if (reference == null) {
+                    if (other.getReference() != null) {
+                        return false;
+                    }
+                } else if (!reference.equals(other.getReference())) {
+                    return false;
+                }
+                if (status == null) {
+                    if (other.getStatus() != null) {
+                        return false;
+                    }
+                } else if (!status.equals(other.getStatus())) {
+                    return false;
+                }
+                if (extensionDefinitions == null) {
+                    if (other.getUnknownSchemaNodes() != null) {
+                        return false;
+                    }
+                } else if (!extensionDefinitions.equals(other
+                        .getUnknownSchemaNodes())) {
+                    return false;
+                }
+                if (position == null) {
+                    if (other.getPosition() != null) {
+                        return false;
+                    }
+                } else if (!position.equals(other.getPosition())) {
+                    return false;
+                }
+                return true;
+            }
+
+            @Override
+            public String toString() {
+                return Bit.class.getSimpleName() + "[name="
+                        + qname.getLocalName() + ", position=" + position + "]";
+            }
+        };
+    }
+
+    /**
+     * Parse orderedby statement.
+     *
+     * @param childNode
+     *            Ordered_by_stmtContext
+     * @return true, if orderedby contains value 'user' or false otherwise
+     */
+    public static boolean parseUserOrdered(Ordered_by_stmtContext childNode) {
+        boolean result = false;
+        for (int j = 0; j < childNode.getChildCount(); j++) {
+            ParseTree orderArg = childNode.getChild(j);
+            if (orderArg instanceof Ordered_by_argContext) {
+                String orderStr = stringFromNode(orderArg);
+                if (orderStr.equals("system")) {
+                    result = false;
+                } else if (orderStr.equals("user")) {
+                    result = true;
+                } else {
+                    logger.warn("Invalid 'orderedby' statement.");
+                }
+            }
+        }
+        return result;
+    }
+
+    /**
+     * Parse given config context and return true if it contains string 'true',
+     * false otherwise.
+     *
+     * @param ctx
+     *            config context to parse.
+     * @return true if given context contains string 'true', false otherwise
+     */
+    public static boolean parseConfig(final Config_stmtContext ctx) {
+        if (ctx != null) {
+            for (int i = 0; i < ctx.getChildCount(); ++i) {
+                final ParseTree configContext = ctx.getChild(i);
+                if (configContext instanceof Config_argContext) {
+                    final String value = stringFromNode(configContext);
+                    if (value.equals("true")) {
+                        return true;
+                    }
+                }
+            }
+        }
+        return false;
+    }
+
+    /**
+     * Parse given type body and creates UnknownType definition.
+     *
+     * @param typedefQName
+     *            qname of current type
+     * @param ctx
+     *            type body
+     * @return UnknownType object with constraints from parsed type body
+     */
+    public static TypeDefinition<?> parseUnknownTypeBody(QName typedefQName,
+            Type_body_stmtsContext ctx) {
+        UnknownType.Builder ut = new UnknownType.Builder(typedefQName);
+
+        if (ctx != null) {
+            List<RangeConstraint> rangeStatements = getRangeConstraints(ctx);
+            List<LengthConstraint> lengthStatements = getLengthConstraints(ctx);
+            List<PatternConstraint> patternStatements = getPatternConstraint(ctx);
+
+            ut.rangeStatements(rangeStatements);
+            ut.lengthStatements(lengthStatements);
+            ut.patterns(patternStatements);
+        }
+
+        return ut.build();
+    }
+
+    /**
+     * Create TypeDefinition object based on given type name and type body.
+     *
+     * @param typeName
+     *            name of type
+     * @param typeBody
+     *            type body
+     * @param actualPath
+     *            current path in schema
+     * @param namespace
+     *            current namespace
+     * @param revision
+     *            current revision
+     * @param prefix
+     *            current prefix
+     * @return TypeDefinition object based on parsed values.
+     */
+    public static TypeDefinition<?> parseTypeBody(String typeName,
+            Type_body_stmtsContext typeBody, List<String> actualPath,
+            URI namespace, Date revision, String prefix) {
+        TypeDefinition<?> type = null;
+
+        List<RangeConstraint> rangeStatements = getRangeConstraints(typeBody);
+        Integer fractionDigits = getFractionDigits(typeBody);
+        List<LengthConstraint> lengthStatements = getLengthConstraints(typeBody);
+        List<PatternConstraint> patternStatements = getPatternConstraint(typeBody);
+        List<EnumTypeDefinition.EnumPair> enumConstants = getEnumConstants(typeBody, actualPath, namespace, revision, prefix);
+
+        if (typeName.equals("decimal64")) {
+            type = YangTypesConverter.javaTypeForBaseYangDecimal64Type(
+                    rangeStatements, fractionDigits);
+        } else if (typeName.startsWith("int") || typeName.startsWith("uint")) {
+            type = YangTypesConverter.javaTypeForBaseYangIntegerType(typeName,
+                    rangeStatements);
+        } else if (typeName.equals("enumeration")) {
+            type = new EnumerationType(enumConstants);
+        } else if (typeName.equals("string")) {
+            type = new StringType(lengthStatements, patternStatements);
+        } else if (typeName.equals("bits")) {
+            type = new BitsType(getBits(typeBody, actualPath, namespace,
+                    revision, prefix));
+        } else if (typeName.equals("leafref")) {
+            final String path = parseLeafrefPath(typeBody);
+            final boolean absolute = path.startsWith("/");
+            RevisionAwareXPath xpath = new RevisionAwareXPathImpl(path,
+                    absolute);
+            type = new Leafref(xpath);
+        } else if (typeName.equals("binary")) {
+            type = new BinaryType(null, lengthStatements, null);
+        } else if (typeName.equals("instanceidentifier")) {
+            boolean requireInstance = isRequireInstance(typeBody);
+            type = new InstanceIdentifier(null, requireInstance);
+        }
+        return type;
+    }
+
+    private static String parseLeafrefPath(Type_body_stmtsContext ctx) {
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof Leafref_specificationContext) {
+                for (int j = 0; j < child.getChildCount(); j++) {
+                    ParseTree leafRefSpec = child.getChild(j);
+                    if (leafRefSpec instanceof Path_stmtContext) {
+                        return stringFromNode(leafRefSpec);
+                    }
+                }
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Internal helper method for parsing Must_stmtContext.
+     *
+     * @param ctx
+     *            Must_stmtContext
+     * @return an array of strings with following fields: [0] must text [1]
+     *         description [2] reference
+     */
+    public static String[] parseMust(YangParser.Must_stmtContext ctx) {
+        String[] params = new String[3];
+
+        String mustText = "";
+        String description = null;
+        String reference = null;
+        for (int i = 0; i < ctx.getChildCount(); ++i) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof StringContext) {
+                final StringContext context = (StringContext) child;
+                for (int j = 0; j < context.getChildCount(); j++) {
+                    String mustPart = context.getChild(j).getText();
+                    if (j == 0) {
+                        mustText += mustPart
+                                .substring(0, mustPart.length() - 1);
+                        continue;
+                    }
+                    if (j % 2 == 0) {
+                        mustText += mustPart.substring(1);
+                    }
+                }
+            } else if (child instanceof Description_stmtContext) {
+                description = stringFromNode(child);
+            } else if (child instanceof Reference_stmtContext) {
+                reference = stringFromNode(child);
+            }
+        }
+        params[0] = mustText;
+        params[1] = description;
+        params[2] = reference;
+
+        return params;
+    }
+
+    /**
+     * Parse given tree and set constraints to given builder.
+     *
+     * @param ctx
+     *            Context to search.
+     * @param constraintsBuilder
+     *            ConstraintsBuilder to fill.
+     */
+    public static void parseConstraints(ParseTree ctx,
+            ConstraintsBuilder constraintsBuilder) {
+        for (int i = 0; i < ctx.getChildCount(); ++i) {
+            final ParseTree childNode = ctx.getChild(i);
+            if (childNode instanceof Max_elements_stmtContext) {
+                Integer max = Integer.valueOf(stringFromNode(childNode));
+                constraintsBuilder.setMinElements(max);
+            } else if (childNode instanceof Min_elements_stmtContext) {
+                Integer min = Integer.valueOf(stringFromNode(childNode));
+                constraintsBuilder.setMinElements(min);
+            } else if (childNode instanceof Must_stmtContext) {
+                String[] mustParams = parseMust((Must_stmtContext) childNode);
+                constraintsBuilder.addMustDefinition(mustParams[0],
+                        mustParams[1], mustParams[2]);
+            } else if (childNode instanceof Mandatory_stmtContext) {
+                for (int j = 0; j < childNode.getChildCount(); j++) {
+                    ParseTree mandatoryTree = ctx.getChild(j);
+                    if (mandatoryTree instanceof Mandatory_argContext) {
+                        Boolean mandatory = Boolean
+                                .valueOf(stringFromNode(mandatoryTree));
+                        constraintsBuilder.setMandatory(mandatory);
+                    }
+                }
+            } else if (childNode instanceof When_stmtContext) {
+                constraintsBuilder.addWhenCondition(stringFromNode(childNode));
+            }
+        }
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/builder/ContainerSchemaNodeBuilderTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/builder/ContainerSchemaNodeBuilderTest.java
deleted file mode 100644 (file)
index 55e1197..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import static org.junit.Assert.*;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.net.URI;\r
-import java.util.Date;\r
-import java.util.HashSet;\r
-import java.util.Set;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.model.parser.builder.ContainerSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.builder.MustDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.builder.TypedefBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
-import org.opendaylight.controller.yang.model.api.ConstraintDefinition;\r
-import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.controller.yang.model.api.MustDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-\r
-public class ContainerSchemaNodeBuilderTest {\r
-\r
-       private ContainerSchemaNodeBuilder tested;\r
-\r
-       private final String NAME = "test-container";\r
-\r
-       private final URI namespace = URI.create("test:container.name");\r
-       private final Date revision = new Date();\r
-       private final String prefix = "x";\r
-\r
-       private SchemaPath schemaPath;\r
-       private final String description = "description of container";\r
-       private final String reference = "reference";\r
-\r
-       private QName typedefQName;\r
-       private TypedefBuilder typeBuilder;\r
-       @Mock private AugmentationSchema augment;\r
-       @Mock private ConstraintDefinition constraint;\r
-       @Mock private UsesNodeBuilder usesBuilder;\r
-       @Mock private UsesNode uses;\r
-       @Mock private MustDefinitionBuilder mustBuilder;\r
-       @Mock private MustDefinition must;\r
-       @Mock private GroupingBuilder groupingBuilder;\r
-       @Mock private GroupingDefinition grouping;\r
-\r
-       @Before\r
-       public void init() {\r
-               MockitoAnnotations.initMocks(this);\r
-               when(usesBuilder.build()).thenReturn(uses);\r
-               when(mustBuilder.build()).thenReturn(must);\r
-               when(groupingBuilder.build()).thenReturn(grouping);\r
-\r
-               schemaPath = TestUtils.createSchemaPath(true, namespace, "main", "interface");\r
-               typedefQName = new QName(namespace, "test-type");\r
-               typeBuilder = new TypedefBuilder(typedefQName);\r
-\r
-               QName qname = new QName(namespace, revision, prefix, NAME);\r
-               tested = new ContainerSchemaNodeBuilder(qname);\r
-       }\r
-\r
-       @Test\r
-       public void test() {\r
-               tested.addTypedef(typeBuilder);\r
-               tested.setPath(schemaPath);\r
-               tested.setDescription(description);\r
-               tested.setReference(reference);\r
-               tested.setStatus(Status.OBSOLOTE);\r
-               tested.setConfiguration(false);\r
-               tested.setConstraints(constraint);\r
-               tested.addUsesNode(usesBuilder);\r
-               tested.addAugmentation(augment);\r
-               tested.setMustDefinitionBuilder(mustBuilder);\r
-               tested.setPresenceContainer(true);\r
-\r
-               ContainerSchemaNode result = tested.build();\r
-\r
-               Set<TypeDefinition<?>> expectedTypedefs = result.getTypeDefinitions();\r
-               assertEquals(1, expectedTypedefs.size());\r
-               assertEquals(typedefQName, expectedTypedefs.iterator().next().getQName());\r
-\r
-               Set<AugmentationSchema> expectedAugments = new HashSet<AugmentationSchema>();\r
-               expectedAugments.add(augment);\r
-               assertEquals(expectedAugments, result.getAvailableAugmentations());\r
-\r
-               assertEquals(schemaPath, result.getPath());\r
-               assertEquals(description, result.getDescription());\r
-               assertEquals(reference, result.getReference());\r
-               assertEquals(Status.OBSOLOTE, result.getStatus());\r
-               assertFalse(result.isConfiguration());\r
-               assertEquals(constraint, result.getConstraints());\r
-\r
-               Set<UsesNode> expectedUses = new HashSet<UsesNode>();\r
-               expectedUses.add(uses);\r
-               assertEquals(expectedUses, result.getUses());\r
-\r
-               assertTrue(result.isPresenceContainer());\r
-               assertEquals(must, result.getMustDefinition());\r
-       }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/builder/LeafListSchemaNodeBuilderTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/builder/LeafListSchemaNodeBuilderTest.java
deleted file mode 100644 (file)
index 9df458a..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import static org.junit.Assert.*;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.net.URI;\r
-import java.util.Date;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.model.parser.builder.LeafSchemaNodeBuilder;\r
-import org.opendaylight.controller.model.parser.builder.MustDefinitionBuilder;\r
-import org.opendaylight.controller.model.parser.builder.TypedefBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ConstraintDefinition;\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.controller.yang.model.api.LeafSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.MustDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-\r
-public class LeafListSchemaNodeBuilderTest {\r
-\r
-       private LeafSchemaNodeBuilder tested;\r
-\r
-       private final String NAME = "test-leaf";\r
-\r
-       private final URI namespace = URI.create("test:leaf.name");\r
-       private final Date revision = new Date();\r
-       private final String prefix = "x";\r
-\r
-       private SchemaPath schemaPath;\r
-       private final String description = "description of container";\r
-       private final String reference = "reference";\r
-\r
-       private QName typedefQName;\r
-       private TypeDefinition<?> type;\r
-       @Mock private ConstraintDefinition constraint;\r
-       @Mock private UsesNodeBuilder usesBuilder;\r
-       @Mock private UsesNode uses;\r
-       @Mock private MustDefinitionBuilder mustBuilder;\r
-       @Mock private MustDefinition must;\r
-       @Mock private GroupingBuilder groupingBuilder;\r
-       @Mock private GroupingDefinition grouping;\r
-\r
-       @Before\r
-       public void init() {\r
-               MockitoAnnotations.initMocks(this);\r
-               when(usesBuilder.build()).thenReturn(uses);\r
-               when(mustBuilder.build()).thenReturn(must);\r
-               when(groupingBuilder.build()).thenReturn(grouping);\r
-\r
-               schemaPath = TestUtils.createSchemaPath(true, namespace, "main", "interface");\r
-               typedefQName = new QName(namespace, "test-type");\r
-               TypedefBuilder typeBuilder = new TypedefBuilder(typedefQName);\r
-               type = typeBuilder.build();\r
-\r
-               QName qname = new QName(namespace, revision, prefix, NAME);\r
-               tested = new LeafSchemaNodeBuilder(qname);\r
-       }\r
-\r
-       @Test\r
-       public void test() {\r
-               tested.setType(type);\r
-               tested.setPath(schemaPath);\r
-               tested.setDescription(description);\r
-               tested.setReference(reference);\r
-               tested.setStatus(Status.OBSOLOTE);\r
-               tested.setConfiguration(false);\r
-               tested.setConstraints(constraint);\r
-               tested.setMustDefinitionBuilder(mustBuilder);\r
-\r
-               LeafSchemaNode result = tested.build();\r
-\r
-               assertEquals(type, result.getType());\r
-               assertEquals(schemaPath, result.getPath());\r
-               assertEquals(description, result.getDescription());\r
-               assertEquals(reference, result.getReference());\r
-               assertEquals(Status.OBSOLOTE, result.getStatus());\r
-               assertFalse(result.isConfiguration());\r
-               assertEquals(constraint, result.getConstraints());\r
-               assertEquals(must, result.getMustDefinition());\r
-       }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/builder/ListSchemaNodeBuilderTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/builder/ListSchemaNodeBuilderTest.java
deleted file mode 100644 (file)
index 7085dae..0000000
+++ /dev/null
@@ -1,121 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import static org.junit.Assert.*;\r
-import static org.mockito.Mockito.when;\r
-\r
-import java.net.URI;\r
-import java.util.ArrayList;\r
-import java.util.Date;\r
-import java.util.HashSet;\r
-import java.util.List;\r
-import java.util.Set;\r
-\r
-import org.junit.Before;\r
-import org.junit.Test;\r
-import org.mockito.Mock;\r
-import org.mockito.MockitoAnnotations;\r
-import org.opendaylight.controller.model.parser.api.GroupingBuilder;\r
-import org.opendaylight.controller.model.parser.api.UsesNodeBuilder;\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.AugmentationSchema;\r
-import org.opendaylight.controller.yang.model.api.ConstraintDefinition;\r
-import org.opendaylight.controller.yang.model.api.GroupingDefinition;\r
-import org.opendaylight.controller.yang.model.api.ListSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.MustDefinition;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-import org.opendaylight.controller.yang.model.api.Status;\r
-import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
-import org.opendaylight.controller.yang.model.api.UsesNode;\r
-\r
-\r
-public class ListSchemaNodeBuilderTest {\r
-\r
-       private ListSchemaNodeBuilder tested;\r
-\r
-       private static final String NAME = "test-list";\r
-\r
-       private final URI namespace = URI.create("test:list.name");\r
-       private final Date revision = new Date();\r
-       private final String prefix = "x";\r
-\r
-       private SchemaPath schemaPath;\r
-       private final String description = "description of list";\r
-       private final String reference = "reference";\r
-\r
-       private QName typedefQName;\r
-       private TypedefBuilder typeBuilder;\r
-       @Mock private AugmentationSchema augment;\r
-       @Mock private ConstraintDefinition constraint;\r
-       @Mock private UsesNodeBuilder usesBuilder;\r
-       @Mock private UsesNode uses;\r
-       @Mock private MustDefinitionBuilder mustBuilder;\r
-       @Mock private MustDefinition must;\r
-       @Mock private GroupingBuilder groupingBuilder;\r
-       @Mock private GroupingDefinition grouping;\r
-       private List<QName> keyDefinition;\r
-\r
-       @Before\r
-       public void init() {\r
-               MockitoAnnotations.initMocks(this);\r
-               when(usesBuilder.build()).thenReturn(uses);\r
-               when(mustBuilder.build()).thenReturn(must);\r
-               when(groupingBuilder.build()).thenReturn(grouping);\r
-\r
-               schemaPath = TestUtils.createSchemaPath(true, namespace, "main", NAME);\r
-               typedefQName = new QName(namespace, "test-type");\r
-               typeBuilder = new TypedefBuilder(typedefQName);\r
-\r
-               keyDefinition = new ArrayList<QName>();\r
-               keyDefinition.add(new QName(namespace, "name"));\r
-\r
-               QName qname = new QName(namespace, revision, prefix, NAME);\r
-               tested = new ListSchemaNodeBuilder(qname);\r
-       }\r
-\r
-       @Test\r
-       public void test() {\r
-               tested.addTypedef(typeBuilder);\r
-               tested.setPath(schemaPath);\r
-               tested.setDescription(description);\r
-               tested.setReference(reference);\r
-               tested.setStatus(Status.OBSOLOTE);\r
-               tested.setConfiguration(false);\r
-               tested.setConstraints(constraint);\r
-               tested.addUsesNode(usesBuilder);\r
-               tested.addAugmentation(augment);\r
-               tested.setUserOrdered(true);\r
-               tested.setKeyDefinition(keyDefinition);\r
-\r
-               ListSchemaNode result = tested.build();\r
-\r
-               Set<TypeDefinition<?>> expectedTypedefs = result.getTypeDefinitions();\r
-               assertEquals(1, expectedTypedefs.size());\r
-               assertEquals(typedefQName, expectedTypedefs.iterator().next().getQName());\r
-\r
-               Set<AugmentationSchema> expectedAugments = new HashSet<AugmentationSchema>();\r
-               expectedAugments.add(augment);\r
-               assertEquals(expectedAugments, result.getAvailableAugmentations());\r
-\r
-               assertEquals(schemaPath, result.getPath());\r
-               assertEquals(description, result.getDescription());\r
-               assertEquals(reference, result.getReference());\r
-               assertEquals(Status.OBSOLOTE, result.getStatus());\r
-               assertFalse(result.isConfiguration());\r
-               assertEquals(constraint, result.getConstraints());\r
-\r
-               Set<UsesNode> expectedUses = new HashSet<UsesNode>();\r
-               expectedUses.add(uses);\r
-               assertEquals(expectedUses, result.getUses());\r
-\r
-               assertTrue(result.isUserOrdered());\r
-               assertEquals(keyDefinition, result.getKeyDefinition());\r
-       }\r
-\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/impl/YangModelParserTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/model/parser/impl/YangModelParserTest.java
deleted file mode 100644 (file)
index 4a90d80..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.impl;\r
-\r
-import static org.junit.Assert.assertEquals;\r
-\r
-import java.io.IOException;\r
-import java.io.InputStream;\r
-import java.util.Set;\r
-\r
-import org.antlr.v4.runtime.ANTLRInputStream;\r
-import org.antlr.v4.runtime.CommonTokenStream;\r
-import org.antlr.v4.runtime.tree.ParseTree;\r
-import org.antlr.v4.runtime.tree.ParseTreeWalker;\r
-import org.junit.Test;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangLexer;\r
-import org.opendaylight.controller.antlrv4.code.gen.YangParser;\r
-import org.opendaylight.controller.sal.binding.model.api.GeneratedType;\r
-\r
-public class YangModelParserTest {\r
-\r
-    @Test\r
-    public void testPackageNameConstruction() {\r
-        try {\r
-            final InputStream inStream = getClass().getResourceAsStream(\r
-                    "/simple-list-demo.yang");\r
-            if (inStream != null) {\r
-                ANTLRInputStream input = new ANTLRInputStream(inStream);\r
-                final YangLexer lexer = new YangLexer(input);\r
-                final CommonTokenStream tokens = new CommonTokenStream(lexer);\r
-                final YangParser parser = new YangParser(tokens);\r
-\r
-                final ParseTree tree = parser.yang();\r
-                final ParseTreeWalker walker = new ParseTreeWalker();\r
-\r
-                // final YangModelParserImpl modelParser = new\r
-                // YangModelParserImpl(tree, new TypeProviderImpl());\r
-                // walker.walk(modelParser, tree);\r
-                // final Set<GeneratedType> genTypes =\r
-                // modelParser.generatedTypes();\r
-\r
-                // getTypesTest(genTypes);\r
-\r
-            }\r
-        } catch (IOException e) {\r
-            e.printStackTrace();\r
-        }\r
-    }\r
-\r
-    private void getTypesTest(final Set<GeneratedType> genTypes) {\r
-        int typesCount = 0;\r
-        for (final GeneratedType type : genTypes) {\r
-            if (type.getName().equals("Topology")) {\r
-                assertEquals(4, type.getMethodDefinitions().size());\r
-                ++typesCount;\r
-            }\r
-            if (type.getName().equals("NetworkNodes")) {\r
-                assertEquals(2, type.getMethodDefinitions().size());\r
-                ++typesCount;\r
-            }\r
-            if (type.getName().equals("NetworkNode")) {\r
-                assertEquals(1, type.getMethodDefinitions().size());\r
-                ++typesCount;\r
-            }\r
-            if (type.getName().equals("NodeAttributes")) {\r
-                assertEquals(2, type.getMethodDefinitions().size());\r
-                ++typesCount;\r
-            }\r
-            if (type.getName().equals("NetworkLinks")) {\r
-                assertEquals(2, type.getMethodDefinitions().size());\r
-                ++typesCount;\r
-            }\r
-            if (type.getName().equals("NetworkLink")) {\r
-                assertEquals(3, type.getMethodDefinitions().size());\r
-                ++typesCount;\r
-            }\r
-            if (type.getName().equals("Source")) {\r
-                assertEquals(2, type.getMethodDefinitions().size());\r
-                ++typesCount;\r
-            }\r
-            if (type.getName().equals("Destination")) {\r
-                assertEquals(2, type.getMethodDefinitions().size());\r
-                ++typesCount;\r
-            }\r
-            if (type.getName().equals("LinkAttributes")) {\r
-                assertEquals(0, type.getMethodDefinitions().size());\r
-                ++typesCount;\r
-            }\r
-        }\r
-        assertEquals(9, typesCount);\r
-    }\r
-}\r
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/ContainerSchemaNodeBuilderTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/ContainerSchemaNodeBuilderTest.java
new file mode 100644 (file)
index 0000000..709d5e3
--- /dev/null
@@ -0,0 +1,111 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UsesNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+
+public class ContainerSchemaNodeBuilderTest {
+
+    private ContainerSchemaNodeBuilder tested;
+
+    private final String NAME = "test-container";
+
+    private final URI namespace = URI.create("test:container.name");
+    private final Date revision = new Date();
+    private final String prefix = "x";
+
+    private SchemaPath schemaPath;
+    private final String description = "description of container";
+    private final String reference = "reference";
+
+    private QName typedefQName;
+    private TypedefBuilder typeBuilder;
+    @Mock
+    private AugmentationSchema augment;
+    @Mock
+    private UsesNodeBuilder usesBuilder;
+    @Mock
+    private UsesNode uses;
+    @Mock
+    private GroupingBuilder groupingBuilder;
+    @Mock
+    private GroupingDefinition grouping;
+
+    @Before
+    public void init() {
+        MockitoAnnotations.initMocks(this);
+        when(usesBuilder.build()).thenReturn(uses);
+        when(groupingBuilder.build()).thenReturn(grouping);
+
+        schemaPath = TestUtils.createSchemaPath(true, namespace, "main",
+                "interface");
+        typedefQName = new QName(namespace, "test-type");
+        typeBuilder = new TypedefBuilder(typedefQName);
+
+        QName qname = new QName(namespace, revision, prefix, NAME);
+        tested = new ContainerSchemaNodeBuilder(qname);
+    }
+
+    @Test
+    public void test() {
+        tested.addTypedef(typeBuilder);
+        tested.setPath(schemaPath);
+        tested.setDescription(description);
+        tested.setReference(reference);
+        tested.setStatus(Status.OBSOLETE);
+        tested.setConfiguration(false);
+        tested.addUsesNode(usesBuilder);
+        tested.addAugmentation(augment);
+        tested.setPresenceContainer(true);
+
+        ContainerSchemaNode result = tested.build();
+
+        Set<TypeDefinition<?>> expectedTypedefs = result.getTypeDefinitions();
+        assertEquals(1, expectedTypedefs.size());
+        assertEquals(typedefQName, expectedTypedefs.iterator().next()
+                .getQName());
+
+        Set<AugmentationSchema> expectedAugments = new HashSet<AugmentationSchema>();
+        expectedAugments.add(augment);
+        assertEquals(expectedAugments, result.getAvailableAugmentations());
+
+        assertEquals(schemaPath, result.getPath());
+        assertEquals(description, result.getDescription());
+        assertEquals(reference, result.getReference());
+        assertEquals(Status.OBSOLETE, result.getStatus());
+        assertFalse(result.isConfiguration());
+
+        Set<UsesNode> expectedUses = new HashSet<UsesNode>();
+        expectedUses.add(uses);
+        assertEquals(expectedUses, result.getUses());
+
+        assertTrue(result.isPresenceContainer());
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafListSchemaNodeBuilderTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafListSchemaNodeBuilderTest.java
new file mode 100644 (file)
index 0000000..367669f
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+import java.util.Date;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.LeafListSchemaNode;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UsesNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+
+public class LeafListSchemaNodeBuilderTest {
+
+    private LeafListSchemaNodeBuilder tested;
+
+    private final String NAME = "test-leaf";
+
+    private final URI namespace = URI.create("test:leaf.name");
+    private final Date revision = new Date();
+    private final String prefix = "x";
+
+    private SchemaPath schemaPath;
+    private final String description = "description of container";
+    private final String reference = "reference";
+
+    private QName typedefQName;
+    private TypeDefinition<?> type;
+
+    @Mock
+    private UsesNodeBuilder usesBuilder;
+    @Mock
+    private UsesNode uses;
+    @Mock
+    private GroupingBuilder groupingBuilder;
+    @Mock
+    private GroupingDefinition grouping;
+
+    @Before
+    public void init() {
+        MockitoAnnotations.initMocks(this);
+        when(usesBuilder.build()).thenReturn(uses);
+        when(groupingBuilder.build()).thenReturn(grouping);
+
+        schemaPath = TestUtils.createSchemaPath(true, namespace, "main",
+                "interface");
+        typedefQName = new QName(namespace, "test-type");
+        TypedefBuilder typeBuilder = new TypedefBuilder(typedefQName);
+        type = typeBuilder.build();
+
+        QName qname = new QName(namespace, revision, prefix, NAME);
+        tested = new LeafListSchemaNodeBuilder(qname);
+    }
+
+    @Test
+    public void test() {
+        tested.setType(type);
+        tested.setPath(schemaPath);
+        tested.setDescription(description);
+        tested.setReference(reference);
+        tested.setStatus(Status.OBSOLETE);
+        tested.setConfiguration(false);
+
+        LeafListSchemaNode result = tested.build();
+
+        assertEquals(type, result.getType());
+        assertEquals(schemaPath, result.getPath());
+        assertEquals(description, result.getDescription());
+        assertEquals(reference, result.getReference());
+        assertEquals(Status.OBSOLETE, result.getStatus());
+        assertFalse(result.isConfiguration());
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafSchemaNodeBuilderTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/LeafSchemaNodeBuilderTest.java
new file mode 100644 (file)
index 0000000..622c82d
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+import java.util.Date;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UsesNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+
+public class LeafSchemaNodeBuilderTest {
+
+    private LeafSchemaNodeBuilder tested;
+
+    private final String NAME = "test-leaf";
+
+    private final URI namespace = URI.create("test:leaf.name");
+    private final Date revision = new Date();
+    private final String prefix = "x";
+
+    private SchemaPath schemaPath;
+    private final String description = "description of container";
+    private final String reference = "reference";
+
+    private QName typedefQName;
+    private TypeDefinition<?> type;
+    @Mock
+    private UsesNodeBuilder usesBuilder;
+    @Mock
+    private UsesNode uses;
+    @Mock
+    private GroupingBuilder groupingBuilder;
+    @Mock
+    private GroupingDefinition grouping;
+
+    @Before
+    public void init() {
+        MockitoAnnotations.initMocks(this);
+        when(usesBuilder.build()).thenReturn(uses);
+        when(groupingBuilder.build()).thenReturn(grouping);
+
+        schemaPath = TestUtils.createSchemaPath(true, namespace, "main",
+                "interface");
+        typedefQName = new QName(namespace, "test-type");
+        TypedefBuilder typeBuilder = new TypedefBuilder(typedefQName);
+        type = typeBuilder.build();
+
+        QName qname = new QName(namespace, revision, prefix, NAME);
+        tested = new LeafSchemaNodeBuilder(qname);
+    }
+
+    @Test
+    public void test() {
+        tested.setType(type);
+        tested.setPath(schemaPath);
+        tested.setDescription(description);
+        tested.setReference(reference);
+        tested.setStatus(Status.OBSOLETE);
+        tested.setConfiguration(false);
+
+        LeafSchemaNode result = tested.build();
+
+        assertEquals(type, result.getType());
+        assertEquals(schemaPath, result.getPath());
+        assertEquals(description, result.getDescription());
+        assertEquals(reference, result.getReference());
+        assertEquals(Status.OBSOLETE, result.getStatus());
+        assertFalse(result.isConfiguration());
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/ListSchemaNodeBuilderTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/ListSchemaNodeBuilderTest.java
new file mode 100644 (file)
index 0000000..c5f3361
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.when;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+import org.opendaylight.controller.yang.model.api.GroupingDefinition;
+import org.opendaylight.controller.yang.model.api.ListSchemaNode;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.api.UsesNode;
+import org.opendaylight.controller.yang.model.parser.builder.api.GroupingBuilder;
+import org.opendaylight.controller.yang.model.parser.builder.api.UsesNodeBuilder;
+
+public class ListSchemaNodeBuilderTest {
+
+    private ListSchemaNodeBuilder tested;
+
+    private static final String NAME = "test-list";
+
+    private final URI namespace = URI.create("test:list.name");
+    private final Date revision = new Date();
+    private final String prefix = "x";
+
+    private SchemaPath schemaPath;
+    private final String description = "description of list";
+    private final String reference = "reference";
+
+    private QName typedefQName;
+    private TypedefBuilder typeBuilder;
+    @Mock
+    private AugmentationSchema augment;
+    @Mock
+    private UsesNodeBuilder usesBuilder;
+    @Mock
+    private UsesNode uses;
+    @Mock
+    private GroupingBuilder groupingBuilder;
+    @Mock
+    private GroupingDefinition grouping;
+    private List<QName> keyDefinition;
+
+    @Before
+    public void init() {
+        MockitoAnnotations.initMocks(this);
+        when(usesBuilder.build()).thenReturn(uses);
+        when(groupingBuilder.build()).thenReturn(grouping);
+
+        schemaPath = TestUtils.createSchemaPath(true, namespace, "main", NAME);
+        typedefQName = new QName(namespace, "test-type");
+        typeBuilder = new TypedefBuilder(typedefQName);
+
+        keyDefinition = new ArrayList<QName>();
+        keyDefinition.add(new QName(namespace, "name"));
+
+        QName qname = new QName(namespace, revision, prefix, NAME);
+        tested = new ListSchemaNodeBuilder(qname);
+    }
+
+    @Test
+    public void test() {
+        tested.addTypedef(typeBuilder);
+        tested.setPath(schemaPath);
+        tested.setDescription(description);
+        tested.setReference(reference);
+        tested.setStatus(Status.OBSOLETE);
+        tested.setConfiguration(false);
+        tested.addUsesNode(usesBuilder);
+        tested.addAugmentation(augment);
+        tested.setUserOrdered(true);
+        tested.setKeyDefinition(keyDefinition);
+
+        ListSchemaNode result = tested.build();
+
+        Set<TypeDefinition<?>> expectedTypedefs = result.getTypeDefinitions();
+        assertEquals(1, expectedTypedefs.size());
+        assertEquals(typedefQName, expectedTypedefs.iterator().next()
+                .getQName());
+
+        Set<AugmentationSchema> expectedAugments = new HashSet<AugmentationSchema>();
+        expectedAugments.add(augment);
+        assertEquals(expectedAugments, result.getAvailableAugmentations());
+
+        assertEquals(schemaPath, result.getPath());
+        assertEquals(description, result.getDescription());
+        assertEquals(reference, result.getReference());
+        assertEquals(Status.OBSOLETE, result.getStatus());
+        assertFalse(result.isConfiguration());
+
+        Set<UsesNode> expectedUses = new HashSet<UsesNode>();
+        expectedUses.add(uses);
+        assertEquals(expectedUses, result.getUses());
+
+        assertTrue(result.isUserOrdered());
+        assertEquals(keyDefinition, result.getKeyDefinition());
+    }
+
+}
@@ -1,33 +1,33 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.model.parser.builder;\r
-\r
-import java.net.URI;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-\r
-import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.SchemaPath;\r
-\r
-\r
-public class TestUtils {\r
-\r
-       private TestUtils () {\r
-       }\r
-\r
-       public static SchemaPath createSchemaPath(boolean absolute, URI namespace, String... path) {\r
-               List<QName> names = new ArrayList<QName>();\r
-               QName qname;\r
-               for(String pathPart : path) {\r
-                       qname = new QName(namespace, pathPart);\r
-                       names.add(qname);\r
-               }\r
-               return new SchemaPath(names, absolute);\r
-       }\r
-\r
-}\r
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+
+public class TestUtils {
+
+    private TestUtils() {
+    }
+
+    public static SchemaPath createSchemaPath(boolean absolute, URI namespace,
+            String... path) {
+        List<QName> names = new ArrayList<QName>();
+        QName qname;
+        for (String pathPart : path) {
+            qname = new QName(namespace, pathPart);
+            names.add(qname);
+        }
+        return new SchemaPath(names, absolute);
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/YangModelBuilderTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/builder/impl/YangModelBuilderTest.java
new file mode 100644 (file)
index 0000000..2a11293
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * 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.yang.model.parser.builder.impl;
+
+import static org.junit.Assert.*;
+
+import java.io.File;
+import java.text.ParseException;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+import org.opendaylight.controller.yang.model.api.DataNodeContainer;
+import org.opendaylight.controller.yang.model.api.LeafSchemaNode;
+import org.opendaylight.controller.yang.model.api.Module;
+import org.opendaylight.controller.yang.model.parser.impl.YangModelParserImpl;
+
+public class YangModelBuilderTest {
+
+    private Set<Module> builtModules;
+
+    @Before
+    public void init() {
+        builtModules = parseModules();
+    }
+
+    @Test
+    public void testAugment() throws ParseException {
+        for(Module module : builtModules) {
+            if(module.getName().equals("types2")) {
+                Set<AugmentationSchema> augmentations = module.getAugmentations();
+                assertEquals(1, augmentations.size());
+                AugmentationSchema augment = augmentations.iterator().next();
+                LeafSchemaNode augmentedLeaf = (LeafSchemaNode)augment.getDataChildByName("ds0ChannelNumber");
+                assertNotNull(augmentedLeaf);
+                assertTrue(augmentedLeaf.isAugmenting());
+            } else if(module.getName().equals("types1")) {
+                DataNodeContainer interfaces = (DataNodeContainer)module.getDataChildByName("interfaces");
+                DataNodeContainer ifEntry = (DataNodeContainer)interfaces.getDataChildByName("ifEntry");
+                assertNotNull(ifEntry);
+            } else {
+                fail("unexpected module");
+            }
+        }
+    }
+
+    private Set<Module> parseModules() {
+        String yangFilesDir = "src/test/resources/model";
+        File resourceDir = new File(yangFilesDir);
+
+        String[] dirList = resourceDir.list();
+        String[] absFiles = new String[dirList.length];
+
+        int i = 0;
+        for (String fileName : dirList) {
+            File abs = new File(resourceDir, fileName);
+            absFiles[i] = abs.getAbsolutePath();
+            i++;
+        }
+
+        YangModelParserImpl parser = new YangModelParserImpl();
+        Set<Module> modules = parser.parseYangModels(absFiles);
+
+        return modules;
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserListenerTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserListenerTest.java
new file mode 100644 (file)
index 0000000..a9bcb91
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+ * 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.yang.model.parser.impl;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Date;
+import java.util.List;
+import java.util.Set;
+
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.tree.ParseTree;
+import org.antlr.v4.runtime.tree.ParseTreeWalker;
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.antlrv4.code.gen.YangLexer;
+import org.opendaylight.controller.antlrv4.code.gen.YangParser;
+import org.opendaylight.controller.model.util.UnknownType;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.controller.yang.model.api.DataNodeContainer;
+import org.opendaylight.controller.yang.model.api.DataSchemaNode;
+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.ModuleImport;
+import org.opendaylight.controller.yang.model.api.SchemaNode;
+import org.opendaylight.controller.yang.model.api.SchemaPath;
+import org.opendaylight.controller.yang.model.api.Status;
+import org.opendaylight.controller.yang.model.api.TypeDefinition;
+import org.opendaylight.controller.yang.model.parser.builder.impl.ModuleBuilder;
+
+public class YangModelParserListenerTest {
+
+    private final String testFile = "/test-model.yang";
+    ModuleBuilder builder;
+    Module module;
+
+
+    @Before
+    public void init() throws IOException {
+        builder = getBuilder(testFile);
+        module = builder.build();
+    }
+
+    @Test
+    public void testParseModule() throws IOException {
+        Set<ModuleImport> imports = module.getImports();
+        assertEquals(3, imports.size());
+
+        URI namespace = module.getNamespace();
+        URI expectedNS = URI.create("urn:cisco:params:xml:ns:yang:controller:network");
+        assertEquals(expectedNS, namespace);
+
+        Date revision = module.getRevision();
+        assertNull(revision);
+
+        String prefix = module.getPrefix();
+        String expectedPrefix = "topos";
+        assertEquals(expectedPrefix, prefix);
+
+        String expectedDescription = "module description";
+        assertEquals(expectedDescription, module.getDescription());
+
+        String expectedReference = "module reference";
+        assertEquals(expectedReference, module.getReference());
+
+        Set<TypeDefinition<?>> typedefs = module.getTypeDefinitions();
+        assertEquals(10, typedefs.size());
+
+        Set<DataSchemaNode> childNodes = module.getChildNodes();
+        assertEquals(1, childNodes.size());
+
+        final String containerName = "network";
+        final QName containerQName = new QName(namespace, revision, prefix, containerName);
+        ContainerSchemaNode tested = (ContainerSchemaNode) module.getChildNodes().iterator().next();
+        DataSchemaNode container1 = module.getDataChildByName(containerName);
+        DataSchemaNode container2 = module.getDataChildByName(containerQName);
+
+        assertEquals(tested, container1);
+        assertEquals(container1, container2);
+    }
+
+    @Test
+    public void testParseContainer() {
+        URI namespace = module.getNamespace();
+        Date revision = module.getRevision();
+        String prefix = module.getPrefix();
+        final QName containerQName = new QName(namespace, revision, prefix, "network");
+
+        ContainerSchemaNode tested = (ContainerSchemaNode)module.getDataChildByName(containerQName);
+
+        Set<DataSchemaNode> containerChildNodes = tested.getChildNodes();
+        assertEquals(3, containerChildNodes.size());
+
+        String expectedDescription = "network-description";
+        String expectedReference = "network-reference";
+        Status expectedStatus = Status.OBSOLETE;
+        testDesc_Ref_Status(tested, expectedDescription, expectedReference, expectedStatus);
+
+        List<QName> path = new ArrayList<QName>();
+        path.add(new QName(namespace, revision, prefix, "test-model"));
+        path.add(containerQName);
+        SchemaPath expectedSchemaPath = new SchemaPath(path, true);
+        assertEquals(expectedSchemaPath, tested.getPath());
+
+        assertTrue(tested.isConfiguration());
+        assertTrue(tested.isPresenceContainer());
+    }
+
+    @Test
+    public void testParseList() {
+        URI namespace = module.getNamespace();
+        Date revision = module.getRevision();
+        String prefix = module.getPrefix();
+        final QName listQName = new QName(namespace, revision, prefix, "topology");
+
+        DataNodeContainer networkContainer = (DataNodeContainer)module.getDataChildByName("network");
+        DataNodeContainer topologiesContainer = (DataNodeContainer)networkContainer.getDataChildByName("topologies");
+        ListSchemaNode tested = (ListSchemaNode)topologiesContainer.getDataChildByName(listQName);
+        assertEquals(listQName, tested.getQName());
+
+        String expectedDescription = "Test description of list 'topology'.";
+        String expectedReference = null;
+        Status expectedStatus = Status.CURRENT;
+        testDesc_Ref_Status(tested, expectedDescription, expectedReference, expectedStatus);
+
+        List<QName> path = new ArrayList<QName>();
+        path.add(new QName(namespace, revision, prefix, "test-model"));
+        path.add(new QName(namespace, revision, prefix, "network"));
+        path.add(new QName(namespace, revision, prefix, "topologies"));
+        path.add(listQName);
+        SchemaPath expectedSchemaPath = new SchemaPath(path, true);
+        assertEquals(expectedSchemaPath, tested.getPath());
+
+        List<QName> expectedKey = new ArrayList<QName>();
+        expectedKey.add(new QName(namespace, revision, prefix, "topology-id"));
+        assertEquals(expectedKey, tested.getKeyDefinition());
+
+        assertEquals(Collections.EMPTY_SET, tested.getTypeDefinitions());
+        assertEquals(Collections.EMPTY_SET, tested.getUses());
+        assertEquals(Collections.EMPTY_SET, tested.getGroupings());
+
+        assertTrue(tested.getDataChildByName("topology-id") instanceof LeafSchemaNode);
+    }
+
+    @Test
+    public void testParseLeaf() {
+        URI namespace = module.getNamespace();
+        Date revision = module.getRevision();
+        String prefix = module.getPrefix();
+        final QName leafQName = new QName(namespace, revision, prefix, "topology-id");
+
+        DataNodeContainer networkContainer = (DataNodeContainer)module.getDataChildByName("network");
+        DataNodeContainer topologiesContainer = (DataNodeContainer)networkContainer.getDataChildByName("topologies");
+        DataNodeContainer topologyList = (DataNodeContainer)topologiesContainer.getDataChildByName("topology");
+        LeafSchemaNode tested = (LeafSchemaNode)topologyList.getDataChildByName(leafQName);
+        assertEquals(leafQName, tested.getQName());
+
+        String expectedDescription = "Test description of leaf 'topology-id'";
+        String expectedReference = null;
+        Status expectedStatus = Status.CURRENT;
+        testDesc_Ref_Status(tested, expectedDescription, expectedReference, expectedStatus);
+
+        List<QName> path = new ArrayList<QName>();
+        path.add(new QName(namespace, revision, prefix, "test-model"));
+        path.add(new QName(namespace, revision, prefix, "network"));
+        path.add(new QName(namespace, revision, prefix, "topologies"));
+        path.add(new QName(namespace, revision, prefix, "topology"));
+        path.add(leafQName);
+        SchemaPath expectedSchemaPath = new SchemaPath(path, true);
+        assertEquals(expectedSchemaPath, tested.getPath());
+
+        UnknownType.Builder typeBuilder = new UnknownType.Builder(new QName(namespace, revision, prefix, "topology-id"), null, null);
+        TypeDefinition<?> expectedType = typeBuilder.build();
+        assertEquals(expectedType, tested.getType());
+    }
+
+
+    private void testDesc_Ref_Status(SchemaNode tested, String expectedDescription, String expectedReference, Status expectedStatus) {
+        assertEquals(expectedDescription, tested.getDescription());
+        assertEquals(expectedReference, tested.getReference());
+        assertEquals(expectedStatus, tested.getStatus());
+    }
+
+    private ModuleBuilder getBuilder(String fileName) throws IOException {
+        final InputStream inStream = getClass().getResourceAsStream(fileName);
+        ANTLRInputStream input = new ANTLRInputStream(inStream);
+        final YangLexer lexer = new YangLexer(input);
+        final CommonTokenStream tokens = new CommonTokenStream(lexer);
+        final YangParser parser = new YangParser(tokens);
+
+        final ParseTree tree = parser.yang();
+        final ParseTreeWalker walker = new ParseTreeWalker();
+
+        final YangModelParserListenerImpl modelParser = new YangModelParserListenerImpl();
+        walker.walk(modelParser, tree);
+        return modelParser.getModuleBuilder();
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserTest.java b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/java/org/opendaylight/controller/yang/model/parser/impl/YangModelParserTest.java
new file mode 100644 (file)
index 0000000..74cfed5
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * 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.yang.model.parser.impl;
+
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.util.Set;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.opendaylight.controller.model.util.Int32;
+import org.opendaylight.controller.yang.model.api.AugmentationSchema;
+import org.opendaylight.controller.yang.model.api.ContainerSchemaNode;
+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.parser.api.YangModelParser;
+
+public class YangModelParserTest {
+
+    private final String testFile1 = "src/test/resources/model/testfile1.yang";
+    private final String testFile2 = "src/test/resources/model/testfile2.yang";
+    private YangModelParser tested;
+
+    @Before
+    public void init() throws IOException {
+        tested = new YangModelParserImpl();
+    }
+
+    @Test
+    public void testAugment() {
+        Set<Module> modules = tested.parseYangModels(testFile1, testFile2);
+        assertEquals(2, modules.size());
+
+        Module m2 = null;
+        for(Module m : modules) {
+            if(m.getName().equals("types2")) {
+                m2 = m;
+            }
+        }
+        assertNotNull(m2);
+
+        AugmentationSchema augment = m2.getAugmentations().iterator().next();
+        assertNotNull(augment);
+    }
+
+    @Test
+    public void testAugmentTarget() {
+        Set<Module> modules = tested.parseYangModels(testFile1, testFile2);
+        assertEquals(2, modules.size());
+
+        Module m1 = null;
+        for(Module m : modules) {
+            if(m.getName().equals("types1")) {
+                m1 = m;
+            }
+        }
+        assertNotNull(m1);
+
+        ContainerSchemaNode container = (ContainerSchemaNode)m1.getDataChildByName("interfaces");
+        assertNotNull(container);
+
+        ListSchemaNode list = (ListSchemaNode)container.getDataChildByName("ifEntry");
+        assertNotNull(list);
+
+        LeafSchemaNode leaf = (LeafSchemaNode)list.getDataChildByName("ds0ChannelNumber");
+        assertNotNull(leaf);
+    }
+
+    @Test
+    public void testTypeDef() {
+        Set<Module> modules = tested.parseYangModels(testFile1, testFile2);
+        assertEquals(2, modules.size());
+
+        Module m1 = null;
+        for(Module m : modules) {
+            if(m.getName().equals("types1")) {
+                m1 = m;
+            }
+        }
+        assertNotNull(m1);
+
+        LeafSchemaNode testleaf = (LeafSchemaNode)m1.getDataChildByName("testleaf");
+        assertTrue(testleaf.getType().getBaseType() instanceof Int32);
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile1.yang b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile1.yang
new file mode 100644 (file)
index 0000000..2c796a9
--- /dev/null
@@ -0,0 +1,39 @@
+module types1 {
+       yang-version 1;
+    namespace "urn:simple.container.demo";
+    prefix "t1";
+    
+    import types2 {
+         prefix "data";
+         revision-date 2013-02-27;
+     }
+    
+    organization "Cisco";
+    contact "WILL-BE-DEFINED-LATER";
+    
+    revision "2013-02-27" {
+        reference " WILL BE DEFINED LATER";
+    }
+    
+    container interfaces {
+         list ifEntry {
+             key "ifIndex";
+
+             leaf ifIndex {
+                 type uint32;
+                 units minutes;
+             }
+             
+             leaf ifMtu {
+                 type int32;
+             }
+         }
+     }
+     
+       leaf testleaf {
+               type data:my-base-int32-type {
+                       range "11..max";
+               }
+       } 
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile2.yang b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/model/testfile2.yang
new file mode 100644 (file)
index 0000000..9d12207
--- /dev/null
@@ -0,0 +1,43 @@
+module types2 {
+       yang-version 1;
+    namespace "urn:simple.types.data.demo";
+    prefix "t2";
+    
+    import types1 {
+         prefix "if";
+         revision-date 2013-02-27;
+     }
+
+    organization "Cisco";
+    contact "WILL-BE-DEFINED-LATER";
+    description "This is types-data test description";
+
+    revision "2013-02-27" {
+        reference " WILL BE DEFINED LATER";
+    }
+    
+    
+     augment "/if:interfaces/if:ifEntry" {
+         when "if:ifType='ds0'";
+         leaf ds0ChannelNumber {
+             type string;
+         }
+     }
+     
+     leaf if-name {
+       type leafref {
+               path "/interface/name";
+        }
+     }
+     
+     leaf name {
+       type string;
+     }
+     
+     typedef my-base-int32-type {
+               type int32 {
+               range "0..32";
+        }
+       }
+
+}
diff --git a/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/test-model.yang b/opendaylight/sal/yang-prototype/code-generator/yang-model-parser-impl/src/test/resources/test-model.yang
new file mode 100644 (file)
index 0000000..a2c485d
--- /dev/null
@@ -0,0 +1,164 @@
+module test-model {
+       yang-version 1;
+       namespace "urn:cisco:params:xml:ns:yang:controller:network";
+       prefix "topos";
+
+       import ietf-inet-types { prefix "inet"; }
+       import iana-if-type {prefix "if-type";}
+       import mount {prefix "mnt";} 
+
+       organization "Cisco";
+
+       contact "WILL-BE-DEFINED-LATER";
+
+       description "module description";
+       reference "module reference";
+       
+       typedef topology-id {
+               type inet:uri;
+       }
+
+       typedef node-id {
+               type inet:uri;
+       }
+
+       typedef link-id {
+               type inet:uri;
+       }
+
+       typedef tp-id {
+               type inet:uri;
+               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 {
+               description "network-description";
+               reference "network-reference";
+               status obsolete;
+               config true;
+               presence "some presence text";
+               
+               mnt:mountpoint point  {
+               mnt:target-ref target;
+               }
+               
+               leaf-list locked-node {
+               type instance-identifier;
+               min-elements 1;
+               when "a/b/c";
+               description "List of locked nodes in the running datastore";
+       }
+       
+       leaf locked-test {
+               mandatory true;
+       }
+       
+               container topologies {
+                       list topology {
+                               description "Test description of list 'topology'.";
+                               key "topology-id";
+                               leaf topology-id {
+                                       type topology-id; 
+                                       description "Test description of leaf 'topology-id'";
+                               }
+
+                               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 "Test description of list 'link'.";
+                                               key "link-id";
+                                               leaf link-id {
+                                                       type link-id;
+                                                       description "";
+                                               }
+
+                                               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;
+                                                       }
+                                               }
+                                       }
+                               }
+                       }
+               }
+       }
+       
+}
index 7cda2acbaeef61d1acaa18840faaa6e7f81f88fd..2c494e6bb94704ff73753ad047d9e59f0e241574 100644 (file)
@@ -10,6 +10,8 @@
                <module>sal-core-api</module>\r
                <module>sal-data-api</module>\r
                <module>sal-binding-api</module>\r
+               <module>sal-binding-spi</module>\r
+               <module>sal-binding-broker-impl</module>\r
                <module>sal-schema-repository-api</module>\r
                <module>sal-common</module>\r
                <module>sal-core-spi</module>\r
index 4c1e6f7e1c338ce87da10d02022d15235f00d593..24f5b25a190b2e4d8d4876ee5eb9e9a5bd794eab 100644 (file)
@@ -160,8 +160,9 @@ public interface BindingAwareBroker {
      */\r
     public interface ProviderSession extends ConsumerSession {\r
 \r
-        void addImplementation(RpcService implementation);\r
+        void addRpcImplementation(RpcService implementation);\r
 \r
-        void removeImplementation(RpcService implementation);\r
+        void removeRpcImplementation(RpcService implementation);\r
     }\r
 }\r
+
index 565c3d2f019c8d6752541a1c42fb302b3cf16bb2..d324b83c5330b517d34447442313577c4163fd5a 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.sal.binding.api;
 import java.util.Collection;\r
 \r
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerSession;\r
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderSession;\r
 import org.opendaylight.controller.yang.binding.RpcService;\r
 \r
 \r
@@ -65,4 +66,7 @@ public interface BindingAwareProvider {
 \r
     }\r
 \r
+    void onSessionInitiated(ProviderSession session);\r
+\r
 }\r
+
index 131630dcc390e7a53474a5b07991ab1e7627b243..9c5552edbd8278a88763eb251c34822889f6b3a5 100644 (file)
                <artifactId>sal-binding-api</artifactId>\r
                <version>1.0-SNAPSHOT</version>\r
        </dependency>\r
-\r
+               <dependency>\r
+               <groupId>org.opendaylight.controller</groupId>\r
+               <artifactId>sal-binding-spi</artifactId>\r
+               <version>1.0-SNAPSHOT</version>\r
+       </dependency>\r
        <dependency>\r
                <groupId>org.opendaylight.controller</groupId>\r
                <artifactId>sal-core-api</artifactId>\r
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingBrokerImpl.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/BindingBrokerImpl.java
new file mode 100644 (file)
index 0000000..4cc23b4
--- /dev/null
@@ -0,0 +1,188 @@
+package org.opendaylight.controller.sal.binding.impl;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.controller.sal.binding.api.BindingAwareService;
+import org.opendaylight.controller.sal.binding.spi.SALBindingModule;
+import org.opendaylight.controller.yang.binding.RpcService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class BindingBrokerImpl implements BindingAwareBroker {
+
+    private static Logger log = LoggerFactory
+            .getLogger(BindingBrokerImpl.class);
+
+    private Set<ConsumerSessionImpl> sessions = new HashSet<ConsumerSessionImpl>();
+    private Set<ProviderSessionImpl> providerSessions = new HashSet<ProviderSessionImpl>();
+
+    private Set<SALBindingModule> modules = new HashSet<SALBindingModule>();
+    private Map<Class<? extends BindingAwareService>, SALBindingModule> salServiceProviders = new HashMap<Class<? extends BindingAwareService>, SALBindingModule>();
+
+    @Override
+    public ConsumerSession registerConsumer(BindingAwareConsumer consumer) {
+        checkPredicates(consumer);
+        log.info("Registering consumer " + consumer);
+
+        ConsumerSessionImpl session = newSessionFor(consumer);
+        consumer.onSessionInitialized(session);
+
+        sessions.add(session);
+
+        return session;
+
+    }
+
+    @Override
+    public ProviderSession registerProvider(BindingAwareProvider provider) {
+        checkPredicates(provider);
+
+        ProviderSessionImpl session = newSessionFor(provider);
+        provider.onSessionInitiated(session);
+
+        providerSessions.add(session);
+        return session;
+    }
+
+    public void addModule(SALBindingModule module) {
+        log.info("Registering broker module " + module);
+        if (modules.contains(module)) {
+            log.error("Module already registered");
+            throw new IllegalArgumentException("Module already exists.");
+        }
+
+        Set<Class<? extends BindingAwareService>> provServices = module
+                .getProvidedServices();
+        for (Class<? extends BindingAwareService> serviceType : provServices) {
+            log.info("  Registering session service implementation: "
+                    + serviceType.getCanonicalName());
+            salServiceProviders.put(serviceType, module);
+        }
+    }
+
+    public void consumerSessionClosed(ConsumerSessionImpl consumerSessionImpl) {
+        sessions.remove(consumerSessionImpl);
+        providerSessions.remove(consumerSessionImpl);
+    }
+
+    private void checkPredicates(BindingAwareProvider prov) {
+        if (prov == null)
+            throw new IllegalArgumentException("Provider should not be null.");
+        for (ProviderSessionImpl session : providerSessions) {
+            if (prov.equals(session.getProvider()))
+                throw new IllegalStateException("Provider already registered");
+        }
+
+    }
+
+    private void checkPredicates(BindingAwareConsumer cons) {
+        if (cons == null)
+            throw new IllegalArgumentException("Consumer should not be null.");
+        for (ConsumerSessionImpl session : sessions) {
+            if (cons.equals(session.getConsumer()))
+                throw new IllegalStateException("Consumer already registered");
+        }
+    }
+
+    private ConsumerSessionImpl newSessionFor(BindingAwareConsumer cons) {
+        return new ConsumerSessionImpl(cons);
+    }
+
+    private ProviderSessionImpl newSessionFor(BindingAwareProvider provider) {
+        return new ProviderSessionImpl(provider);
+    }
+
+    private <T extends BindingAwareService> T newSALServiceForSession(
+            Class<T> service, ConsumerSession session) {
+
+        SALBindingModule serviceProvider = salServiceProviders.get(service);
+        if (serviceProvider == null) {
+            return null;
+        }
+        return serviceProvider.getServiceForSession(service, session);
+
+    }
+
+    private class ConsumerSessionImpl implements
+            BindingAwareBroker.ConsumerSession {
+
+        private final BindingAwareConsumer consumer;
+        private Map<Class<? extends BindingAwareService>, BindingAwareService> sessionSalServices = new HashMap<Class<? extends BindingAwareService>, BindingAwareService>();
+
+        public ConsumerSessionImpl(BindingAwareConsumer cons) {
+            this.consumer = cons;
+        }
+
+        @Override
+        public <T extends BindingAwareService> T getSALService(Class<T> service) {
+
+            BindingAwareService serv = sessionSalServices.get(service);
+            if (serv != null) {
+                if (service.isInstance(serv)) {
+                    @SuppressWarnings("unchecked")
+                    T ret = (T) serv;
+                    return ret;
+                } else {
+                    log.error("Implementation for service " + service.getName()
+                            + " does not implement the service interface");
+                    throw new IllegalStateException("Service implementation "
+                            + serv.getClass().getName() + "does not implement "
+                            + service.getName());
+                }
+            } else {
+                T ret = BindingBrokerImpl.this.newSALServiceForSession(service,
+                        this);
+                if (ret != null) {
+                    sessionSalServices.put(service, ret);
+                }
+                return ret;
+            }
+        }
+
+        @Override
+        public <T extends RpcService> T getRpcService(Class<T> module) {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+        public BindingAwareConsumer getConsumer() {
+            return this.consumer;
+        }
+
+    }
+
+    private class ProviderSessionImpl extends ConsumerSessionImpl implements
+            BindingAwareBroker.ProviderSession {
+
+        private final BindingAwareProvider provider;
+
+        public ProviderSessionImpl(BindingAwareProvider provider2) {
+            super(null);
+            this.provider = provider2;
+        }
+
+        @Override
+        public void addRpcImplementation(RpcService implementation) {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+        @Override
+        public void removeRpcImplementation(RpcService implementation) {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+        public BindingAwareProvider getProvider() {
+            return this.provider;
+        }
+
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationInvoker.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationInvoker.java
new file mode 100644 (file)
index 0000000..810a0cb
--- /dev/null
@@ -0,0 +1,9 @@
+package org.opendaylight.controller.sal.binding.impl;
+
+import org.opendaylight.controller.sal.binding.spi.MappingProvider.MappingExtension;
+import org.opendaylight.controller.yang.binding.Notification;
+import org.opendaylight.controller.yang.binding.NotificationListener;
+
+public interface NotificationInvoker extends MappingExtension {
+    void notify(Notification notification, NotificationListener listener);
+}
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationModule.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/NotificationModule.java
new file mode 100644 (file)
index 0000000..189c585
--- /dev/null
@@ -0,0 +1,230 @@
+package org.opendaylight.controller.sal.binding.impl;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareService;
+import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
+import org.opendaylight.controller.sal.binding.api.NotificationService;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerSession;
+import org.opendaylight.controller.sal.binding.spi.SALBindingModule;
+import org.opendaylight.controller.sal.binding.spi.Mapper;
+import org.opendaylight.controller.sal.binding.spi.MappingProvider;
+import org.opendaylight.controller.sal.binding.spi.MappingProvider.MappingExtensionFactory;
+import org.opendaylight.controller.sal.core.api.Provider;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
+import org.opendaylight.controller.yang.binding.DataObject;
+import org.opendaylight.controller.yang.binding.Notification;
+import org.opendaylight.controller.yang.binding.NotificationListener;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.data.api.CompositeNode;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NotificationModule implements SALBindingModule {
+
+    private ProviderSession biSession;
+    private org.opendaylight.controller.sal.core.api.notify.NotificationProviderService biNotifyService;
+    private BindingAwareBroker broker;
+    private MappingProvider mappingProvider;
+
+    private Map<Class<? extends Notification>, List<NotificationListener>> listeners = new HashMap<Class<? extends Notification>, List<NotificationListener>>();
+    private static Logger log = LoggerFactory.getLogger(NotificationModule.class);
+
+    @Override
+    public Set<Class<? extends BindingAwareService>> getProvidedServices() {
+
+        Set<Class<? extends BindingAwareService>> ret = new HashSet<Class<? extends BindingAwareService>>();
+        ret.add(NotificationService.class);
+        ret.add(NotificationProviderService.class);
+        return ret;
+    }
+
+    @Override
+    public <T extends BindingAwareService> T getServiceForSession(
+            Class<T> service, ConsumerSession session) {
+        if (service == null)
+            throw new IllegalArgumentException("Service should not be null");
+        if (session == null)
+            throw new IllegalArgumentException("Session should not be null");
+
+        if (NotificationProviderSession.class.equals(service)) {
+            if (session instanceof org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderSession) {
+                @SuppressWarnings("unchecked")
+                T ret = (T) new NotificationProviderSession(session);
+                return ret;
+            } else {
+                throw new IllegalArgumentException(
+                        "NotificationProviderService is available only to ProviderSession");
+            }
+        }
+
+        if (NotificationService.class.equals(service)) {
+            @SuppressWarnings("unchecked")
+            T ret = (T) new NotificationSession(session);
+            return ret;
+        }
+        return null;
+    }
+
+    @Override
+    public Set<Class<? extends org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality>> getSupportedProviderFunctionality() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public void setBroker(BindingAwareBroker broker) {
+        this.broker = broker;
+    }
+
+    @Override
+    public void setMappingProvider(MappingProvider provider) {
+        this.mappingProvider = provider;
+    }
+
+    @Override
+    public void onBISessionAvailable(ProviderSession session) {
+        biSession = session;
+        if (biSession != null) {
+            biNotifyService = session
+                    .getService(org.opendaylight.controller.sal.core.api.notify.NotificationProviderService.class);
+        }
+    }
+
+    private void notify(Notification notification) {
+        notifyBindingIndependent(notification);
+        notifyBindingAware(notification);
+    }
+
+    private void notifyBindingAware(Notification notification) {
+        Class<? extends Notification> type = notification.getClass();
+        List<NotificationListener> toNotify = listeners.get(type);
+
+        // Invocation of notification on registered listeners
+        if (toNotify != null) {
+
+            // We get factory for Notification Invoker
+            MappingExtensionFactory<NotificationInvoker> invokerFactory = mappingProvider
+                    .getExtensionFactory(NotificationInvoker.class);
+
+            // We get generated invoker for NoficiationListener interface
+            // associated to Notification Type
+            NotificationInvoker invoker = invokerFactory.forClass(type);
+            for (NotificationListener listener : toNotify) {
+                try {
+                    // Invoker invokes the right method on subtype of
+                    // NotificationListener
+                    // associated to the type of notification
+                    invoker.notify(notification, listener);
+                } catch (Exception e) {
+
+                }
+            }
+        }
+    }
+
+    private void notifyBindingIndependent(Notification notification) {
+        Class<? extends Notification> type = notification.getClass();
+
+        if (biSession == null) {
+            return;
+        }
+        if (biSession.isClosed()) {
+            return;
+        }
+        if (biNotifyService == null) {
+            return;
+        }
+
+        // FIXME: Somehow we need to resolve this for class hierarchy.
+        // probably use type.getInterfaces()
+        Mapper<? extends Notification> mapper = mappingProvider.getMapper(type);
+        CompositeNode domNotification = mapper.domFromObject(notification);
+
+        biNotifyService.sendNotification(domNotification);
+    }
+
+    private class NotificationSession implements NotificationService {
+        private final ConsumerSession session;
+
+        public NotificationSession(ConsumerSession session) {
+            this.session = session;
+        }
+
+        private Map<Class<? extends Notification>, List<NotificationListener>> sessionListeners = new HashMap<Class<? extends Notification>, List<NotificationListener>>();
+
+        @Override
+        public void addNotificationListener(
+                Class<? extends Notification> notificationType,
+                NotificationListener listener) {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+        @Override
+        public void removeNotificationListener(
+                Class<? extends Notification> notificationType,
+                NotificationListener listener) {
+            // TODO Implement this method
+            throw new UnsupportedOperationException("Not implemented");
+        }
+
+    }
+
+    private class NotificationProviderSession extends NotificationSession
+            implements NotificationProviderService {
+
+        public NotificationProviderSession(ConsumerSession session) {
+            super(session);
+        }
+
+        @Override
+        public void notify(Notification notification) {
+            NotificationModule.this.notify(notification);
+        }
+
+    }
+    
+    private class BindingIndependentListener implements org.opendaylight.controller.sal.core.api.notify.NotificationListener {
+
+        @Override
+        public Set<QName> getSupportedNotifications() {
+            return Collections.emptySet();
+        }
+
+        @Override
+        public void onNotification(CompositeNode notification) {
+            NotificationModule.this.onBindingIndependentNotification(notification);
+        }
+        
+    }
+
+    private void onBindingIndependentNotification(CompositeNode biNotification) {
+        QName biType = biNotification.getNodeType();
+        
+        Mapper<DataObject> mapper = mappingProvider.getMapper(biType);
+        if(mapper == null) {
+            log.info("Received notification does not have a binding defined.");
+            return;
+        }
+        Class<DataObject> type = mapper.getDataObjectClass();
+        
+        // We check if the received QName / type is really Notification
+        if(Notification.class.isAssignableFrom(type)) {
+            Notification notification = (Notification) mapper.objectFromDom(biNotification);
+            notifyBindingAware(notification);
+        } else {
+            // The generated type for this QName does not inherits from notification
+            // something went wrong - generated APIs and/or provider sending notification
+            // which was incorectly described in the YANG schema.
+            log.error("Received notification "+  biType +" is not binded as notification");
+        }
+        
+    }
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/package-info.java b/opendaylight/sal/yang-prototype/sal/sal-binding-broker-impl/src/main/java/org/opendaylight/controller/sal/binding/impl/package-info.java
new file mode 100644 (file)
index 0000000..e5f26b9
--- /dev/null
@@ -0,0 +1,8 @@
+/*
+  * 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.impl;
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-spi/pom.xml b/opendaylight/sal/yang-prototype/sal/sal-binding-spi/pom.xml
new file mode 100644 (file)
index 0000000..720d1e9
--- /dev/null
@@ -0,0 +1,22 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>sal</artifactId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+   <artifactId>sal-binding-spi</artifactId>
+   
+   <dependencies>
+       <dependency>
+               <groupId>org.opendaylight.controller</groupId>
+               <artifactId>sal-binding-api</artifactId>
+               <version>1.0-SNAPSHOT</version>
+       </dependency>
+       <dependency>
+               <groupId>org.opendaylight.controller</groupId>
+               <artifactId>sal-core-api</artifactId>
+               <version>1.0-SNAPSHOT</version>
+       </dependency>
+   </dependencies>
+</project>
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/Mapper.java b/opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/Mapper.java
new file mode 100644 (file)
index 0000000..701e72c
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.controller.sal.binding.spi;
+
+import org.opendaylight.controller.yang.binding.DataObject;
+import org.opendaylight.controller.yang.common.QName;
+import org.opendaylight.controller.yang.data.api.CompositeNode;
+/**
+ * Translator between Binding-Independent format and generated Binding Data Objects
+ * 
+ * 
+ * 
+ * 
+ * @param <T> Result Type 
+ */
+public interface Mapper<T extends DataObject> {
+
+    QName getQName();
+    Class<T> getDataObjectClass();    
+    T objectFromDom(CompositeNode object);
+    
+    /**
+     * 
+     * @param obj
+     * @return
+     * @throws IllegalArgumentException 
+     */
+    CompositeNode domFromObject(DataObject obj) throws IllegalArgumentException;
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/MappingProvider.java b/opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/MappingProvider.java
new file mode 100644 (file)
index 0000000..a7fbb24
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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.spi;
+
+import org.opendaylight.controller.yang.binding.DataObject;
+import org.opendaylight.controller.yang.common.QName;
+
+public interface MappingProvider {
+
+    <T extends DataObject> Mapper<T> getMapper(Class<T> type);
+    Mapper<DataObject> getMapper(QName name);
+
+    <T extends MappingExtension> MappingExtensionFactory<T> getExtensionFactory(Class<T> cls);
+
+    public interface MappingExtension {
+
+    }
+    
+    public interface MappingExtensionFactory<T> {
+        T forClass(Class<?> obj);
+    }
+
+}
diff --git a/opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/SALBindingModule.java b/opendaylight/sal/yang-prototype/sal/sal-binding-spi/src/main/java/org/opendaylight/controller/sal/binding/spi/SALBindingModule.java
new file mode 100644 (file)
index 0000000..f3ecf80
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * 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.spi;
+
+import java.util.Set;
+
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareService;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerSession;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider.ProviderFunctionality;
+import org.opendaylight.controller.sal.core.api.Broker.ProviderSession;
+
+public interface SALBindingModule {
+
+    void setBroker(BindingAwareBroker broker);
+    void onBISessionAvailable(ProviderSession session);
+    
+    void setMappingProvider(MappingProvider provider);
+
+    Set<Class<? extends BindingAwareService>> getProvidedServices();
+
+    <T extends BindingAwareService> T getServiceForSession(Class<T> service,
+            ConsumerSession session);
+
+    Set<Class<? extends ProviderFunctionality>> getSupportedProviderFunctionality();
+}
index 608c24b7b5aabe719511116e9f354cbe4afed885..032dd22e3cf3efa03dbb371295d9f5f5d47c292a 100644 (file)
@@ -26,6 +26,7 @@ public class ConsumerSessionImpl implements ConsumerSession {
     private final Consumer consumer;\r
 \r
     private Map<Class<? extends BrokerService>, BrokerService> instantiatedServices = new HashMap<Class<? extends BrokerService>, BrokerService>();\r
+    private boolean closed = false;\r
 \r
     public Consumer getConsumer() {\r
         return consumer;\r
@@ -59,11 +60,16 @@ public class ConsumerSessionImpl implements ConsumerSession {
     @Override\r
     public void close() {\r
         Collection<BrokerService> toStop = instantiatedServices.values();\r
+        this.closed  = true;\r
         for (BrokerService brokerService : toStop) {\r
             brokerService.closeSession();\r
         }\r
         broker.consumerSessionClosed(this);\r
     }\r
 \r
-}\r
-
+    @Override\r
+    public boolean isClosed() {\r
+        return closed;\r
+    }\r
+\r
+}
index 46a4e3f096a1b20d0a11874278ef349d4db842e0..58ceb5f51b6a89094111f2bbfde9b5029bc8b0ba 100644 (file)
@@ -1,11 +1,3 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved. \r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-\r
 package org.opendaylight.controller.sal.core.impl.rpc;\r
 \r
 public interface RpcModule {\r
index 19c3e1777903ebec3c91aa37a8de10248f03dd24..9b3b47f8b17e8f312cb77b0688973b0d702e129a 100644 (file)
@@ -146,6 +146,8 @@ public interface Broker {
          */\r
         Future<RpcResult<CompositeNode>> rpc(QName rpc, CompositeNode input);\r
 \r
+        boolean isClosed();\r
+\r
         /**\r
          * Returns a session specific instance (implementation) of requested\r
          * service\r
@@ -229,5 +231,8 @@ public interface Broker {
          */\r
         @Override\r
         public void close();\r
+\r
+        @Override\r
+        boolean isClosed();\r
     }\r
 }\r
index 91dd78c1440a40128983bbca49ea38050ec5d3d9..a162f52d69198985ed16cc9ce3e469296a7869a4 100644 (file)
@@ -10,7 +10,7 @@
 \r
        <dependencies>\r
                <dependency>\r
-               \r
+\r
                        <groupId>org.opendaylight.controller</groupId>\r
                        <artifactId>sal-broker-impl</artifactId>\r
                        <version>1.0-SNAPSHOT</version>\r
                        <version>1.7.2</version>\r
                        <scope>runtime</scope>\r
                </dependency>\r
-       </dependencies>
+       </dependencies>\r
+       <build>\r
+               <plugins>\r
+                       <plugin>\r
+                               <artifactId>maven-assembly-plugin</artifactId>\r
+                               <version>2.4</version>\r
+                               <configuration>\r
+                                       <descriptorRefs>\r
+                                               <descriptorRef>jar-with-dependencies</descriptorRef>\r
+                                       </descriptorRefs>\r
+                                       <archive>\r
+                                               <manifest>\r
+                                                       <mainClass>org.opendaylight.controller.sal.demo.SALDemo</mainClass>\r
+                                               </manifest>\r
+                                       </archive>\r
+                               </configuration>\r
+                               <executions>\r
+                                       <execution>\r
+                                               <id>make-assembly</id>\r
+                                               <phase>package</phase>\r
+                                               <goals>\r
+                                                       <goal>single</goal>\r
+                                               </goals>\r
+                                       </execution>\r
+                               </executions>\r
+                       </plugin>\r
+\r
+               </plugins>\r
+\r
+       </build>
 </project>
\ No newline at end of file
diff --git a/opendaylight/sal/yang-prototype/yang/yang-binding/src/main/java/org/opendaylight/controller/yang/binding/DataObject.java b/opendaylight/sal/yang-prototype/yang/yang-binding/src/main/java/org/opendaylight/controller/yang/binding/DataObject.java
new file mode 100644 (file)
index 0000000..02a013e
--- /dev/null
@@ -0,0 +1,5 @@
+package org.opendaylight.controller.yang.binding;
+
+public interface DataObject {
+
+}
index babceb24d5ff96c8aaae85d5362fac97545263c2..e99bbb14c66cecbc76f04ee78e1d60a2afd771cd 100644 (file)
@@ -7,6 +7,8 @@
  */\r
 package org.opendaylight.controller.model.api.type;\r
 \r
+import java.util.List;\r
+\r
 import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
 \r
 /**\r
@@ -18,16 +20,16 @@ import org.opendaylight.controller.yang.model.api.TypeDefinition;
  * 4</a>). <br>\r
  * The canonical form of a binary value follows the rules in <a\r
  * href="https://tools.ietf.org/html/rfc4648">[RFC4648]</a>.\r
- * \r
- * \r
+ *\r
+ *\r
  */\r
 public interface BinaryTypeDefinition extends\r
         TypeDefinition<BinaryTypeDefinition> {\r
 \r
     /**\r
-     * Returns the number of octets it that binary value contains.\r
-     * \r
-     * @return the number of octets it that binary value contains.\r
+     * Returns List of number of octets that binary value contains.\r
+     *\r
+     * @return List of number of octets that binary value contains.\r
      */\r
-    public LengthConstraint getLengthConstraint();\r
+    public List<LengthConstraint> getLengthConstraints();\r
 }\r
index 050802019f7919000cb0eb34c5be57059208b6f3..1b11cd3d13b82e4cd3e1e0c760a64b69a54c2b59 100644 (file)
@@ -7,10 +7,13 @@
  */\r
 package org.opendaylight.controller.model.api.type;\r
 \r
+import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
 import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
 \r
 public interface IdentityrefTypeDefinition extends\r
         TypeDefinition<IdentityTypeDefinition> {\r
-\r
+    \r
+    public RevisionAwareXPath getPathStatement();\r
+    \r
     public IdentityTypeDefinition getIdentity();\r
 }\r
index 83510bac0f35e33f99ea3c6b8a349af886af5860..b3b2c06caa03502c904351d27e1d90a9b4d1e1fa 100644 (file)
@@ -9,8 +9,6 @@ package org.opendaylight.controller.yang.model.api;
 \r
 public interface Deviation {\r
 \r
-    MustDefinition getMustDefinition();\r
-\r
     enum Deviate {\r
         NOT_SUPPORTED, ADD, REPLACE, DELETE\r
     }\r
index ccb075f7a5494719aab83543101306a165f58056..3ad047f3b96e345cf3b9cd12af0db8edb2fbd613 100644 (file)
@@ -8,7 +8,7 @@
 package org.opendaylight.controller.yang.model.api;\r
 \r
 public interface LeafSchemaNode extends DataSchemaNode {\r
-    TypeDefinition getType();\r
 \r
-    MustDefinition getMustDefinition();\r
+    TypeDefinition<?> getType();\r
+\r
 }\r
index 6731844a5be1000a13f6c3955c2565bc9c08816c..7dda61ec7e76a05684da5ce55a56ee1368c6afbd 100644 (file)
@@ -9,6 +9,7 @@ package org.opendaylight.controller.yang.model.api;
 \r
 import java.net.URI;\r
 import java.util.Date;\r
+import java.util.List;\r
 import java.util.Set;\r
 \r
 public interface Module extends DataNodeContainer {\r
@@ -43,4 +44,6 @@ public interface Module extends DataNodeContainer {
 \r
     Set<Deviation> getDeviations();\r
 \r
+    List<ExtensionDefinition> getExtensionSchemaNodes();\r
+\r
 }\r
index df360eb43c98e7e47ac7ab34d392b19383785f45..a3364d625f4fd194bd45ad2b297a63b15c75e3ea 100644 (file)
@@ -8,5 +8,21 @@
 package org.opendaylight.controller.yang.model.api;\r
 \r
 public interface RevisionAwareXPath {\r
-\r
+    \r
+    \r
+    /**\r
+     * Returns <code>true</code> if the XPapth starts in root of Yang model, otherwise returns <code>false</cdoe>.\r
+     * \r
+     * @return <code>true</code> if the XPapth starts in root of Yang model, otherwise returns <code>false</cdoe>\r
+     */\r
+    public boolean isAbsolute();\r
+    \r
+    /**\r
+     * Returns the XPath formatted string as is defined in model. \r
+     * <br>\r
+     * For example: /prefix:container/prefix:container::cond[when()=foo]/prefix:leaf\r
+     * \r
+     * @return the XPath formatted string as is defined in model.\r
+     */\r
+    public String toString();\r
 }\r
@@ -1,30 +1,28 @@
-/*\r
- * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.\r
- *\r
- * This program and the accompanying materials are made available under the\r
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
- * and is available at http://www.eclipse.org/legal/epl-v10.html\r
- */\r
-package org.opendaylight.controller.sal.schema.api;\r
-\r
-import java.util.Set;\r
-\r
-import org.opendaylight.controller.yang.model.api.DataSchemaNode;\r
-import org.opendaylight.controller.yang.model.api.Module;\r
-import org.opendaylight.controller.yang.model.api.NotificationDefinition;\r
-import org.opendaylight.controller.yang.model.api.RpcDefinition;\r
-\r
-\r
-/**\r
- * \r
- */\r
-public interface SchemaContext {\r
-\r
-    Set<DataSchemaNode> getDataDefinitions();\r
-\r
-    Set<Module> getModules();\r
-\r
-    Set<NotificationDefinition> getNotifications();\r
-\r
-    Set<RpcDefinition> getOperations();\r
-}\r
+/*
+ * 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.yang.model.api;
+
+import java.util.Set;
+
+
+
+/**
+ * 
+ */
+public interface SchemaContext {
+
+    Set<DataSchemaNode> getDataDefinitions();
+
+    Set<Module> getModules();
+
+    Set<NotificationDefinition> getNotifications();
+
+    Set<RpcDefinition> getOperations();
+    
+    Set<ExtensionDefinition> getExtensions();
+}
index 97ca6a9585e8b07bebebcfe14f46ebbf24249933..4d3c48654db23dfc6bb7fe53887c002c2bbb03b2 100644 (file)
@@ -23,5 +23,5 @@ public interface SchemaNode {
 \r
     public Status getStatus();\r
 \r
-    public List<ExtensionDefinition> getExtensionSchemaNodes();\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes();\r
 }\r
@@ -5,13 +5,8 @@
  * 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.model.parser.builder;
+package org.opendaylight.controller.yang.model.api;
 
-/**
- * Interface for all nodes which can contain 'must' definition: [container, leaf, leaf-list, list, anyxml, deviate]
- */
-public interface MustAwareBuilder {
-
-       void setMustDefinitionBuilder(MustDefinitionBuilder mustDefinitionBuilder);
+public interface UnknownSchemaNode extends SchemaNode {
 
 }
index 61a6d69d60f6ef100a623f72e8e9c4d3092f4c3b..715dce7027d2d72fa5804254e8ec60b5cb79c816 100644 (file)
@@ -7,7 +7,12 @@
  */\r
 package org.opendaylight.controller.yang.model.api;\r
 \r
+import java.util.Set;\r
+\r
 public interface UsesNode {\r
+\r
     SchemaPath getGroupingPath();\r
+    Set<AugmentationSchema> getAugmentations();\r
+    boolean isAugmenting();\r
 \r
 }\r
index 58040225c182a1c3f002618c497c9dd4a1bfa566..33cb2b02687f956c2f8dbac5ced59ff9f08f6787 100644 (file)
@@ -13,9 +13,9 @@ import java.util.List;
 import org.opendaylight.controller.model.api.type.IntegerTypeDefinition;\r
 import org.opendaylight.controller.model.api.type.RangeConstraint;\r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public abstract class AbstractInteger implements IntegerTypeDefinition {\r
 \r
@@ -112,7 +112,7 @@ public abstract class AbstractInteger implements IntegerTypeDefinition {
     }\r
 \r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return Collections.emptyList();\r
     }\r
 \r
index 99a948960b0f7c339eb3c70b688be10e141edb8b..7429c015314317d1a5a2bcbb473d949e9955c729 100644 (file)
@@ -13,9 +13,9 @@ import java.util.List;
 import org.opendaylight.controller.model.api.type.BinaryTypeDefinition;\r
 import org.opendaylight.controller.model.api.type.LengthConstraint;\r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class BinaryType implements BinaryTypeDefinition {\r
 \r
@@ -25,29 +25,28 @@ public class BinaryType implements BinaryTypeDefinition {
     private final String reference = "";\r
 \r
     private List<Byte> bytes;\r
-    private final LengthConstraint lengthConstraint;\r
+    private final List<LengthConstraint> lengthConstraints;\r
     private String units = "";\r
 \r
     public BinaryType() {\r
         super();\r
 \r
-        lengthConstraint = BaseConstraints.lengthConstraint(0L, Long.MAX_VALUE,\r
-                null, null);\r
+        lengthConstraints = Collections.emptyList();\r
         bytes = Collections.emptyList();\r
         bytes = Collections.unmodifiableList(bytes);\r
     }\r
 \r
     public BinaryType(final List<Byte> bytes,\r
-            final LengthConstraint lengthConstraint, final String units) {\r
+            final List<LengthConstraint> lengthConstraints, final String units) {\r
         super();\r
         this.bytes = bytes;\r
-        this.lengthConstraint = lengthConstraint;\r
+        this.lengthConstraints = lengthConstraints;\r
         this.units = units;\r
     }\r
 \r
     /*\r
      * (non-Javadoc)\r
-     * \r
+     *\r
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getBaseType()\r
      */\r
     @Override\r
@@ -57,7 +56,7 @@ public class BinaryType implements BinaryTypeDefinition {
 \r
     /*\r
      * (non-Javadoc)\r
-     * \r
+     *\r
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getUnits()\r
      */\r
     @Override\r
@@ -67,7 +66,7 @@ public class BinaryType implements BinaryTypeDefinition {
 \r
     /*\r
      * (non-Javadoc)\r
-     * \r
+     *\r
      * @see org.opendaylight.controller.yang.model.api.TypeDefinition#getDefaultValue()\r
      */\r
     @Override\r
@@ -77,7 +76,7 @@ public class BinaryType implements BinaryTypeDefinition {
 \r
     /*\r
      * (non-Javadoc)\r
-     * \r
+     *\r
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getQName()\r
      */\r
     @Override\r
@@ -87,7 +86,7 @@ public class BinaryType implements BinaryTypeDefinition {
 \r
     /*\r
      * (non-Javadoc)\r
-     * \r
+     *\r
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getPath()\r
      */\r
     @Override\r
@@ -97,7 +96,7 @@ public class BinaryType implements BinaryTypeDefinition {
 \r
     /*\r
      * (non-Javadoc)\r
-     * \r
+     *\r
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getDescription()\r
      */\r
     @Override\r
@@ -107,7 +106,7 @@ public class BinaryType implements BinaryTypeDefinition {
 \r
     /*\r
      * (non-Javadoc)\r
-     * \r
+     *\r
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getReference()\r
      */\r
     @Override\r
@@ -117,7 +116,7 @@ public class BinaryType implements BinaryTypeDefinition {
 \r
     /*\r
      * (non-Javadoc)\r
-     * \r
+     *\r
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getStatus()\r
      */\r
     @Override\r
@@ -127,18 +126,18 @@ public class BinaryType implements BinaryTypeDefinition {
 \r
     /*\r
      * (non-Javadoc)\r
-     * \r
+     *\r
      * @see\r
      * org.opendaylight.controller.yang.model.base.type.api.BinaryTypeDefinition#getLengthConstraint\r
      * ()\r
      */\r
     @Override\r
-    public LengthConstraint getLengthConstraint() {\r
-        return lengthConstraint;\r
+    public List<LengthConstraint> getLengthConstraints() {\r
+        return lengthConstraints;\r
     }\r
 \r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return Collections.emptyList();\r
     }\r
 \r
@@ -151,7 +150,7 @@ public class BinaryType implements BinaryTypeDefinition {
                 + ((description == null) ? 0 : description.hashCode());\r
         result = prime\r
                 * result\r
-                + ((lengthConstraint == null) ? 0 : lengthConstraint.hashCode());\r
+                + ((lengthConstraints == null) ? 0 : lengthConstraints.hashCode());\r
         result = prime * result + ((name == null) ? 0 : name.hashCode());\r
         result = prime * result + ((path == null) ? 0 : path.hashCode());\r
         result = prime * result\r
@@ -186,11 +185,11 @@ public class BinaryType implements BinaryTypeDefinition {
         } else if (!description.equals(other.description)) {\r
             return false;\r
         }\r
-        if (lengthConstraint == null) {\r
-            if (other.lengthConstraint != null) {\r
+        if (lengthConstraints == null) {\r
+            if (other.lengthConstraints != null) {\r
                 return false;\r
             }\r
-        } else if (!lengthConstraint.equals(other.lengthConstraint)) {\r
+        } else if (!lengthConstraints.equals(other.lengthConstraints)) {\r
             return false;\r
         }\r
         if (name == null) {\r
@@ -237,8 +236,8 @@ public class BinaryType implements BinaryTypeDefinition {
         builder.append(reference);\r
         builder.append(", bytes=");\r
         builder.append(bytes);\r
-        builder.append(", lengthConstraint=");\r
-        builder.append(lengthConstraint);\r
+        builder.append(", lengthConstraints=");\r
+        builder.append(lengthConstraints);\r
         builder.append(", units=");\r
         builder.append(units);\r
         builder.append("]");\r
index 57deb07ba1213ba9a98e610e7bac129b8deac628..b783bc773090e76d56c197797d30f33d5fdd1c9b 100644 (file)
@@ -12,9 +12,9 @@ import java.util.List;
 \r
 import org.opendaylight.controller.model.api.type.BitsTypeDefinition;\r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class BitsType implements BitsTypeDefinition {\r
 \r
@@ -137,7 +137,7 @@ public class BitsType implements BitsTypeDefinition {
     }\r
 \r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return Collections.emptyList();\r
     }\r
 \r
index 361ef56bbd23f31781c6bfbca5abb5018270caf5..c9d319d2c6559eb8467d1c36627eecb4cff31aaa 100644 (file)
@@ -12,9 +12,9 @@ import java.util.List;
 \r
 import org.opendaylight.controller.model.api.type.BooleanTypeDefinition;\r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class BooleanType implements BooleanTypeDefinition {\r
 \r
@@ -137,7 +137,7 @@ public class BooleanType implements BooleanTypeDefinition {
     }\r
 \r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return Collections.emptyList();\r
     }\r
 \r
index 5c6eac1cc226bb3548efd33f43e16f6ece70c3c9..233e4607ce703eeb1cadd7f6499154e1c293a41a 100644 (file)
@@ -15,9 +15,9 @@ import java.util.List;
 import org.opendaylight.controller.model.api.type.DecimalTypeDefinition;\r
 import org.opendaylight.controller.model.api.type.RangeConstraint;\r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class Decimal64 implements DecimalTypeDefinition {\r
 \r
@@ -103,7 +103,7 @@ public class Decimal64 implements DecimalTypeDefinition {
     }\r
 \r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return Collections.emptyList();\r
     }\r
 \r
index 34d7459b36439b7c4bfe414ebbfbe23c4fc1dd21..34ac5374f7415f6e965b40571b59ecd57c86d33d 100644 (file)
@@ -12,9 +12,9 @@ import java.util.List;
 \r
 import org.opendaylight.controller.model.api.type.EnumTypeDefinition;\r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class EnumerationType implements EnumTypeDefinition {\r
 \r
@@ -133,7 +133,7 @@ public class EnumerationType implements EnumTypeDefinition {
     }\r
 \r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return Collections.emptyList();\r
     }\r
 \r
index 44ca80430c2a8b80ed65a47ea8bb1d8406e1246e..87c74be7a283ea95578a406d532c7596676e8c1c 100644 (file)
@@ -11,10 +11,10 @@ import java.util.Collections;
 import java.util.List;\r
 \r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
 import org.opendaylight.controller.yang.model.api.TypeDefinition;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class ExtendedType implements TypeDefinition {\r
 \r
@@ -23,7 +23,7 @@ public class ExtendedType implements TypeDefinition {
     private final SchemaPath path;\r
     private final String description;\r
     private final String reference;\r
-    private final List<ExtensionDefinition> extensions;\r
+    private final List<UnknownSchemaNode> unknownSchemaNodes;\r
 \r
     private Status status;\r
     private String units;\r
@@ -37,7 +37,7 @@ public class ExtendedType implements TypeDefinition {
         private final String description;\r
         private final String reference;\r
 \r
-        private List<ExtensionDefinition> extensions = Collections.emptyList();;\r
+        private List<UnknownSchemaNode> unknownSchemaNodes = Collections.emptyList();;\r
         private Status status = Status.CURRENT;\r
         private String units = "";\r
         private Object defaultValue = null;\r
@@ -66,8 +66,8 @@ public class ExtendedType implements TypeDefinition {
             return this;\r
         }\r
 \r
-        public Builder extensions(final List<ExtensionDefinition> extensions) {\r
-            this.extensions = extensions;\r
+        public Builder unknownSchemaNodes(final List<UnknownSchemaNode> unknownSchemaNodes) {\r
+            this.unknownSchemaNodes = unknownSchemaNodes;\r
             return this;\r
         }\r
 \r
@@ -82,7 +82,7 @@ public class ExtendedType implements TypeDefinition {
         this.path = builder.path;\r
         this.description = builder.description;\r
         this.reference = builder.reference;\r
-        this.extensions = builder.extensions;\r
+        this.unknownSchemaNodes = builder.unknownSchemaNodes;\r
         this.status = builder.status;\r
         this.units = builder.units;\r
         this.defaultValue = builder.defaultValue;\r
@@ -129,8 +129,8 @@ public class ExtendedType implements TypeDefinition {
     }\r
 \r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
-        return extensions;\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
+        return unknownSchemaNodes;\r
     }\r
 \r
     @Override\r
@@ -144,7 +144,7 @@ public class ExtendedType implements TypeDefinition {
         result = prime * result\r
                 + ((description == null) ? 0 : description.hashCode());\r
         result = prime * result\r
-                + ((extensions == null) ? 0 : extensions.hashCode());\r
+                + ((unknownSchemaNodes == null) ? 0 : unknownSchemaNodes.hashCode());\r
         result = prime * result + ((path == null) ? 0 : path.hashCode());\r
         result = prime * result\r
                 + ((reference == null) ? 0 : reference.hashCode());\r
@@ -188,11 +188,11 @@ public class ExtendedType implements TypeDefinition {
         } else if (!description.equals(other.description)) {\r
             return false;\r
         }\r
-        if (extensions == null) {\r
-            if (other.extensions != null) {\r
+        if (unknownSchemaNodes == null) {\r
+            if (other.unknownSchemaNodes != null) {\r
                 return false;\r
             }\r
-        } else if (!extensions.equals(other.extensions)) {\r
+        } else if (!unknownSchemaNodes.equals(other.unknownSchemaNodes)) {\r
             return false;\r
         }\r
         if (path == null) {\r
@@ -242,8 +242,8 @@ public class ExtendedType implements TypeDefinition {
         builder2.append(description);\r
         builder2.append(", reference=");\r
         builder2.append(reference);\r
-        builder2.append(", extensions=");\r
-        builder2.append(extensions);\r
+        builder2.append(", unknownSchemaNodes=");\r
+        builder2.append(unknownSchemaNodes);\r
         builder2.append(", status=");\r
         builder2.append(status);\r
         builder2.append(", units=");\r
index 2c102060e3a2ab6e69a0a9d7e81e60e6bf52f491..775d368eaf27ae543dbaedccfa3cb000c5d9ccb3 100644 (file)
@@ -12,9 +12,9 @@ import java.util.List;
 \r
 import org.opendaylight.controller.model.api.type.IdentityTypeDefinition;\r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class IdentityType implements IdentityTypeDefinition {\r
 \r
@@ -113,7 +113,7 @@ public class IdentityType implements IdentityTypeDefinition {
     }\r
 \r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return Collections.emptyList();\r
     }\r
 \r
index c4040c1f234f3507416517567a866373f1a69bc7..24ab0af1ad0806c82497f32d13e6a7661d860131 100644 (file)
@@ -13,9 +13,10 @@ import java.util.List;
 import org.opendaylight.controller.model.api.type.IdentityTypeDefinition;\r
 import org.opendaylight.controller.model.api.type.IdentityrefTypeDefinition;\r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
+import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class Identityref implements IdentityrefTypeDefinition {\r
 \r
@@ -25,12 +26,20 @@ public class Identityref implements IdentityrefTypeDefinition {
     private final String reference = "";\r
 \r
     private final IdentityTypeDefinition identity;\r
+    private final RevisionAwareXPath xpath;\r
 \r
     private String units = "";\r
 \r
-    public Identityref(IdentityTypeDefinition identity) {\r
+    public Identityref(RevisionAwareXPath xpath, IdentityTypeDefinition identity) {\r
         super();\r
         this.identity = identity;\r
+        this.xpath = xpath;\r
+    }\r
+    \r
+    public Identityref(RevisionAwareXPath xpath) {\r
+        super();\r
+        this.xpath = xpath;\r
+        this.identity = null;\r
     }\r
 \r
     /*\r
@@ -114,7 +123,7 @@ public class Identityref implements IdentityrefTypeDefinition {
     }\r
 \r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return Collections.emptyList();\r
     }\r
 \r
@@ -129,96 +138,11 @@ public class Identityref implements IdentityrefTypeDefinition {
     public IdentityTypeDefinition getIdentity() {\r
         return identity;\r
     }\r
-\r
-    @Override\r
-    public int hashCode() {\r
-        final int prime = 31;\r
-        int result = 1;\r
-        result = prime * result\r
-                + ((description == null) ? 0 : description.hashCode());\r
-        result = prime * result\r
-                + ((identity == null) ? 0 : identity.hashCode());\r
-        result = prime * result + ((name == null) ? 0 : name.hashCode());\r
-        result = prime * result + ((path == null) ? 0 : path.hashCode());\r
-        result = prime * result\r
-                + ((reference == null) ? 0 : reference.hashCode());\r
-        result = prime * result + ((units == null) ? 0 : units.hashCode());\r
-        return result;\r
-    }\r
-\r
-    @Override\r
-    public boolean equals(Object obj) {\r
-        if (this == obj) {\r
-            return true;\r
-        }\r
-        if (obj == null) {\r
-            return false;\r
-        }\r
-        if (getClass() != obj.getClass()) {\r
-            return false;\r
-        }\r
-        Identityref other = (Identityref) obj;\r
-        if (description == null) {\r
-            if (other.description != null) {\r
-                return false;\r
-            }\r
-        } else if (!description.equals(other.description)) {\r
-            return false;\r
-        }\r
-        if (identity == null) {\r
-            if (other.identity != null) {\r
-                return false;\r
-            }\r
-        } else if (!identity.equals(other.identity)) {\r
-            return false;\r
-        }\r
-        if (name == null) {\r
-            if (other.name != null) {\r
-                return false;\r
-            }\r
-        } else if (!name.equals(other.name)) {\r
-            return false;\r
-        }\r
-        if (path == null) {\r
-            if (other.path != null) {\r
-                return false;\r
-            }\r
-        } else if (!path.equals(other.path)) {\r
-            return false;\r
-        }\r
-        if (reference == null) {\r
-            if (other.reference != null) {\r
-                return false;\r
-            }\r
-        } else if (!reference.equals(other.reference)) {\r
-            return false;\r
-        }\r
-        if (units == null) {\r
-            if (other.units != null) {\r
-                return false;\r
-            }\r
-        } else if (!units.equals(other.units)) {\r
-            return false;\r
-        }\r
-        return true;\r
-    }\r
-\r
+    \r
     @Override\r
-    public String toString() {\r
-        StringBuilder builder = new StringBuilder();\r
-        builder.append("IdentityrefType [name=");\r
-        builder.append(name);\r
-        builder.append(", path=");\r
-        builder.append(path);\r
-        builder.append(", description=");\r
-        builder.append(description);\r
-        builder.append(", reference=");\r
-        builder.append(reference);\r
-        builder.append(", identity=");\r
-        builder.append(identity);\r
-        builder.append(", units=");\r
-        builder.append(units);\r
-        builder.append("]");\r
-        return builder.toString();\r
+    public RevisionAwareXPath getPathStatement() {\r
+        return xpath;\r
     }\r
+    \r
+    \r
 }\r
index 8376d9bd62a639c1b5190565581d5a06f439d34d..9a238aea1f031935a6c69c1155852f12bf5d003b 100644 (file)
@@ -12,10 +12,10 @@ import java.util.List;
 \r
 import org.opendaylight.controller.model.api.type.InstanceIdentifierTypeDefinition;\r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {\r
 \r
@@ -122,7 +122,7 @@ public class InstanceIdentifier implements InstanceIdentifierTypeDefinition {
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes()\r
      */\r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return Collections.emptyList();\r
     }\r
 \r
index 53c2c82ac3b32130121790c4ae004baa95e3df2a..9c99d4218a77c0f06a0a9246e66d4cf2fd7b5d26 100644 (file)
@@ -12,10 +12,10 @@ import java.util.List;
 \r
 import org.opendaylight.controller.model.api.type.LeafrefTypeDefinition;\r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class Leafref implements LeafrefTypeDefinition {\r
     private static final QName name = BaseTypes.constructQName("leafref");\r
@@ -116,7 +116,7 @@ public class Leafref implements LeafrefTypeDefinition {
      * @see org.opendaylight.controller.yang.model.api.SchemaNode#getExtensionSchemaNodes()\r
      */\r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return Collections.emptyList();\r
     }\r
 \r
diff --git a/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/RevisionAwareXPathImpl.java b/opendaylight/sal/yang-prototype/yang/yang-model-util/src/main/java/org/opendaylight/controller/model/util/RevisionAwareXPathImpl.java
new file mode 100644 (file)
index 0000000..d3328f3
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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.model.util;
+
+import org.opendaylight.controller.yang.model.api.RevisionAwareXPath;
+
+public class RevisionAwareXPathImpl implements RevisionAwareXPath {
+
+    private final String xpath;
+    private final boolean absolute;
+
+    public RevisionAwareXPathImpl(String xpath, boolean absolute) {
+        this.xpath = xpath;
+        this.absolute = absolute;
+    }
+
+    @Override
+    public boolean isAbsolute() {
+        return absolute;
+    }
+
+    @Override
+    public String toString() {
+        return xpath;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((xpath == null) ? 0 : xpath.hashCode());
+        result = prime * result + (absolute ? 1231 : 1237);
+        return result;
+    }
+
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        RevisionAwareXPathImpl other = (RevisionAwareXPathImpl) obj;
+        if (xpath == null) {
+            if (other.xpath != null) {
+                return false;
+            }
+        } else if (!xpath.equals(other.xpath)) {
+            return false;
+        }
+        if (absolute != other.absolute) {
+            return false;
+        }
+        return false;
+    }
+
+}
index f64083129717a855b2f378f93fb7a2ecec89fe13..99b6d26684af44bad5949e60acca58a1cd0aa190 100644 (file)
@@ -14,9 +14,9 @@ import org.opendaylight.controller.model.api.type.LengthConstraint;
 import org.opendaylight.controller.model.api.type.PatternConstraint;\r
 import org.opendaylight.controller.model.api.type.StringTypeDefinition;\r
 import org.opendaylight.controller.yang.common.QName;\r
-import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class StringType implements StringTypeDefinition {\r
 \r
@@ -159,7 +159,7 @@ public class StringType implements StringTypeDefinition {
     }\r
 \r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return Collections.emptyList();\r
     }\r
 \r
index b1e1082c607e98f1c7fa7465e25a6672c1841f18..f0b5ddd2865f2c34aec5eb70c3b7eedc23d7798a 100644 (file)
@@ -18,6 +18,7 @@ import org.opendaylight.controller.yang.common.QName;
 import org.opendaylight.controller.yang.model.api.ExtensionDefinition;\r
 import org.opendaylight.controller.yang.model.api.SchemaPath;\r
 import org.opendaylight.controller.yang.model.api.Status;\r
+import org.opendaylight.controller.yang.model.api.UnknownSchemaNode;\r
 \r
 public class UnknownType implements UnknownTypeDefinition {\r
 \r
@@ -29,7 +30,7 @@ public class UnknownType implements UnknownTypeDefinition {
     private final List<LengthConstraint> lengthStatements;\r
     private final List<PatternConstraint> patterns;\r
     private final List<RangeConstraint> rangeStatements;\r
-    private final List<ExtensionDefinition> extensions;\r
+    private final List<UnknownSchemaNode> extensions;\r
     private final LengthConstraint lengthConstraint;\r
 \r
     private final Status status;\r
@@ -47,7 +48,7 @@ public class UnknownType implements UnknownTypeDefinition {
                 .emptyList();\r
         private List<PatternConstraint> patterns = Collections.emptyList();\r
         private List<RangeConstraint> rangeStatements = Collections.emptyList();\r
-        private List<ExtensionDefinition> extensions = Collections.emptyList();\r
+        private List<UnknownSchemaNode> extensions = Collections.emptyList();\r
         private LengthConstraint lengthConstraint = null;\r
 \r
         private Status status = Status.CURRENT;\r
@@ -94,7 +95,7 @@ public class UnknownType implements UnknownTypeDefinition {
             return this;\r
         }\r
 \r
-        public Builder extensions(final List<ExtensionDefinition> extensions) {\r
+        public Builder extensions(final List<UnknownSchemaNode> extensions) {\r
             this.extensions = extensions;\r
             return this;\r
         }\r
@@ -231,7 +232,7 @@ public class UnknownType implements UnknownTypeDefinition {
      * ()\r
      */\r
     @Override\r
-    public List<ExtensionDefinition> getExtensionSchemaNodes() {\r
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {\r
         return extensions;\r
     }\r
 \r
index 1ab1dc63b1a9f46ca8716a428384be3915117dcb..a09d27e340bbab323b4679ad0d212a9963cb83eb 100644 (file)
@@ -59,16 +59,21 @@ public class YangTypesConverter {
         baseYangTypes.add("bits");\r
         baseYangTypes.add("boolean");\r
         baseYangTypes.add("decimal64");\r
+        baseYangTypes.add("empty");\r
         baseYangTypes.add("enumeration");\r
+        baseYangTypes.add("identityref");\r
+        baseYangTypes.add("instance-identifier");\r
         baseYangTypes.add("int8");\r
         baseYangTypes.add("int16");\r
         baseYangTypes.add("int32");\r
         baseYangTypes.add("int64");\r
+        baseYangTypes.add("leafref");\r
         baseYangTypes.add("string");\r
         baseYangTypes.add("uint8");\r
         baseYangTypes.add("uint16");\r
         baseYangTypes.add("uint32");\r
         baseYangTypes.add("uint64");\r
+        baseYangTypes.add("union");\r
     }\r
 \r
     public static boolean isBaseYangType(String type) {\r