Bug 2366 - new parser API - implementation of declared statements 30/16130/26
authorMartin Ciglan <mciglan@cisco.com>
Tue, 14 Apr 2015 14:31:07 +0000 (16:31 +0200)
committerMartin Ciglan <mciglan@cisco.com>
Tue, 14 Apr 2015 14:31:07 +0000 (16:31 +0200)
- added integration between ANTL4 parsing YANG file and new parser
- added test to demonstrate it
- added implementation of yang statements and their definitions resp. support
  classes
- added implementation of effective statements and integration to yang.model.api
- added effective build implementation and unit tests of effective build
- added new namespaces
- added new utils and parsing methods
- added simple unit tests

Bugfixing:
- fix of phases switching bugs on two places
- fix of argument parsing before parent ctx assigment (NPE on null parent)
- fix of values retrieval from sourceLocal and treeScoped namespaces
- fix of tryToComplete method in SourceSpecificContext class. Method did not
  return correct progress result although everything was resolved
  correctly

Change-Id: I5d6acc69bb877b26403d69e276ed5c578e9bd4d9
Signed-off-by: Peter Kajsa <pkajsa@cisco.com>
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
Signed-off-by: Gregor Zatko <gzatko@cisco.com>
Signed-off-by: Martin Ciglan <mciglan@cisco.com>
169 files changed:
yang/yang-common/src/main/java/org/opendaylight/yangtools/yang/common/SimpleDateFormatUtil.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/AnyXmlNode.java
yang/yang-data-api/src/main/java/org/opendaylight/yangtools/yang/data/api/schema/stream/NormalizedNodeStreamWriter.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/Rfc6020Mapping.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/meta/EffectiveStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/ArgumentStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/IdentityStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/MandatoryStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/NotificationStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/RequireInstanceStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/RevisionStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/RpcStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/TypeStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/TypedefStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/YangVersionStatement.java
yang/yang-model-api/src/main/java/org/opendaylight/yangtools/yang/model/api/stmt/YinElementStatement.java
yang/yang-parser-impl/src/main/antlr/YangStatementLexer.g4
yang/yang-parser-impl/src/main/antlr/YangStatementParser.g4
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/builder/impl/ModuleIdentifierImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangStatementParserListenerImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/NamespaceBehaviour.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StatementSupportBundle.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/meta/StmtContextUtils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/BelongsToPrefixToModuleName.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ImpPrefixToModuleIdentifier.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleIdentifierToModuleQName.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleNameToModuleQName.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleQNameToModuleName.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/QNameToStatementDefinitionMap.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/BuildGlobalContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/CrossSourceStatementReactor.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/EffectiveModelContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/ModifierImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/NamespaceStorageSupport.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/RootStatementContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SourceSpecificContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementContextBase.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/StatementDefinitionContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/reactor/SubstatementContext.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AnyxmlStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ArgumentStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AugmentStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BaseStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BelongsToStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BitStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BitsSpecificationImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/CaseStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ChoiceStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ConfigStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ContactStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ContainerStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Decimal64SpecificationImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DefaultStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DescriptionStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviateStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviationStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/EnumSpecificationImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/EnumStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ErrorAppTagStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ErrorMessageStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ExtensionStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/FeatureStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/FractionDigitsStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingUtils.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IdentityRefSpecificationImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IdentityStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IfFeatureStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ImportStatementDefinition.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IncludeStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IncludedModuleContext.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/InputStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/InstanceIdentifierSpecificationImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/KeyStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LeafListStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LeafStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LeafrefSpecificationImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LengthStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ListStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MandatoryStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MaxElementsStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MinElementsStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ModuleStatementSupport.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MustStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/NamespaceStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/NotificationStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/NumericalRestrictionsImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/OrderedByStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/OrganizationStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/OutputStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/PatternStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/PositionStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/PrefixStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/PresenceStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RangeStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ReferenceStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RefineStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RequireInstanceStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RevisionDateStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RevisionStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RpcStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/StatusStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/StringRestrictionsImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/SubmoduleStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/TypeStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/TypedefStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/UnionSpecificationImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/UnitsStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/UsesStatementImpl.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Utils.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ValueStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/WhenStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangInferencePipeline.java
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangStatementSourceImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangVersionStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YinElementStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedDataNodeContainer.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedNode.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveSchemaContext.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContainerEffectiveStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DescriptionEffectiveStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveSchemaContext.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/GroupingEffectiveStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ModuleEffectiveStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NamespaceEffectiveStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PrefixEffectiveStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PresenceEffectiveStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ReferenceEffectiveStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UsesEffectiveStatementImpl.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/effective/build/test/EffectiveBuildTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/effective/build/test/YangFileStatementSource.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/ImportBasicTestStatementSource.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/ImportResolutionBasicTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/ImportResolutionTest.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/ImportRevisionsTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/IncludeResolutionTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/IncludeRevisionsTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/IncludeTestStatementSource.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/TestStatementSource.java
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/TestYangFileStatementSource.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/UsesResolutionTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/UsesTestStatementSource.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/YangFileStmtTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/augment/AugmentTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/augment/TestAugmentSource.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/key/KeyTest.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/key/TestKeySource.java [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/model/foo.yang
yang/yang-parser-impl/src/test/resources/revisions/equal-rev.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/revisions/equal-root.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/revisions/mod-1970-rev.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/revisions/mod-1970-root.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/revisions/mod-only-rev.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/revisions/mod-only-root.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/revisions/nowhere-rev.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/revisions/nowhere-root.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/revisions/submod-only-rev.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/revisions/submod-only-root.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/revisions/unequal-rev.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/revisions/unequal-root.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-statement-parser/ext-typedef.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-statement-parser/ext-use.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-statement-parser/foo.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-statement-parser/importedtest.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-statement-parser/simple-nodes-semantic.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/semantic-statement-parser/test.yang [new file with mode: 0644]
yang/yang-parser-impl/src/test/resources/stmt-test/effective-build/simple-module.yang [new file with mode: 0644]

index 3824f4afd36b4b9a4c402951c7d96e7f880c472e..303ef4f2e06f3c17e13c9de02a648a2e44e49816 100644 (file)
@@ -8,10 +8,29 @@
 
 package org.opendaylight.yangtools.yang.common;
 
+import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.util.Date;
 
 public final class SimpleDateFormatUtil {
 
+    private static final String REVISION_SIMPLE_DATE = "yyyy-MM-dd";
+    private static final String DEFAULT_DATE = "1970-01-01";
+
+    public static Date DEFAULT_DATE_REV;
+    public static Date DEFAULT_DATE_IMP;
+
+    static {
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(REVISION_SIMPLE_DATE);
+
+        try {
+            DEFAULT_DATE_REV = simpleDateFormat.parse(DEFAULT_DATE);
+            DEFAULT_DATE_IMP = simpleDateFormat.parse(DEFAULT_DATE);
+        } catch (ParseException e) {
+            throw new ExceptionInInitializerError(e);
+        }
+    }
+
     private SimpleDateFormatUtil() {
         throw new UnsupportedOperationException("Utility class should not be instantiated");
     }
@@ -20,7 +39,7 @@ public final class SimpleDateFormatUtil {
 
         @Override
         protected SimpleDateFormat initialValue() {
-            return new SimpleDateFormat("yyyy-MM-dd");
+            return new SimpleDateFormat(REVISION_SIMPLE_DATE);
         }
 
         @Override
index a2bd7a72de76cb27a7ac741fe7ffcbc3712cc533..cff313dc95097ec40475bfa831ac435ad69f6dbb 100644 (file)
@@ -12,7 +12,7 @@ import org.opendaylight.yangtools.yang.data.api.AttributesContainer;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifier;
 
 /**
- * Anyxml normalizedNode.
+ * AN normalizedNode.
  */
 public interface AnyXmlNode extends AttributesContainer, DataContainerChild<NodeIdentifier, DOMSource> {
 
index 1168a0b116bf00bb5b14804f8be9734bd0e5dfe8..94b5ba69e57457ef0c503468ebd08063ed384e24 100644 (file)
@@ -52,7 +52,7 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
  * {@link #endNode()}. Leaf list entries are emmited using
  * {@link #leafSetEntryNode(Object)}.
  *
- * <li><code>anyxml - Anyxml node event is emitted using
+ * <li><code>anyxml - AN node event is emitted using
  * {@link #leafNode(NodeIdentifier, Object)}. {@link #endNode()} MUST NOT BE emitted
  * for anyxml node.</code></li>
  *
index fca62d4850b4a702126c52cba75b38efdb184260..1bf809567dbc5d91ed5d3ef8b2e4b5d80ea7ae24 100644 (file)
@@ -11,6 +11,7 @@ import com.google.common.annotations.Beta;
 import com.google.common.base.Preconditions;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
+
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.common.YangConstants;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
@@ -81,6 +82,7 @@ import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
 
+
 @Beta
 public enum Rfc6020Mapping implements StatementDefinition {
     ANYXML(AnyxmlStatement.class, "anyxml", "name"),
index 026a0a04093681f3b537f9408e1e6f5591c0ab47..b7b97d8e12e3d20be073c7ed513852d8c67eddcc 100644 (file)
@@ -51,8 +51,9 @@ public interface EffectiveStatement<A, S extends DeclaredStatement<A>> extends M
      *
      *
      */
+    //<K, V, N extends IdentifierNamespace<? super K, ? extends V>> V
     @Nullable
-    <K, V, N extends IdentifierNamespace<? super K, ? extends V>> V get(@Nonnull Class<N> namespace,@Nonnull  K identifier);
+    public <K,V,N extends IdentifierNamespace<K, V>> V get(@Nonnull Class<N> namespace,@Nonnull  K identifier);
 
     /**
      *
index 2f83adfe6322b084c36253e135e8a31826e3672e..ff63ef1ca516594ab31070df31142170ed2bd23c 100644 (file)
@@ -17,7 +17,7 @@ import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 @Rfc6020AbnfRule("argument-stmt")
 public interface ArgumentStatement extends DeclaredStatement<QName> {
 
-    @Nonnull String getName();
+    @Nonnull QName getName();
 
     @Nullable YinElementStatement getYinElement();
 
index 07b61c5858a0b1a821cfd2bcad55fddc04ef7e87..8ed06fa70e939a034b7213b35d379d5af8985702 100644 (file)
@@ -14,7 +14,7 @@ import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
 public interface IdentityStatement extends DeclaredStatement<QName>, DocumentationGroup.WithStatus {
 
-    @Nonnull String getName();
+    @Nonnull QName getName();
 
     @Nullable BaseStatement getBase();
 
index d5ec65eeb4a4bf650a99547aa1f7b01bfa468f96..4d727b18b11ce93f3f0f4c9aa9e272d7ae5d726e 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.yangtools.yang.model.api.stmt;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
-public interface MandatoryStatement extends DeclaredStatement<String> {
+public interface MandatoryStatement extends DeclaredStatement<Boolean> {
 
-    @Nonnull String getValue();
+    @Nonnull Boolean getValue();
 }
 
index fed0ca6c8080b607fcc76699dc31e39ef9fce6c1..e60c1ddcb9fddc649c6bcf11425691bd551f647e 100644 (file)
@@ -11,7 +11,7 @@ import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
-public interface NotificationStatement extends DeclaredStatement<QName> {
+public interface NotificationStatement extends DeclaredStatement<QName>, DataDefinitionContainer.WithReusableDefinitions, DocumentationGroup.WithStatus {
 
     @Nonnull QName getName();
 }
index b1de1e8a31272ddefff9c914e0b40b21416401f5..a909cf7b577446421547889a579731f484edc7c9 100644 (file)
@@ -13,6 +13,6 @@ import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
 public interface RequireInstanceStatement extends DeclaredStatement<Boolean> {
 
-    @Nonnull String getValue();
+    @Nonnull Boolean getValue();
 }
 
index fd6d850ab683079ea7f9b371c4b142781778dc86..66d2603cb6ae7d8703bccde73c342afc4c6e8396 100644 (file)
@@ -7,10 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.model.api.stmt;
 
+import java.util.Date;
+
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
-public interface RevisionStatement extends DeclaredStatement<String>, DocumentationGroup {
+public interface RevisionStatement extends DeclaredStatement<Date>, DocumentationGroup {
 
-    String getDate();
+    Date getDate();
 
 }
index 45cb5069ac9b34d85c3742c4bd265ad53af37822..9a39d0da4934c18f1300e47871a0b360c388642c 100644 (file)
@@ -7,11 +7,20 @@
  */
 package org.opendaylight.yangtools.yang.model.api.stmt;
 
+import java.util.Collection;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
-public interface RpcStatement extends DeclaredStatement<QName> {
+public interface RpcStatement extends DeclaredStatement<QName>, DocumentationGroup.WithStatus, ConditionalFeature {
 
-    String getName();
+    QName getName();
+
+    Collection<? extends TypedefStatement> getTypedefs();
+
+    Collection<? extends GroupingStatement> getGroupings();
+
+    InputStatement getInput();
+
+    OutputStatement getOutput();
 
 }
index a89d1da5345ec4644fc93c4b8e83a2c993ac1499..42b45c38b4e17f8d66c856e57ff13586511dad1d 100644 (file)
@@ -10,11 +10,10 @@ package org.opendaylight.yangtools.yang.model.api.stmt;
 import java.util.Collection;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
-import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
 @Rfc6020AbnfRule("type-stmt")
-public interface TypeStatement extends DeclaredStatement<QName> {
+public interface TypeStatement extends DeclaredStatement<String> {
 
     @Nonnull String getName();
 
index eee2f91e9b67e4b10545af312af3941859d5f2eb..c3eab244418c02a1b38ba1ff0dda513548086e47 100644 (file)
@@ -14,7 +14,7 @@ import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 public interface TypedefStatement extends DeclaredStatement<QName>,DocumentationGroup.WithStatus, TypeGroup {
 
 
-    @Nonnull String getName();
+    @Nonnull QName getName();
 
 }
 
index ff75fee6be22a60c046eb40541b233d3c376f1d1..0c8d6c3a5ceba7b08c3a31162deb30f1133de52c 100644 (file)
@@ -9,7 +9,10 @@ package org.opendaylight.yangtools.yang.model.api.stmt;
 
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
+import javax.annotation.Nonnull;
+
 public interface YangVersionStatement extends DeclaredStatement<String> {
 
+        @Nonnull String getValue();
 }
 
index 949e443c639ad3e1a0ba70d8a2ba302626aa4758..bb9ee75bf37c3429f1c7aec01f9f6dac4c01f604 100644 (file)
@@ -10,8 +10,8 @@ package org.opendaylight.yangtools.yang.model.api.stmt;
 import javax.annotation.Nonnull;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 
-public interface YinElementStatement extends DeclaredStatement<String> {
+public interface YinElementStatement extends DeclaredStatement<Boolean> {
 
-    @Nonnull String getValue();
+    @Nonnull Boolean getValue();
 }
 
index c69853de961974f5571ab9f3c12b2c537c71c6a7..b5fc095a4cd2c88157e1dac9872834ca4c755527 100644 (file)
@@ -39,7 +39,7 @@ fragment ESC : '\\' (["\\/bfnrt] | UNICODE);
 fragment UNICODE : 'u' HEX HEX HEX HEX;
 fragment HEX : [0-9a-fA-F] ;
 
-STRING : ((~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '"' | '\'' | ':' | '/' | '=' | '[' | ']' )~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | ':' | '/' | '=' | '[' | ']')* ) | SUB_STRING );
+STRING : ((~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | '"' | '\'' | ':' | '/' | '=' | '[' | ']' | '+' )~( '\r' | '\n' | '\t' | ' ' | ';' | '{' | ':' | '/' | '=' | '[' | ']')* ) | SUB_STRING );
 
 mode BLOCK_COMMENT_MODE;
 END_BLOCK_COMMENT : '*/' -> popMode, skip;
index 3ac195dfbe89d82bb01ddd0d15c18a3ef52615a8..5d975ad69c8b9816c66dd8f48b6a70d8d6e3134e 100644 (file)
@@ -18,4 +18,4 @@ options{
 statement : SEP? keyword SEP? (argument)? SEP? (SEMICOLON | LEFT_BRACE SEP? (statement)* SEP? RIGHT_BRACE SEP?) SEP?;
 keyword : (IDENTIFIER COLON)? IDENTIFIER;
 
-argument : STRING | IDENTIFIER | STRING (SEP? PLUS SEP? STRING)*;
\ No newline at end of file
+argument : STRING (SEP? PLUS SEP? STRING)* | IDENTIFIER;
\ No newline at end of file
index 5a32774036a56b0809a68863a893c9e5a8f43020..6e825dd666473fe878c46deb8bbc85f41c732517 100644 (file)
@@ -9,6 +9,8 @@ package org.opendaylight.yangtools.yang.parser.builder.impl;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+
 import com.google.common.base.Optional;
 import java.net.URI;
 import java.util.Date;
@@ -77,8 +79,29 @@ public class ModuleIdentifierImpl implements ModuleIdentifier {
         if (getNamespace() != null && !getNamespace().equals(that.getNamespace())) {
             return false;
         }
+
+        Date defaultRev = SimpleDateFormatUtil.DEFAULT_DATE_REV;
+        Date defaultImp = SimpleDateFormatUtil.DEFAULT_DATE_IMP;
+
+        // if revision is in import only, spec says that it is undefined which
+        // revision to take
+        if (getRevision() == defaultImp ^ that.getRevision() == defaultImp) {
+            return true;
+        }
+
+        // default and none revisions taken as equal
+        if ((defaultRev.equals(getRevision()) && that.getRevision() == null)
+                || (defaultRev.equals(that.getRevision()) && getRevision() == null)) {
+            return true;
+        }
+
+        // else if none of them is default and one null
+        if (getRevision() == null ^ that.getRevision() == null) {
+            return false;
+        }
+
         // only fail if this revision is non-null
-        if (getRevision() != null && !getRevision().equals(that.getRevision())) {
+        if (getRevision() != null && that.getRevision() != null && !getRevision().equals(that.getRevision())) {
             return false;
         }
 
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangStatementParserListenerImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/impl/YangStatementParserListenerImpl.java
new file mode 100644 (file)
index 0000000..cfc3546
--- /dev/null
@@ -0,0 +1,102 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.impl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.antlr.v4.runtime.tree.ParseTree;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParserBaseListener;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.YangConstants;
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.Utils;
+
+public class YangStatementParserListenerImpl extends YangStatementParserBaseListener {
+
+    private StatementWriter writer;
+    private StatementSourceReference ref;
+    private QNameToStatementDefinition stmtDef;
+    private PrefixToModule prefixes;
+    private List<String> toBeSkipped = new ArrayList<>();
+
+    public YangStatementParserListenerImpl(StatementSourceReference ref) {
+        this.ref = ref;
+    }
+
+    public void setAttributes(StatementWriter writer, QNameToStatementDefinition stmtDef) {
+        this.writer = writer;
+        this.stmtDef = stmtDef;
+    }
+
+    public void setAttributes(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes) {
+        this.writer = writer;
+        this.stmtDef = stmtDef;
+        this.prefixes = prefixes;
+    }
+
+    @Override
+    public void enterStatement(YangStatementParser.StatementContext ctx) {
+        boolean action = true;
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof YangStatementParser.KeywordContext) {
+                try {
+                    QName identifier = new QName(YangConstants.RFC6020_YIN_NAMESPACE,
+                            ((YangStatementParser.KeywordContext) child).children.get(0).getText());
+                    if (stmtDef != null && stmtDef.get(identifier) != null && toBeSkipped.isEmpty()) {
+                        writer.startStatement(identifier, ref);
+                    } else {
+                        action = false;
+                        toBeSkipped.add(((YangStatementParser.KeywordContext) child).children.get(0).getText());
+                    }
+                } catch (SourceException e) {
+                    e.printStackTrace();
+                }
+            } else if (child instanceof YangStatementParser.ArgumentContext) {
+                try {
+                    if (action)
+                        writer.argumentValue(
+                                Utils.stringFromStringContext((YangStatementParser.ArgumentContext) child), ref);
+                    else
+                        action = true;
+                } catch (SourceException e) {
+                    e.printStackTrace();
+                }
+            }
+
+        }
+    }
+
+    @Override
+    public void exitStatement(YangStatementParser.StatementContext ctx) {
+        for (int i = 0; i < ctx.getChildCount(); i++) {
+            ParseTree child = ctx.getChild(i);
+            if (child instanceof YangStatementParser.KeywordContext) {
+                try {
+                    String statementName = ((YangStatementParser.KeywordContext) child).children.get(0).getText();
+                    QName identifier = new QName(YangConstants.RFC6020_YIN_NAMESPACE, statementName);
+                    if (stmtDef != null && stmtDef.get(identifier) != null && toBeSkipped.isEmpty()) {
+                        writer.endStatement(ref);
+                    }
+
+                    if (toBeSkipped.contains(statementName)) {
+                        toBeSkipped.remove(statementName);
+                    }
+                } catch (SourceException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+    }
+}
index cdff074d675638e0b9eaef3f3d236a865e166850..129110d8537491c41716a7db9f59d40bcdcb7042 100644 (file)
@@ -46,6 +46,8 @@ public abstract class NamespaceBehaviour<K,V, N extends IdentifierNamespace<K, V
 
         @Nullable  <K, V, N extends IdentifierNamespace<K, V>> V getFromLocalStorage(Class<N> type, K key);
 
+        //<K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAllFromLocalStorage(Class<N> type);
+
         @Nullable  <K, V, N extends IdentifierNamespace<K, V>> void addToLocalStorage(Class<N> type, K key, V value);
 
     }
@@ -100,6 +102,9 @@ public abstract class NamespaceBehaviour<K,V, N extends IdentifierNamespace<K, V
     }
 
     public abstract V getFrom(NamespaceStorageNode storage, K key);
+
+    //public abstract Map<K, V> getAllFrom(NamespaceStorageNode storage);
+
     public abstract void addTo(NamespaceStorageNode storage,K key,V value);
 
     @Override
@@ -111,6 +116,10 @@ public abstract class NamespaceBehaviour<K,V, N extends IdentifierNamespace<K, V
         return storage.getFromLocalStorage(getIdentifier(), key);
     }
 
+//    protected final Map<K, V> getAllFromLocalStorage(NamespaceStorageNode storage) {
+//        return storage.getAllFromLocalStorage(getIdentifier());
+//    }
+
     protected final void addToStorage(NamespaceStorageNode storage,K key,V value) {
         storage.addToLocalStorage(getIdentifier(),key,value);
     }
@@ -127,12 +136,21 @@ public abstract class NamespaceBehaviour<K,V, N extends IdentifierNamespace<K, V
         @Override
         public V getFrom(final NamespaceStorageNode storage, final K key) {
             NamespaceStorageNode current = storage;
-            while(current.getParentNamespaceStorage() != null) {
+            while(current.getStorageNodeType() != storageType) {
                 current = current.getParentNamespaceStorage();
             }
             return getFromLocalStorage(current,key);
         }
 
+//        @Override
+//        public Map<K, V> getAllFrom(final NamespaceStorageNode storage) {
+//            NamespaceStorageNode current = storage;
+//            while(current.getStorageNodeType() != storageType) {
+//                current = current.getParentNamespaceStorage();
+//            }
+//            return getAllFromLocalStorage(current);
+//        }
+
         @Override
         public void addTo(NamespaceBehaviour.NamespaceStorageNode storage, K key, V value) {
             NamespaceStorageNode current = storage;
@@ -163,6 +181,19 @@ public abstract class NamespaceBehaviour<K,V, N extends IdentifierNamespace<K, V
             return null;
         }
 
+//        @Override
+//        public Map<K, V> getAllFrom(final NamespaceStorageNode storage) {
+//            NamespaceStorageNode current = storage;
+//            while(current != null) {
+//                final Map<K, V> val = getAllFromLocalStorage(current);
+//                if(val != null) {
+//                    return val;
+//                }
+//                current = current.getParentNamespaceStorage();
+//            }
+//            return null;
+//        }
+
         @Override
         public void addTo(NamespaceStorageNode storage,K key, V value) {
             addToStorage(storage, key, value);
index 2002cf513527a53ecd52c97c8c5439b4f1a68c9e..01435600334c555d263c69ded77d1dff597b2452 100644 (file)
@@ -23,6 +23,10 @@ public final class StatementSupportBundle implements Immutable,NamespaceBehaviou
     private final ImmutableMap<QName, StatementSupport<?,?,?>> definitions;
     private final ImmutableMap<Class<?>, NamespaceBehaviour<?, ?, ?>> namespaceDefinitions;
 
+    public ImmutableMap<QName, StatementSupport<?, ?, ?>> getDefinitions() {
+        return definitions;
+    }
+
     private StatementSupportBundle(StatementSupportBundle parent,
             ImmutableMap<QName, StatementSupport<?, ?, ?>> statements,
             ImmutableMap<Class<?>, NamespaceBehaviour<?, ?, ?>> namespaces) {
index 124d6bf9e18772f52b02e1ea3ba133e5b60c904d..514d283e2e5d4f809dc4d1509ba0d51314b0af56 100644 (file)
@@ -7,6 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.parser.spi.meta;
 
+import java.util.Map;
+
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
 import java.util.Collection;
 import javax.annotation.Nonnull;
 import javax.annotation.Nullable;
@@ -32,21 +37,30 @@ public interface StmtContext<A,D extends DeclaredStatement<A>, E extends Effecti
 
     @Nullable A getStatementArgument();
 
-    @Nonnull <K,VT, V extends VT,N extends IdentifierNamespace<K, V>> VT getFromNamespace(Class<N> type, K key) throws NamespaceNotAvailableException;
+    //<K,VT, V extends VT,N extends IdentifierNamespace<K, V>>
+    //       <K, VT, V extends VT ,N extends IdentifierNamespace<K, V>> VT getFromNamespace(Class<N> type, K key)
+    @Nonnull <K,V,N extends IdentifierNamespace<K, V>> V getFromNamespace(Class<N> type, K key) throws NamespaceNotAvailableException;
+
+    <K, V, N extends IdentifierNamespace<K, V>> Map<?, ?> getAllFromNamespace(Class<N> type);
 
     @Nonnull StmtContext<?,?,?> getRoot();
 
-    @Nonnull Collection<? extends StmtContext<?,?,?>> declaredSubstatements();
+    @Nonnull Collection<StatementContextBase<?,?,?>> declaredSubstatements();
+
+    public Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements();
 
     D buildDeclared();
 
     E buildEffective();
 
+    public StatementContextBase<?, ?, ?>  createCopy(QNameModule newQNameModule,StatementContextBase<?, ?, ?> newParent) throws SourceException;
+
     interface Mutable<A,D extends DeclaredStatement<A>,E extends EffectiveStatement<A, D>> extends StmtContext<A,D,E> {
 
         @Override
         StmtContext.Mutable<?,?,?> getParentContext();
 
+        //<K,V,VT extends V,N extends IdentifierNamespace<K, V>> void addToNs(Class<N> type, K key, VT value)
         <K,V,VT extends V,N extends IdentifierNamespace<K, V>> void addToNs(Class<N> type, K key, VT value) throws NamespaceNotAvailableException;
 
         @Override
index 1838e6effc97c288cd70b5d8f860ecd8469d37b7..fa2e78bddb21689f1b33376e572be8ceea10b0d0 100644 (file)
@@ -7,6 +7,7 @@
  */
 package org.opendaylight.yangtools.yang.parser.spi.meta;
 
+import java.util.Collection;
 import com.google.common.base.Function;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@@ -15,14 +16,14 @@ public final class StmtContextUtils {
 
     private static final Function<StmtContext<?, ?,?>, DeclaredStatement<?>> BUILD_DECLARED = new Function<StmtContext<?,?,?>, DeclaredStatement<?>>() {
         @Override
-        public DeclaredStatement<?> apply(StmtContext<?,?,?> input) {
+        public DeclaredStatement<?> apply(StmtContext<?, ?, ?> input) {
             return input.buildDeclared();
         }
     };
 
     private static final Function<StmtContext<?, ?,?>, EffectiveStatement<?,?>> BUILD_EFFECTIVE = new Function<StmtContext<?,?,?>, EffectiveStatement<?,?>>() {
         @Override
-        public EffectiveStatement<?,?> apply(StmtContext<?,?,?> input) {
+        public EffectiveStatement<?, ?> apply(StmtContext<?, ?, ?> input) {
             return input.buildEffective();
         }
     };
@@ -37,21 +38,109 @@ public final class StmtContextUtils {
     }
 
     @SuppressWarnings("unchecked")
-    public static <E extends EffectiveStatement<?,?>> Function<StmtContext<?, ?,? extends E>, E> buildEffective() {
+
+    public static final <E extends EffectiveStatement<?, ?>> Function<StmtContext<?, ?, ? extends E>, E> buildEffective() {
         return Function.class.cast(BUILD_EFFECTIVE);
     }
 
     @SuppressWarnings("unchecked")
-    public static <AT,DT extends DeclaredStatement<AT>> AT firstAttributeOf(Iterable<? extends StmtContext<?,?,?>> contexts, Class<DT> declaredType) {
-        for(StmtContext<?, ?, ?> ctx : contexts) {
-            if(producesDeclared(ctx,declaredType)) {
+    public static final <AT, DT extends DeclaredStatement<AT>> AT firstAttributeOf(
+            Iterable<? extends StmtContext<?, ?, ?>> contexts,
+            Class<DT> declaredType) {
+        for (StmtContext<?, ?, ?> ctx : contexts) {
+            if (producesDeclared(ctx, declaredType)) {
                 return (AT) ctx.getStatementArgument();
             }
         }
         return null;
     }
 
-    public static boolean producesDeclared(StmtContext<?, ?, ?> ctx, Class<? extends DeclaredStatement<?>> type) {
-        return type.isAssignableFrom(ctx.getPublicDefinition().getDeclaredRepresentationClass());
+    @SuppressWarnings("unchecked")
+    public static final <AT, DT extends DeclaredStatement<AT>> AT firstAttributeOf(
+            StmtContext<?, ?, ?> ctx, Class<DT> declaredType) {
+
+        if (producesDeclared(ctx, declaredType)) {
+            return (AT) ctx.getStatementArgument();
+        }
+
+        return null;
+    }
+
+    public static final <DT extends DeclaredStatement<?>> StmtContext<?, ?, ?> findFirstDeclaredSubstatement(
+            StmtContext<?, ?, ?> stmtContext, Class<DT> declaredType) {
+        Collection<? extends StmtContext<?, ?, ?>> declaredSubstatements = stmtContext
+                .declaredSubstatements();
+        for (StmtContext<?, ?, ?> subStmtContext : declaredSubstatements) {
+            if (producesDeclared(subStmtContext,declaredType)) {
+                return subStmtContext;
+            }
+        }
+        return null;
+    }
+
+    public static final StmtContext<?, ?, ?> findFirstDeclaredSubstatement(
+            StmtContext<?, ?, ?> stmtContext, int startIndex, Class<? extends DeclaredStatement<?>>... types) {
+
+        if (startIndex >= types.length)
+            return null;
+
+        Collection<? extends StmtContext<?, ?, ?>> declaredSubstatements = stmtContext
+                .declaredSubstatements();
+        for (StmtContext<?, ?, ?> subStmtContext : declaredSubstatements) {
+            if (producesDeclared(subStmtContext,types[startIndex])) {
+                if (startIndex + 1 == types.length)
+                    return subStmtContext;
+                else
+                    return findFirstDeclaredSubstatement(subStmtContext,
+                            ++startIndex, types);
+            }
+        }
+        return null;
+    }
+
+    public static final <DT extends DeclaredStatement<?>> StmtContext<?, ?, ?> findFirstDeclaredSubstatementOnSublevel(
+            StmtContext<?, ?, ?> stmtContext, Class<DT> declaredType,
+            int sublevel) {
+        Collection<? extends StmtContext<?, ?, ?>> declaredSubstatements = stmtContext
+                .declaredSubstatements();
+        for (StmtContext<?, ?, ?> subStmtContext : declaredSubstatements) {
+            if (sublevel == 1 && producesDeclared(subStmtContext,declaredType)) {
+                return subStmtContext;
+            } else {
+                if (sublevel > 1) {
+                    StmtContext<?, ?, ?> result = findFirstDeclaredSubstatementOnSublevel(
+                            subStmtContext, declaredType, --sublevel);
+                    if (result != null)
+                        return result;
+                }
+            }
+        }
+        return null;
+    }
+
+    public static final <DT extends DeclaredStatement<?>> StmtContext<?, ?, ?> findDeepFirstDeclaredSubstatement(
+            StmtContext<?, ?, ?> stmtContext, Class<DT> declaredType) {
+
+        Collection<? extends StmtContext<?, ?, ?>> declaredSubstatements = stmtContext
+                .declaredSubstatements();
+
+        for (StmtContext<?, ?, ?> subStmtContext : declaredSubstatements) {
+            if (producesDeclared(subStmtContext,declaredType)) {
+                return subStmtContext;
+            } else {
+                StmtContext<?, ?, ?> result = findDeepFirstDeclaredSubstatement(
+                        subStmtContext, declaredType);
+                if (result != null)
+                    return result;
+
+            }
+        }
+        return null;
+    }
+
+    public static final boolean producesDeclared(StmtContext<?, ?, ?> ctx,
+            Class<? extends DeclaredStatement<?>> type) {
+        return type.isAssignableFrom(ctx.getPublicDefinition()
+                .getDeclaredRepresentationClass());
     }
 }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/BelongsToPrefixToModuleName.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/BelongsToPrefixToModuleName.java
new file mode 100644 (file)
index 0000000..7b012ff
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.spi.source;
+
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+
+/**
+ *
+ * Source-specific mapping of prefixes to namespaces
+ *
+ */
+public interface BelongsToPrefixToModuleName extends IdentifierNamespace<String, String> {
+
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ImpPrefixToModuleIdentifier.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ImpPrefixToModuleIdentifier.java
new file mode 100644 (file)
index 0000000..a60e7df
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.spi.source;
+
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+
+/**
+ *
+ * Source-specific mapping of prefixes to namespaces
+ *
+ */
+public interface ImpPrefixToModuleIdentifier extends IdentifierNamespace<String, ModuleIdentifier> {
+
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleIdentifierToModuleQName.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleIdentifierToModuleQName.java
new file mode 100644 (file)
index 0000000..efd62be
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.spi.source;
+
+import org.opendaylight.yangtools.yang.common.QNameModule;
+
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+
+/**
+ *
+ * Source-specific mapping of prefixes to namespaces
+ *
+ */
+public interface ModuleIdentifierToModuleQName extends IdentifierNamespace<ModuleIdentifier, QNameModule> {
+
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleNameToModuleQName.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleNameToModuleQName.java
new file mode 100644 (file)
index 0000000..0f32b25
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.spi.source;
+
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+
+/**
+ *
+ * Source-specific mapping of prefixes to namespaces
+ *
+ */
+public interface ModuleNameToModuleQName extends IdentifierNamespace<String, QNameModule> {
+
+
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleQNameToModuleName.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/ModuleQNameToModuleName.java
new file mode 100644 (file)
index 0000000..cd45463
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.spi.source;
+
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+
+/**
+ *
+ * Source-specific mapping of prefixes to namespaces
+ *
+ */
+public interface ModuleQNameToModuleName extends IdentifierNamespace<QNameModule,String> {
+
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/QNameToStatementDefinitionMap.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/QNameToStatementDefinitionMap.java
new file mode 100644 (file)
index 0000000..f0767c7
--- /dev/null
@@ -0,0 +1,23 @@
+package org.opendaylight.yangtools.yang.parser.spi.source;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.HashMap;
+import java.util.Map;
+
+public class QNameToStatementDefinitionMap implements QNameToStatementDefinition{
+
+    private Map<QName, StatementDefinition> qNameToStmtDefMap = new HashMap<>();
+
+    public void put(QName qName, StatementDefinition stDef ) {
+        qNameToStmtDefMap.put(qName, stDef);
+    }
+
+    @Nullable @Override
+    public StatementDefinition get(@Nonnull QName identifier) {
+        return qNameToStmtDefMap.get(identifier);
+    }
+}
index 7bfee3471b203a750190448748300b2269dcc31b..cb0dd2c3437cf505d86b9ad120de14603bd7be09 100644 (file)
@@ -7,6 +7,9 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.reactor;
 
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
+
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import com.google.common.base.Preconditions;
 import com.google.common.base.Throwables;
 import com.google.common.collect.ImmutableList;
@@ -60,6 +63,10 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
         this.supports = supports;
     }
 
+    public StatementSupportBundle getSupportsForPhase(ModelProcessingPhase currentPhase) {
+        return supports.get(currentPhase);
+    }
+
     public void addSource(@Nonnull StatementStreamSource source) {
         sources.add(new SourceSpecificContext(this,source));
     }
@@ -135,6 +142,32 @@ class BuildGlobalContext extends NamespaceStorageSupport implements NamespaceBeh
         return new EffectiveModelContext(rootStatements);
     }
 
+    public EffectiveSchemaContext buildEffective() throws SourceException, ReactorException {
+        for(ModelProcessingPhase phase : PHASE_EXECUTION_ORDER) {
+            startPhase(phase);
+            loadPhaseStatements();
+            completePhaseActions();
+            endPhase(phase);
+        }
+        return transformEffective();
+    }
+
+    private EffectiveSchemaContext transformEffective() {
+        Preconditions.checkState(finishedPhase == ModelProcessingPhase.EFFECTIVE_MODEL);
+        List<DeclaredStatement<?>> rootStatements = new ArrayList<>();
+        List<EffectiveStatement<?,?>> rootEffectiveStatements = new ArrayList<>();
+
+        for(SourceSpecificContext source : sources) {
+            DeclaredStatement<?> root = source.getRoot().buildDeclared();
+            rootStatements.add(root);
+
+            EffectiveStatement<?,?> rootEffective = source.getRoot().buildEffective();
+            rootEffectiveStatements.add(rootEffective);
+        }
+
+        return new EffectiveSchemaContext(rootStatements,rootEffectiveStatements);
+    }
+
     private void startPhase(ModelProcessingPhase phase) {
         Preconditions.checkState(Objects.equals(finishedPhase, phase.getPreviousPhase()));
         for(SourceSpecificContext source : sources) {
index 819dfff3be7d15b44ec43d79106b6b0bab848ee2..06ae43adce10e9ef5cb88bf33dcecdcd16a1889d 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.reactor;
 
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
+
 import com.google.common.collect.ImmutableMap;
 import java.util.EnumMap;
 import java.util.Map;
@@ -64,7 +66,9 @@ public class CrossSourceStatementReactor {
             return context.build();
         }
 
-
+        public EffectiveSchemaContext buildEffective() throws SourceException, ReactorException {
+            return context.buildEffective();
+        }
 
     }
 
index 0b1e823a0c8fe98231fb6a9bdc670366664ca01d..a2a487402bdd40c037dfed1d8ecdee72d1755cb6 100644 (file)
@@ -23,5 +23,4 @@ public class EffectiveModelContext implements Immutable {
     public ImmutableList<DeclaredStatement<?>> getRootStatements() {
         return rootStatements;
     }
-
 }
index c8d205409a5ed808abf6894bb7e8e7313363464a..8c22b734a983eed12e4cf405d797307e08d395a1 100644 (file)
@@ -172,37 +172,37 @@ class ModifierImpl implements ModelActionBuilder {
 
     @Override
     public <D extends DeclaredStatement<?>> Prerequisite<D> requiresDeclared(StmtContext<?, ? extends D, ?> context) {
-        return requiresCtxImpl(context,FULL_DECLARATION).transform(StmtContextUtils.<D>buildDeclared());
+        return requiresCtxImpl(context, FULL_DECLARATION).transform(StmtContextUtils.<D>buildDeclared());
     }
 
     @Override
     public <K, D extends DeclaredStatement<?>, N extends StatementNamespace<K, ? extends D, ?>> AbstractPrerequisite<StmtContext<?, D, ?>> requiresDeclaredCtx(
             StmtContext<?, ?, ?> context, Class<N> namespace, K key) {
-        return requiresCtxImpl(context, namespace, key,FULL_DECLARATION);
+        return requiresCtxImpl(context, namespace, key, FULL_DECLARATION);
     }
 
     @Override
     public <K, D extends DeclaredStatement<?>, N extends StatementNamespace<K, ? extends D, ?>> Prerequisite<D> requiresDeclared(
             StmtContext<?, ?, ?> context, Class<N> namespace, K key) {
-        final AbstractPrerequisite<StmtContext<?,D,?>> rawContext = requiresCtxImpl(context, namespace, key,FULL_DECLARATION);
+        final AbstractPrerequisite<StmtContext<?,D,?>> rawContext = requiresCtxImpl(context, namespace, key, FULL_DECLARATION);
         return rawContext.transform(StmtContextUtils.<D>buildDeclared());
     }
 
     @Override
     public <E extends EffectiveStatement<?, ?>> Prerequisite<E> requiresEffective(StmtContext<?, ?, ? extends E> stmt) {
-        return requiresCtxImpl(stmt,EFFECTIVE_MODEL).transform(StmtContextUtils.<E>buildEffective());
+        return requiresCtxImpl(stmt, EFFECTIVE_MODEL).transform(StmtContextUtils.<E>buildEffective());
     }
 
     @Override
     public <K, E extends EffectiveStatement<?, ?>, N extends StatementNamespace<K, ?, ? extends E>> AbstractPrerequisite<StmtContext<?, ?, E>> requiresEffectiveCtx(
             StmtContext<?, ?, ?> context, Class<N> namespace, K key) {
-        return requiresCtxImpl(contextImpl(context),namespace,key,EFFECTIVE_MODEL);
+        return requiresCtxImpl(contextImpl(context),namespace,key, EFFECTIVE_MODEL);
     }
 
     @Override
     public <K, E extends EffectiveStatement<?, ?>, N extends StatementNamespace<K, ?, ? extends E>> Prerequisite<E> requiresEffective(
             StmtContext<?, ?, ?> context, Class<N> namespace, K key) {
-        final AbstractPrerequisite<StmtContext<?,?,E>> rawContext = requiresCtxImpl(context, namespace, key,EFFECTIVE_MODEL);
+        final AbstractPrerequisite<StmtContext<?,?,E>> rawContext = requiresCtxImpl(context, namespace, key, EFFECTIVE_MODEL);
         return rawContext.transform(StmtContextUtils.<E>buildEffective());
     }
 
index f79a062ea11ed7d3dd61cafb98be0b07a9a2c2bc..8e6409f5835bf750da430bed013aa6d09264096e 100644 (file)
@@ -34,11 +34,17 @@ abstract class NamespaceStorageSupport implements NamespaceStorageNode {
         // NOOP
     }
 
-    public final <K, VT, V extends VT ,N extends IdentifierNamespace<K, V>> VT getFromNamespace(Class<N> type, K key)
+    //<K,V,N extends IdentifierNamespace<K, V>> V
+    //public final <K, VT, V extends VT ,N extends IdentifierNamespace<K, V>> VT getFromNamespace(Class<N> type, K key)
+    public final <K,V,N extends IdentifierNamespace<K, V>> V getFromNamespace(Class<N> type, K key)
             throws NamespaceNotAvailableException {
         return getBehaviourRegistry().getNamespaceBehaviour(type).getFrom(this,key);
     }
 
+    public final <K, V, N extends IdentifierNamespace<K, V>> Map<?, ?> getAllFromNamespace(Class<N> type){
+        return namespaces.get(type);
+    }
+
     public final <K,V,VT extends V,N extends IdentifierNamespace<K, V>> void addToNs(Class<N> type, K key, VT value)
             throws NamespaceNotAvailableException {
         getBehaviourRegistry().getNamespaceBehaviour(type).addTo(this,key,value);
index 295d2cc8ca3ea6c5df4d1738920e52404a9476f2..18509213a7cf2168fb827ae0dbfbb0c6fe884d82 100644 (file)
@@ -7,26 +7,64 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.reactor;
 
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import java.util.Collection;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.Registry;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
-
 class RootStatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
-    extends StatementContextBase<A, D,E> {
-
+        extends StatementContextBase<A, D, E> {
 
     private final SourceSpecificContext sourceContext;
+    private final A argument;
 
-    RootStatementContext(ContextBuilder<A, D,E> builder, SourceSpecificContext sourceContext) throws SourceException {
+    RootStatementContext(ContextBuilder<A, D, E> builder,
+            SourceSpecificContext sourceContext) throws SourceException {
         super(builder);
         this.sourceContext = sourceContext;
+        this.argument = builder.getDefinition().parseArgumentValue(this,
+                builder.getRawArgument());
+    }
+
+    RootStatementContext(RootStatementContext<A, D, E> original,
+            QNameModule newQNameModule) throws SourceException {
+        super(original);
+
+        sourceContext = original.sourceContext;
+        this.argument = original.argument;
+
+        copyDeclaredStmts(original, newQNameModule);
+
+        copyEffectiveStmts(original, newQNameModule);
+
+    }
+
+    private void copyDeclaredStmts(RootStatementContext<A, D, E> original,
+            QNameModule newQNameModule) throws SourceException {
+        Collection<? extends StmtContext<?, ?, ?>> originalDeclaredSubstatements = original
+                .declaredSubstatements();
+        for (StmtContext<?, ?, ?> stmtContext : originalDeclaredSubstatements) {
+            this.addEffectiveSubstatement(stmtContext
+                    .createCopy(newQNameModule,this));
+        }
+    }
+
+    private void copyEffectiveStmts(RootStatementContext<A, D, E> original,
+            QNameModule newQNameModule) throws SourceException {
+        Collection<? extends StmtContext<?, ?, ?>> originalEffectiveSubstatements = original
+                .effectiveSubstatements();
+        for (StmtContext<?, ?, ?> stmtContext : originalEffectiveSubstatements) {
+            this.addEffectiveSubstatement(stmtContext
+                    .createCopy(newQNameModule,this));
+        }
     }
 
     @Override
-    public StatementContextBase<?,?, ?> getParentContext() {
+    public StatementContextBase<?, ?, ?> getParentContext() {
         return null;
     }
 
@@ -41,7 +79,7 @@ class RootStatementContext<A, D extends DeclaredStatement<A>, E extends Effectiv
     }
 
     @Override
-    public RootStatementContext<?,?,?> getRoot() {
+    public RootStatementContext<?, ?, ?> getRoot() {
         return this;
     }
 
@@ -49,6 +87,18 @@ class RootStatementContext<A, D extends DeclaredStatement<A>, E extends Effectiv
         return sourceContext;
     }
 
+    @Override
+    public A getStatementArgument() {
+        return argument;
+    }
+
+    @Override
+    public StatementContextBase<A, D, E> createCopy(QNameModule newQNameModule, StatementContextBase<?, ?, ?> newParent)
+            throws SourceException {
 
+        StatementContextBase<A, D, E> copy = new RootStatementContext<A, D, E>(
+                this, newQNameModule);
+        return copy;
+    }
 
 }
index b2d56f8f77e145b7c0834e7507258e0d0d74f5a2..d6ddc551c228760036f7d965113169993ce672f6 100644 (file)
@@ -7,18 +7,21 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.reactor;
 
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+
 import com.google.common.base.Preconditions;
 import com.google.common.collect.HashMultimap;
+import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Multimap;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Iterator;
+import java.util.Map;
 import java.util.Objects;
 import javax.annotation.Nullable;
 import org.opendaylight.yangtools.concepts.Mutable;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
-import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ImportedNamespaceContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
@@ -27,8 +30,10 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.NamespaceStorageNode;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
 import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinitionMap;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
@@ -51,6 +56,7 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh
 
     private ModelProcessingPhase inProgressPhase;
     private ModelProcessingPhase finishedPhase;
+    private QNameToStatementDefinitionMap qNameToStmtDefMap = new QNameToStatementDefinitionMap();
 
 
     SourceSpecificContext(BuildGlobalContext currentContext,StatementStreamSource source) {
@@ -68,7 +74,7 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh
         if(current == null) {
             return createDeclaredRoot(def,ref);
         }
-        return current.substatementBuilder(def,ref);
+        return current.substatementBuilder(def, ref);
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
@@ -80,7 +86,7 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh
                 if(root == null) {
                     root = new RootStatementContext(this, SourceSpecificContext.this);
                 } else {
-                    Preconditions.checkState(root.getIdentifier().equals(getIdentifier()), "Root statement was already defined.");
+                    Preconditions.checkState(root.getIdentifier().equals(getIdentifier()), "Root statement was already defined as %s.", root.getIdentifier());
                 }
                 root.resetLists();
                 return root;
@@ -97,7 +103,7 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh
         return root.buildDeclared();
     }
 
-    EffectiveStatement<?,?> build() {
+    EffectiveStatement<?,?> buildEffective() {
         return root.buildEffective();
     }
 
@@ -148,6 +154,27 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh
 
     PhaseCompletionProgress tryToCompletePhase(ModelProcessingPhase phase) throws SourceException {
         Collection<ModifierImpl> currentPhaseModifiers = modifiers.get(phase);
+
+        boolean hasProgressed = hasProgress(currentPhaseModifiers);
+
+        boolean phaseCompleted = root.tryToCompletePhase(phase);
+
+        hasProgressed = hasProgress(currentPhaseModifiers);
+
+        if(phaseCompleted && (currentPhaseModifiers.isEmpty())) {
+            finishedPhase = phase;
+            return PhaseCompletionProgress.FINISHED;
+
+        }
+        if(hasProgressed) {
+            return PhaseCompletionProgress.PROGRESS;
+        }
+        return PhaseCompletionProgress.NO_PROGRESS;
+    }
+
+
+    private boolean hasProgress(Collection<ModifierImpl> currentPhaseModifiers) {
+
         Iterator<ModifierImpl> modifier = currentPhaseModifiers.iterator();
         boolean hasProgressed = false;
         while(modifier.hasNext()) {
@@ -156,15 +183,9 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh
                 hasProgressed = true;
             }
         }
-        if(root.tryToCompletePhase(phase) && currentPhaseModifiers.isEmpty()) {
-            finishedPhase = phase;
-            return PhaseCompletionProgress.FINISHED;
 
-        }
-        if(hasProgressed) {
-            return PhaseCompletionProgress.PROGRESS;
-        }
-        return PhaseCompletionProgress.NO_PROGRESS;
+        return hasProgressed;
+
     }
 
     ModelActionBuilder newInferenceAction(ModelProcessingPhase phase) {
@@ -200,9 +221,10 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh
             break;
         case STATEMENT_DEFINITION:
             source.writeLinkageAndStatementDefinitions(new StatementContextWriter(this, inProgressPhase), stmtDef(), prefixes());
+            break;
         case FULL_DECLARATION:
             source.writeFull(new StatementContextWriter(this, inProgressPhase), stmtDef(), prefixes());
-
+            break;
         default:
             break;
         }
@@ -214,8 +236,11 @@ public class SourceSpecificContext implements NamespaceStorageNode, NamespaceBeh
     }
 
     private QNameToStatementDefinition stmtDef() {
-        // TODO Auto-generated method stub
-        return null;
+        ImmutableMap<QName, StatementSupport<?, ?, ?>> definitions = currentContext.getSupportsForPhase(
+                inProgressPhase).getDefinitions();
+        for (Map.Entry<QName, StatementSupport<?,?,?>> entry : definitions.entrySet()) {
+            qNameToStmtDefMap.put(entry.getKey(), entry.getValue());
+        }
+        return qNameToStmtDefMap;
     }
-
 }
index 0068ee47cbb133d2cd9a46429245847e10524859..0f55001b5f2bdec373f003f9e39bcc659809b4cf 100644 (file)
@@ -34,7 +34,7 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.NamespaceBehaviourWithListeners.ValueAddedListener;
 
-abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> extends
+public abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>> extends
         NamespaceStorageSupport implements StmtContext.Mutable<A, D, E>, Identifiable<StatementIdentifier> {
 
     interface OnNamespaceItemAdded extends EventListener{
@@ -100,7 +100,6 @@ abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E extends
     private final StatementDefinitionContext<A, D, E> definition;
     private final StatementIdentifier identifier;
     private final StatementSourceReference statementDeclSource;
-    private final A argument;
 
     private LinkedHashMap<StatementIdentifier, StatementContextBase<?, ?, ?> > substatements = new LinkedHashMap<>();
 
@@ -120,7 +119,13 @@ abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E extends
         this.definition = builder.getDefinition();
         this.identifier = builder.getIdentifier();
         this.statementDeclSource = builder.getStamementSource();
-        this.argument = definition.parseArgumentValue(this, this.rawStatementArgument());
+        this.completedPhase = null;
+    }
+
+    StatementContextBase(StatementContextBase<A,D,E> original) {
+        this.definition = original.definition;
+        this.identifier = original.identifier;
+        this.statementDeclSource = original.statementDeclSource;
         this.completedPhase = null;
     }
 
@@ -152,13 +157,21 @@ abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E extends
     }
 
     @Override
-    public A getStatementArgument() {
-        return argument;
+    public Collection<StatementContextBase<?, ?, ?>> declaredSubstatements() {
+        return Collections.unmodifiableCollection(declared);
     }
 
     @Override
-    public Collection<? extends StmtContext<?, ?, ?>> declaredSubstatements() {
-        return Collections.unmodifiableCollection(declared);
+    public Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements() {
+        return Collections.unmodifiableCollection(effective);
+    }
+
+    public void addEffectiveSubstatement(StatementContextBase<?, ?, ?> substatement){
+        effective.add(substatement);
+    }
+
+    public void addDeclaredSubstatement(StatementContextBase<?, ?, ?> substatement){
+        declared.add(substatement);
     }
 
     @SuppressWarnings({ "rawtypes", "unchecked" })
@@ -187,6 +200,8 @@ abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E extends
         };
     }
 
+
+
     @Override
     public StorageNodeType getStorageNodeType() {
         return StorageNodeType.STATEMENT_LOCAL;
@@ -232,6 +247,9 @@ abstract class StatementContextBase<A, D extends DeclaredStatement<A>, E extends
         for(StatementContextBase<?, ?, ?> child: declared) {
             finished &= child.tryToCompletePhase(phase);
         }
+        for(StatementContextBase<?, ?, ?> child: effective) {
+            finished &= child.tryToCompletePhase(phase);
+        }
         if(finished) {
             onPhaseCompleted(phase);
             return true;
index fba236cd5e7bcfe1c3c38617d774d3879e3cd992..2e78e75ed28b8b5188df2364c3e8c392ec918496 100644 (file)
@@ -20,7 +20,7 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
-class StatementDefinitionContext<A,D extends DeclaredStatement<A>,E extends EffectiveStatement<A,D>> {
+public class StatementDefinitionContext<A,D extends DeclaredStatement<A>,E extends EffectiveStatement<A,D>> {
     private final StatementSupport<A,D,E> support;
     public StatementDefinitionContext(StatementSupport<A,D,E> support) {
         this.support= support;
@@ -56,8 +56,10 @@ class StatementDefinitionContext<A,D extends DeclaredStatement<A>,E extends Effe
             break;
         case STATEMENT_DEFINITION:
             support.onStatementDefinitionDeclared(statement);
+            break;
         case FULL_DECLARATION:
             support.onFullDefinitionDeclared(statement);
+            break;
         default:
             break;
         }
index aafdfca824a378e1b94af00106b6ef354e5b001a..d0c35df46e38dea87e18d0f14a2d3b79d67df411 100644 (file)
@@ -7,6 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.reactor;
 
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.GroupingUtils;
+
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.common.QName;
 import com.google.common.base.Preconditions;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
@@ -18,10 +23,59 @@ class SubstatementContext<A,D extends DeclaredStatement<A>, E extends EffectiveS
     extends StatementContextBase<A,D,E> {
 
     private final StatementContextBase<?,?,?> parent;
+    private final A argument;
 
     SubstatementContext(StatementContextBase<?,?,?> parent,ContextBuilder<A,D,E> builder) throws SourceException {
+        //super(builder,  builder.getDefinition().parseArgumentValue(parent, builder.getRawArgument()));
         super(builder);
         this.parent = Preconditions.checkNotNull(parent, "Parent must not be null");
+        this.argument =   builder.getDefinition().parseArgumentValue(this, builder.getRawArgument());
+    }
+
+    SubstatementContext(SubstatementContext<A,D,E> original, QNameModule newQNameModule, StatementContextBase<?, ?, ?> newParent) throws SourceException {
+        super(original);
+        this.parent = newParent;
+
+        if(newQNameModule != null && original.argument instanceof QName) {
+            QName originalQName = (QName) original.argument;
+            this.argument =  (A) QName.create(newQNameModule,originalQName.getLocalName());
+        } else {
+            this.argument = original.argument;
+        }
+
+        copyDeclaredStmts(original, newQNameModule);
+
+        copyEffectiveStmts(original, newQNameModule);
+    }
+
+    private void copyDeclaredStmts(SubstatementContext<A, D, E> original,
+            QNameModule newQNameModule) throws SourceException {
+        Collection<? extends StatementContextBase<?, ?, ?>> originalDeclaredSubstatements = original
+                .declaredSubstatements();
+        for (StatementContextBase<?, ?, ?> stmtContext : originalDeclaredSubstatements) {
+            if (GroupingUtils.needToCopyByUses(stmtContext)) {
+                StatementContextBase<?, ?, ?> copy = stmtContext
+                        .createCopy(newQNameModule,this);
+                this.addEffectiveSubstatement(copy);
+            } else if (GroupingUtils.isReusedByUses(stmtContext)) {
+                this.addEffectiveSubstatement(stmtContext);
+            }
+        }
+    }
+
+    private void copyEffectiveStmts(SubstatementContext<A, D, E> original,
+            QNameModule newQNameModule) throws SourceException {
+        Collection<? extends StatementContextBase<?, ?, ?>> originalEffectiveSubstatements = original
+                .effectiveSubstatements();
+        for (StatementContextBase<?, ?, ?> stmtContext : originalEffectiveSubstatements) {
+            if (GroupingUtils.needToCopyByUses(stmtContext)) {
+                StatementContextBase<?, ?, ?> copy = stmtContext
+                        .createCopy(newQNameModule,this);
+                this.addEffectiveSubstatement(copy);
+            } else if (GroupingUtils.isReusedByUses(stmtContext)) {
+                this.addEffectiveSubstatement(stmtContext);
+            }
+        }
     }
 
     @Override
@@ -44,4 +98,15 @@ class SubstatementContext<A,D extends DeclaredStatement<A>, E extends EffectiveS
         return parent.getRoot();
     }
 
+
+    @Override
+    public A getStatementArgument() {
+        return argument;
+    }
+
+    @Override
+    public StatementContextBase<A, D, E>  createCopy(QNameModule newQNameModule, StatementContextBase<?, ?, ?> newParent) throws SourceException {
+        StatementContextBase<A,D,E> copy = new SubstatementContext<A,D,E>(this,newQNameModule, newParent);
+        return copy;
+    }
 }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AnyxmlStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AnyxmlStatementImpl.java
new file mode 100644 (file)
index 0000000..e069c3f
--- /dev/null
@@ -0,0 +1,102 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
+
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.AnyxmlStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class AnyxmlStatementImpl extends AbstractDeclaredStatement<QName> implements AnyxmlStatement {
+
+    protected AnyxmlStatementImpl(StmtContext<QName, AnyxmlStatement,?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<QName,AnyxmlStatement,EffectiveStatement<QName,AnyxmlStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.ANYXML);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?,?,?> ctx, String value) {
+            return Utils.qNameFromArgument(ctx,value);
+        }
+
+        @Override
+        public AnyxmlStatement createDeclared(StmtContext<QName, AnyxmlStatement,?> ctx) {
+            return new AnyxmlStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName,AnyxmlStatement> createEffective(StmtContext<QName,AnyxmlStatement,EffectiveStatement<QName,AnyxmlStatement>> ctx) {
+           throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+    @Override
+    public WhenStatement getWhenStatement() {
+        return firstDeclared(WhenStatement.class);
+    }
+
+    @Override
+    public Collection<? extends IfFeatureStatement> getIfFeatures() {
+        return allDeclared(IfFeatureStatement.class);
+    }
+
+    @Override
+    public Collection<? extends MustStatement> getMusts() {
+        return allDeclared(MustStatement.class);
+    }
+
+    @Override
+    public ConfigStatement getConfig() {
+        return firstDeclared(ConfigStatement.class);
+    }
+
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public MandatoryStatement getMandatory() {
+        return firstDeclared(MandatoryStatement.class);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ArgumentStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ArgumentStatementImpl.java
new file mode 100644 (file)
index 0000000..3d1c0fa
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ArgumentStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ArgumentStatementImpl extends AbstractDeclaredStatement<QName>
+        implements ArgumentStatement {
+
+    protected ArgumentStatementImpl(
+            StmtContext<QName, ArgumentStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, ArgumentStatement, EffectiveStatement<QName, ArgumentStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.ARGUMENT);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public ArgumentStatement createDeclared(
+                StmtContext<QName, ArgumentStatement, ?> ctx) {
+            return new ArgumentStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, ArgumentStatement> createEffective(
+                StmtContext<QName, ArgumentStatement, EffectiveStatement<QName, ArgumentStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+    @Override
+    public YinElementStatement getYinElement() {
+        return firstDeclared(YinElementStatement.class);
+    }
+
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AugmentStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/AugmentStatementImpl.java
new file mode 100644 (file)
index 0000000..926a39b
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import java.util.Collection;
+
+import javax.annotation.Nonnull;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+public class AugmentStatementImpl extends AbstractDeclaredStatement<SchemaNodeIdentifier> implements AugmentStatement {
+
+    protected AugmentStatementImpl(StmtContext<SchemaNodeIdentifier, AugmentStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.AUGMENT);
+        }
+
+        @Override
+        public SchemaNodeIdentifier parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return SchemaNodeIdentifier.create(Utils.parseAugmentPath(ctx, value), Utils.isXPathAbsolute(value));
+        }
+
+        @Override
+        public AugmentStatement createDeclared(StmtContext<SchemaNodeIdentifier, AugmentStatement, ?> ctx) {
+            return new AugmentStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<SchemaNodeIdentifier, AugmentStatement> createEffective(
+                StmtContext<SchemaNodeIdentifier, AugmentStatement, EffectiveStatement<SchemaNodeIdentifier, AugmentStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull
+    @Override
+    public SchemaNodeIdentifier getTargetNode() {
+        return argument();
+    }
+
+    @Override
+    public Collection<? extends DataDefinitionStatement> getDataDefinitions() {
+        return allDeclared(DataDefinitionStatement.class);
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BaseStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BaseStatementImpl.java
new file mode 100644 (file)
index 0000000..b2bd11d
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.BaseStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class BaseStatementImpl extends AbstractDeclaredStatement<QName>
+        implements BaseStatement {
+
+    protected BaseStatementImpl(StmtContext<QName, BaseStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, BaseStatement, EffectiveStatement<QName, BaseStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.BASE);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public BaseStatement createDeclared(
+                StmtContext<QName, BaseStatement, ?> ctx) {
+            return new BaseStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, BaseStatement> createEffective(
+                StmtContext<QName, BaseStatement, EffectiveStatement<QName, BaseStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BelongsToStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BelongsToStatementImpl.java
new file mode 100644 (file)
index 0000000..276da96
--- /dev/null
@@ -0,0 +1,63 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class BelongsToStatementImpl extends AbstractDeclaredStatement<String>
+        implements BelongsToStatement {
+
+    protected BelongsToStatementImpl(
+            StmtContext<String, BelongsToStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, BelongsToStatement, EffectiveStatement<String, BelongsToStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.BELONGS_TO);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public BelongsToStatement createDeclared(
+                StmtContext<String, BelongsToStatement, ?> ctx) {
+            return new BelongsToStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, BelongsToStatement> createEffective(
+                StmtContext<String, BelongsToStatement, EffectiveStatement<String, BelongsToStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getModule() {
+        return argument();
+    }
+
+    @Override
+    public PrefixStatement getPrefix() {
+        return firstDeclared(PrefixStatement.class);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BitStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BitStatementImpl.java
new file mode 100644 (file)
index 0000000..6080528
--- /dev/null
@@ -0,0 +1,81 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PositionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.BitStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class BitStatementImpl extends AbstractDeclaredStatement<String>
+        implements BitStatement {
+
+    protected BitStatementImpl(
+            StmtContext<String, BitStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, BitStatement, EffectiveStatement<String, BitStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.BIT);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public BitStatement createDeclared(
+                StmtContext<String, BitStatement, ?> ctx) {
+            return new BitStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, BitStatement> createEffective(
+                StmtContext<String, BitStatement, EffectiveStatement<String, BitStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+    @Override
+    public PositionStatement getPosition() {
+        return firstDeclared(PositionStatement.class);
+    }
+
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BitsSpecificationImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BitsSpecificationImpl.java
new file mode 100644 (file)
index 0000000..53215e7
--- /dev/null
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.stmt.BitStatement;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+
+public class BitsSpecificationImpl extends AbstractDeclaredStatement<String>
+        implements TypeStatement.BitsSpecification {
+
+    protected BitsSpecificationImpl(
+            StmtContext<String, TypeStatement.BitsSpecification, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, TypeStatement.BitsSpecification, EffectiveStatement<String, TypeStatement.BitsSpecification>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.TYPE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return value;
+        }
+
+        @Override
+        public TypeStatement.BitsSpecification createDeclared(
+                StmtContext<String, TypeStatement.BitsSpecification, ?> ctx) {
+            return new BitsSpecificationImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, TypeStatement.BitsSpecification> createEffective(
+                StmtContext<String, TypeStatement.BitsSpecification, EffectiveStatement<String, TypeStatement.BitsSpecification>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+    @Override
+    public Collection<? extends BitStatement> getBits() {
+        return allDeclared(BitStatement.class);
+    }
+
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/CaseStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/CaseStatementImpl.java
new file mode 100644 (file)
index 0000000..a6e29b2
--- /dev/null
@@ -0,0 +1,92 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.CaseStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Collection;
+
+public class CaseStatementImpl extends AbstractDeclaredStatement<QName> implements CaseStatement {
+
+    protected CaseStatementImpl(
+            StmtContext<QName, CaseStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<QName,CaseStatement,EffectiveStatement<QName,CaseStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.CASE);
+        }
+
+        @Override public QName parseArgumentValue(StmtContext<?, ?, ?> ctx,
+                String value) throws SourceException {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override public CaseStatement createDeclared(
+                StmtContext<QName, CaseStatement, ?> ctx) {
+            return new CaseStatementImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<QName, CaseStatement> createEffective(
+                StmtContext<QName, CaseStatement, EffectiveStatement<QName, CaseStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull @Override
+    public QName getName() {
+        return argument();
+    }
+
+    @Override
+    public WhenStatement getWhenStatement() {
+        return firstDeclared(WhenStatement.class);
+    }
+
+    @Nonnull @Override
+    public Collection<? extends IfFeatureStatement> getIfFeatures() {
+        return allDeclared(IfFeatureStatement.class);
+    }
+
+    @Override
+    public Collection<? extends DataDefinitionStatement> getDataDefinitions() {
+        return allDeclared(DataDefinitionStatement.class);
+    }
+
+    @Nullable @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Nullable @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ChoiceStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ChoiceStatementImpl.java
new file mode 100644 (file)
index 0000000..3feee1f
--- /dev/null
@@ -0,0 +1,124 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.CaseStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DefaultStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Collection;
+
+public class ChoiceStatementImpl extends AbstractDeclaredStatement<QName>
+        implements ChoiceStatement {
+
+    protected ChoiceStatementImpl(StmtContext<QName, ChoiceStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, ChoiceStatement, EffectiveStatement<QName, ChoiceStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.CHOICE);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public ChoiceStatement createDeclared(
+                StmtContext<QName, ChoiceStatement, ?> ctx) {
+            return new ChoiceStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, ChoiceStatement> createEffective(
+                StmtContext<QName, ChoiceStatement, EffectiveStatement<QName, ChoiceStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+    @Nullable
+    @Override
+    public DefaultStatement getDefault() {
+        return firstDeclared(DefaultStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public ConfigStatement getConfig() {
+        return firstDeclared(ConfigStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public MandatoryStatement getMandatory() {
+        return firstDeclared(MandatoryStatement.class);
+    }
+
+    @Nonnull
+    @Override
+    public Collection<? extends CaseStatement> getCases() {
+        return allDeclared(CaseStatement.class);
+    }
+
+    @Override
+    public WhenStatement getWhenStatement() {
+        return firstDeclared(WhenStatement.class);
+    }
+
+    @Nonnull
+    @Override
+    public Collection<? extends IfFeatureStatement> getIfFeatures() {
+        return allDeclared(IfFeatureStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ConfigStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ConfigStatementImpl.java
new file mode 100644 (file)
index 0000000..b25f975
--- /dev/null
@@ -0,0 +1,51 @@
+/**
+* Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+*
+* This program and the accompanying materials are made available under the
+* terms of the Eclipse Public License v1.0 which accompanies this distribution,
+* and is available at http://www.eclipse.org/legal/epl-v10.html
+*/
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+
+public class ConfigStatementImpl extends AbstractDeclaredStatement<Boolean> implements ConfigStatement {
+
+    protected ConfigStatementImpl(
+            StmtContext<Boolean, ConfigStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<Boolean,ConfigStatement,EffectiveStatement<Boolean,ConfigStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.CONFIG);
+        }
+
+        @Override public Boolean parseArgumentValue(StmtContext<?, ?, ?> ctx,
+                String value) throws SourceException {
+            return Boolean.valueOf(value);
+        }
+
+        @Override public ConfigStatement createDeclared(StmtContext<Boolean, ConfigStatement, ?> ctx) {
+            return new ConfigStatementImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<Boolean, ConfigStatement> createEffective(StmtContext<Boolean, ConfigStatement, EffectiveStatement<Boolean, ConfigStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull @Override
+    public Boolean getValue() {
+        return argument();
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ContactStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ContactStatementImpl.java
new file mode 100644 (file)
index 0000000..e3ef013
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ContactStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+
+public class ContactStatementImpl extends AbstractDeclaredStatement<String> implements ContactStatement{
+
+    protected ContactStatementImpl(StmtContext<String, ContactStatement,?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<String,ContactStatement,EffectiveStatement<String,ContactStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.CONTACT);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return value;
+        }
+
+        @Override
+        public ContactStatement createDeclared(StmtContext<String, ContactStatement, ?> ctx) {
+            return new ContactStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, ContactStatement> createEffective(StmtContext<String, ContactStatement, EffectiveStatement<String, ContactStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull @Override
+    public String getText() {
+        return rawArgument();
+    }
+}
index 360aee41e3ed5599563382708fad26836834c90f..69f839bb96db9464a592e0f9a5d933d1e7757ea4 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ContainerEffectiveStatementImpl;
+
 import java.util.Collection;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
@@ -28,9 +30,11 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 
 public class ContainerStatementImpl extends AbstractDeclaredStatement<QName> implements ContainerStatement {
+    //private QName qname;
 
     protected ContainerStatementImpl(StmtContext<QName, ContainerStatement,?> context) {
         super(context);
+        //this.qname =
     }
 
     public static class Definition extends AbstractStatementSupport<QName,ContainerStatement,EffectiveStatement<QName,ContainerStatement>> {
@@ -51,7 +55,7 @@ public class ContainerStatementImpl extends AbstractDeclaredStatement<QName> imp
 
         @Override
         public EffectiveStatement<QName,ContainerStatement> createEffective(StmtContext<QName,ContainerStatement,EffectiveStatement<QName,ContainerStatement>> ctx) {
-           throw new UnsupportedOperationException();
+           return new ContainerEffectiveStatementImpl(ctx);
         }
 
     }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Decimal64SpecificationImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/Decimal64SpecificationImpl.java
new file mode 100644 (file)
index 0000000..985b18d
--- /dev/null
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.FractionDigitsStatement;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RangeStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+
+public class Decimal64SpecificationImpl extends AbstractDeclaredStatement<String> implements TypeStatement.Decimal64Specification{
+
+    protected Decimal64SpecificationImpl(StmtContext<String, TypeStatement.Decimal64Specification, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<String,TypeStatement.Decimal64Specification,EffectiveStatement<String,TypeStatement.Decimal64Specification>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.FRACTION_DIGITS);
+        }
+
+        @Override public String parseArgumentValue(StmtContext<?, ?, ?> ctx,
+                String value) throws SourceException {
+            return value;
+        }
+
+        @Override public TypeStatement.Decimal64Specification createDeclared(
+                StmtContext<String, TypeStatement.Decimal64Specification, ?> ctx) {
+            return new Decimal64SpecificationImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<String, TypeStatement.Decimal64Specification> createEffective(
+                StmtContext<String, TypeStatement.Decimal64Specification, EffectiveStatement<String, TypeStatement.Decimal64Specification>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+    @Override
+    public FractionDigitsStatement getFractionDigits() {
+        return firstDeclared(FractionDigitsStatement.class);
+    }
+
+    @Override
+    public RangeStatement getRange() {
+        return firstDeclared(RangeStatement.class);
+    }
+
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DefaultStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DefaultStatementImpl.java
new file mode 100644 (file)
index 0000000..95aadef
--- /dev/null
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DefaultStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+
+public class DefaultStatementImpl extends AbstractDeclaredStatement<String> implements
+        DefaultStatement {
+
+    protected DefaultStatementImpl(
+            StmtContext<String, DefaultStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<String,DefaultStatement,EffectiveStatement<String,DefaultStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.DEFAULT);
+        }
+
+        @Override public String parseArgumentValue(
+                StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return value;
+        }
+
+        @Override public DefaultStatement createDeclared(
+                StmtContext<String, DefaultStatement, ?> ctx) {
+            return new DefaultStatementImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<String, DefaultStatement> createEffective(
+                StmtContext<String, DefaultStatement, EffectiveStatement<String, DefaultStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull @Override
+    public String getValue() {
+        return rawArgument();
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DescriptionStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DescriptionStatementImpl.java
new file mode 100644 (file)
index 0000000..0bbec53
--- /dev/null
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.DescriptionEffectiveStatementImpl;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import javax.annotation.Nonnull;
+
+public class DescriptionStatementImpl extends AbstractDeclaredStatement<String> implements DescriptionStatement {
+
+    protected DescriptionStatementImpl(
+            StmtContext<String, DescriptionStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<String,DescriptionStatement,EffectiveStatement<String,DescriptionStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.DESCRIPTION);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return value;
+        }
+
+        @Override
+        public DescriptionStatement createDeclared(StmtContext<String, DescriptionStatement, ?> ctx) {
+            return new DescriptionStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, DescriptionStatement> createEffective(StmtContext<String, DescriptionStatement, EffectiveStatement<String, DescriptionStatement>> ctx) {
+            return new DescriptionEffectiveStatementImpl(ctx);
+        }
+    }
+
+    @Nonnull @Override
+    public String getText() {
+        return rawArgument();
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviateStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviateStatementImpl.java
new file mode 100644 (file)
index 0000000..b47dc79
--- /dev/null
@@ -0,0 +1,53 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DeviateStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+
+public class DeviateStatementImpl extends AbstractDeclaredStatement<String> implements DeviateStatement {
+
+    protected DeviateStatementImpl(
+            StmtContext<String, DeviateStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<String,DeviateStatement,EffectiveStatement<String,DeviateStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.DEVIATE);
+        }
+
+        @Override public String parseArgumentValue(
+                StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return value;
+        }
+
+        @Override public DeviateStatement createDeclared(
+                StmtContext<String, DeviateStatement, ?> ctx) {
+            return new DeviateStatementImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<String, DeviateStatement> createEffective(
+                StmtContext<String, DeviateStatement, EffectiveStatement<String, DeviateStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull @Override
+    public String getValue() {
+        return rawArgument();
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviationStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/DeviationStatementImpl.java
new file mode 100644 (file)
index 0000000..4d6b433
--- /dev/null
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DeviationStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+
+public class DeviationStatementImpl extends AbstractDeclaredStatement<SchemaNodeIdentifier> implements DeviationStatement {
+
+    protected DeviationStatementImpl(
+            StmtContext<SchemaNodeIdentifier, DeviationStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<SchemaNodeIdentifier,DeviationStatement,EffectiveStatement<SchemaNodeIdentifier,DeviationStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.DEVIATION);
+        }
+
+        @Override public SchemaNodeIdentifier parseArgumentValue(
+                StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return SchemaNodeIdentifier.create(Utils.parseXPath(ctx, value), Utils.isXPathAbsolute(value));
+        }
+
+        @Override public DeviationStatement createDeclared(
+                StmtContext<SchemaNodeIdentifier, DeviationStatement, ?> ctx) {
+            return new DeviationStatementImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<SchemaNodeIdentifier, DeviationStatement> createEffective(
+                StmtContext<SchemaNodeIdentifier, DeviationStatement, EffectiveStatement<SchemaNodeIdentifier, DeviationStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull @Override
+    public SchemaNodeIdentifier getTargetNode() {
+        return argument();
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/EnumSpecificationImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/EnumSpecificationImpl.java
new file mode 100644 (file)
index 0000000..8a1a973
--- /dev/null
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.EnumStatement;
+
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+
+public class EnumSpecificationImpl extends AbstractDeclaredStatement<String>
+        implements TypeStatement.EnumSpecification {
+
+    protected EnumSpecificationImpl(
+            StmtContext<String, TypeStatement.EnumSpecification, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, TypeStatement.EnumSpecification, EffectiveStatement<String, TypeStatement.EnumSpecification>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.ENUM);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return value;
+        }
+
+        @Override
+        public TypeStatement.EnumSpecification createDeclared(
+                StmtContext<String, TypeStatement.EnumSpecification, ?> ctx) {
+            return new EnumSpecificationImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, TypeStatement.EnumSpecification> createEffective(
+                StmtContext<String, TypeStatement.EnumSpecification, EffectiveStatement<String, TypeStatement.EnumSpecification>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+    @Override
+    public Collection<? extends EnumStatement> getEnums() {
+        return allDeclared(EnumStatement.class);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/EnumStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/EnumStatementImpl.java
new file mode 100644 (file)
index 0000000..a5558a5
--- /dev/null
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.ValueStatement;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.EnumStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class EnumStatementImpl extends AbstractDeclaredStatement<String>
+        implements EnumStatement {
+
+    protected EnumStatementImpl(
+            StmtContext<String, EnumStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, EnumStatement, EffectiveStatement<String, EnumStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.ENUM);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public EnumStatement createDeclared(
+                StmtContext<String, EnumStatement, ?> ctx) {
+            return new EnumStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, EnumStatement> createEffective(
+                StmtContext<String, EnumStatement, EffectiveStatement<String, EnumStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+    @Override
+    public ValueStatement getValue() {
+        return firstDeclared(ValueStatement.class);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ErrorAppTagStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ErrorAppTagStatementImpl.java
new file mode 100644 (file)
index 0000000..4e1c9ab
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ErrorAppTagStatementImpl extends AbstractDeclaredStatement<String>
+        implements ErrorAppTagStatement {
+
+    protected ErrorAppTagStatementImpl(
+            StmtContext<String, ErrorAppTagStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, ErrorAppTagStatement, EffectiveStatement<String, ErrorAppTagStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.ERROR_APP_TAG);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public ErrorAppTagStatement createDeclared(
+                StmtContext<String, ErrorAppTagStatement, ?> ctx) {
+            return new ErrorAppTagStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, ErrorAppTagStatement> createEffective(
+                StmtContext<String, ErrorAppTagStatement, EffectiveStatement<String, ErrorAppTagStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ErrorMessageStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ErrorMessageStatementImpl.java
new file mode 100644 (file)
index 0000000..4ad3f49
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ErrorMessageStatementImpl extends
+        AbstractDeclaredStatement<String> implements ErrorMessageStatement {
+
+    protected ErrorMessageStatementImpl(
+            StmtContext<String, ErrorMessageStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, ErrorMessageStatement, EffectiveStatement<String, ErrorMessageStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.ERROR_MESSAGE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public ErrorMessageStatement createDeclared(
+                StmtContext<String, ErrorMessageStatement, ?> ctx) {
+            return new ErrorMessageStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, ErrorMessageStatement> createEffective(
+                StmtContext<String, ErrorMessageStatement, EffectiveStatement<String, ErrorMessageStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ExtensionStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ExtensionStatementImpl.java
new file mode 100644 (file)
index 0000000..65ae9e4
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.ArgumentStatement;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ExtensionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ExtensionStatementImpl extends AbstractDeclaredStatement<QName> implements ExtensionStatement {
+
+    protected ExtensionStatementImpl(StmtContext<QName, ExtensionStatement,?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<QName,ExtensionStatement,EffectiveStatement<QName,ExtensionStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.EXTENSION);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?,?,?> ctx, String value) {
+            return Utils.qNameFromArgument(ctx,value);
+        }
+
+        @Override
+        public ExtensionStatement createDeclared(StmtContext<QName, ExtensionStatement,?> ctx) {
+            return new ExtensionStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName,ExtensionStatement> createEffective(StmtContext<QName,ExtensionStatement,EffectiveStatement<QName,ExtensionStatement>> ctx) {
+           throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public ArgumentStatement getArgument() {
+        return firstDeclared(ArgumentStatement.class);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/FeatureStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/FeatureStatementImpl.java
new file mode 100644 (file)
index 0000000..3034662
--- /dev/null
@@ -0,0 +1,84 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.FeatureStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class FeatureStatementImpl extends AbstractDeclaredStatement<QName>
+        implements FeatureStatement {
+
+    protected FeatureStatementImpl(
+            StmtContext<QName, FeatureStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, FeatureStatement, EffectiveStatement<QName, FeatureStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.FEATURE);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public FeatureStatement createDeclared(
+                StmtContext<QName, FeatureStatement, ?> ctx) {
+            return new FeatureStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, FeatureStatement> createEffective(
+                StmtContext<QName, FeatureStatement, EffectiveStatement<QName, FeatureStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public Collection<? extends IfFeatureStatement> getIfFeatures() {
+        return allDeclared(IfFeatureStatement.class);
+    }
+
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/FractionDigitsStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/FractionDigitsStatementImpl.java
new file mode 100644 (file)
index 0000000..94e1017
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.FractionDigitsStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class FractionDigitsStatementImpl extends
+        AbstractDeclaredStatement<String> implements FractionDigitsStatement {
+
+    protected FractionDigitsStatementImpl(
+            StmtContext<String, FractionDigitsStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, FractionDigitsStatement, EffectiveStatement<String, FractionDigitsStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.FRACTION_DIGITS);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public FractionDigitsStatement createDeclared(
+                StmtContext<String, FractionDigitsStatement, ?> ctx) {
+            return new FractionDigitsStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, FractionDigitsStatement> createEffective(
+                StmtContext<String, FractionDigitsStatement, EffectiveStatement<String, FractionDigitsStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingStatementImpl.java
new file mode 100644 (file)
index 0000000..06ebd38
--- /dev/null
@@ -0,0 +1,108 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.GroupingEffectiveStatementImpl;
+
+import org.opendaylight.yangtools.yang.parser.spi.GroupingNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class GroupingStatementImpl extends AbstractDeclaredStatement<QName>
+        implements GroupingStatement {
+
+    protected GroupingStatementImpl(
+            StmtContext<QName, GroupingStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.GROUPING);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public GroupingStatement createDeclared(
+                StmtContext<QName, GroupingStatement, ?> ctx) {
+            return new GroupingStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, GroupingStatement> createEffective(
+                StmtContext<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> ctx) {
+            return new GroupingEffectiveStatementImpl(ctx);
+        }
+
+        @Override
+        public void onFullDefinitionDeclared(
+                Mutable<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> stmt)
+                throws InferenceException, SourceException {
+            stmt.getParentContext().addContext(GroupingNamespace.class, stmt.getStatementArgument(),stmt);
+            //
+        }
+
+    }
+
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public Collection<? extends TypedefStatement> getTypedefs() {
+        return allDeclared(TypedefStatement.class);
+    }
+
+    @Override
+    public Collection<? extends GroupingStatement> getGroupings() {
+        return allDeclared(GroupingStatement.class);
+    }
+
+    @Override
+    public Collection<? extends DataDefinitionStatement> getDataDefinitions() {
+        return allDeclared(DataDefinitionStatement.class);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingUtils.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/GroupingUtils.java
new file mode 100644 (file)
index 0000000..44f9148
--- /dev/null
@@ -0,0 +1,158 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import java.util.Collection;
+import java.util.HashSet;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RefineStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.UsesStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
+
+public class GroupingUtils {
+
+    /**
+     * @param sourceGrpStmtCtx
+     * @param targetCtx
+     * @throws SourceException
+     */
+    public static void copyFromSourceToTarget(
+            StatementContextBase<?, ?, ?> sourceGrpStmtCtx,
+            StatementContextBase<?, ?, ?> targetCtx) throws SourceException {
+
+        QNameModule newQNameModule = getNewQNameModule(targetCtx,
+                sourceGrpStmtCtx);
+        copyDeclaredStmts(sourceGrpStmtCtx, targetCtx, newQNameModule);
+        copyEffectiveStmts(sourceGrpStmtCtx, targetCtx, newQNameModule);
+
+    }
+
+    public static void copyDeclaredStmts(
+            StatementContextBase<?, ?, ?> sourceGrpStmtCtx,
+            StatementContextBase<?, ?, ?> targetCtx, QNameModule newQNameModule)
+            throws SourceException {
+        Collection<? extends StatementContextBase<?, ?, ?>> declaredSubstatements = sourceGrpStmtCtx
+                .declaredSubstatements();
+        for (StatementContextBase<?, ?, ?> originalStmtCtx : declaredSubstatements) {
+            if (needToCopyByUses(originalStmtCtx)) {
+                StatementContextBase<?, ?, ?> copy = originalStmtCtx
+                        .createCopy(newQNameModule, targetCtx);
+                targetCtx.addEffectiveSubstatement(copy);
+            } else if (isReusedByUses(originalStmtCtx)) {
+                targetCtx.addEffectiveSubstatement(originalStmtCtx);
+            }
+        }
+    }
+
+    public static void copyEffectiveStmts(
+            StatementContextBase<?, ?, ?> sourceGrpStmtCtx,
+            StatementContextBase<?, ?, ?> targetCtx, QNameModule newQNameModule)
+            throws SourceException {
+        Collection<? extends StatementContextBase<?, ?, ?>> effectiveSubstatements = sourceGrpStmtCtx
+                .effectiveSubstatements();
+        for (StatementContextBase<?, ?, ?> originalStmtCtx : effectiveSubstatements) {
+            if (needToCopyByUses(originalStmtCtx)) {
+                StatementContextBase<?, ?, ?> copy = originalStmtCtx
+                        .createCopy(newQNameModule, targetCtx);
+                targetCtx.addEffectiveSubstatement(copy);
+            } else if (isReusedByUses(originalStmtCtx)) {
+                targetCtx.addEffectiveSubstatement(originalStmtCtx);
+            }
+        }
+    }
+
+    public static QNameModule getNewQNameModule(
+            StatementContextBase<?, ?, ?> targetCtx,
+            StmtContext<?, ?, ?> stmtContext) {
+        if (needToCreateNewQName(stmtContext.getPublicDefinition())) {
+            Object targetStmtArgument = targetCtx.getStatementArgument();
+            Object sourceStmtArgument = stmtContext.getStatementArgument();
+            if (targetStmtArgument instanceof QName
+                    && sourceStmtArgument instanceof QName) {
+                QName targetQName = (QName) targetStmtArgument;
+                QNameModule targetQNameModule = targetQName.getModule();
+
+                QName sourceQName = (QName) sourceStmtArgument;
+                QNameModule sourceQNameModule = sourceQName.getModule();
+
+                if (targetQNameModule.equals(sourceQNameModule))
+                    return null;
+                else
+                    return targetQNameModule;
+            } else
+                return null;
+        } else
+            return null;
+    }
+
+    public static boolean needToCreateNewQName(
+            StatementDefinition publicDefinition) {
+        return true;
+    }
+
+    public static boolean needToCopyByUses(StmtContext<?, ?, ?> stmtContext) {
+
+        HashSet<StatementDefinition> noCopyDefSet = new HashSet<StatementDefinition>();
+        noCopyDefSet.add(Rfc6020Mapping.USES);
+
+        StatementDefinition def = stmtContext.getPublicDefinition();
+        if (noCopyDefSet.contains(def))
+            return false;
+        else
+            return true;
+    }
+
+    public static boolean isReusedByUses(StmtContext<?, ?, ?> stmtContext) {
+
+        HashSet<StatementDefinition> reusedDefSet = new HashSet<StatementDefinition>();
+        reusedDefSet.add(Rfc6020Mapping.TYPEDEF);
+
+        StatementDefinition def = stmtContext.getPublicDefinition();
+        if (reusedDefSet.contains(def))
+            return true;
+        else
+            return false;
+    }
+
+    public static void resolveUsesNode(
+            Mutable<QName, UsesStatement, EffectiveStatement<QName, UsesStatement>> usesNode,
+            StatementContextBase<?, ?, ?> targetNodeStmtCtx)
+            throws SourceException {
+
+        Collection<StatementContextBase<?, ?, ?>> declaredSubstatements = usesNode
+                .declaredSubstatements();
+        for (StatementContextBase<?, ?, ?> subStmtCtx : declaredSubstatements) {
+            if (StmtContextUtils.producesDeclared(subStmtCtx,
+                    WhenStatement.class)) {
+                StatementContextBase<?, ?, ?> copy = subStmtCtx.createCopy(
+                        null, targetNodeStmtCtx);
+                targetNodeStmtCtx.addEffectiveSubstatement(copy);
+            }
+            if (StmtContextUtils.producesDeclared(subStmtCtx,
+                    RefineStatement.class)) {
+                // :TODO resolve and perform refine statement
+            }
+            if (StmtContextUtils.producesDeclared(subStmtCtx,
+                    AugmentStatement.class)) {
+                // :TODO find target node and perform augmentation
+            }
+            // :TODO resolve other uses substatements
+        }
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IdentityRefSpecificationImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IdentityRefSpecificationImpl.java
new file mode 100644 (file)
index 0000000..bd2b1e7
--- /dev/null
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+
+public class IdentityRefSpecificationImpl extends
+        AbstractDeclaredStatement<String> implements
+        TypeStatement.IdentityRefSpecification {
+
+    protected IdentityRefSpecificationImpl(
+            StmtContext<String, TypeStatement.IdentityRefSpecification, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, TypeStatement.IdentityRefSpecification, EffectiveStatement<String, TypeStatement.IdentityRefSpecification>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.BASE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return value;
+        }
+
+        @Override
+        public TypeStatement.IdentityRefSpecification createDeclared(
+                StmtContext<String, TypeStatement.IdentityRefSpecification, ?> ctx) {
+            return new IdentityRefSpecificationImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, TypeStatement.IdentityRefSpecification> createEffective(
+                StmtContext<String, TypeStatement.IdentityRefSpecification, EffectiveStatement<String, TypeStatement.IdentityRefSpecification>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IdentityStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IdentityStatementImpl.java
new file mode 100644 (file)
index 0000000..c5ea40c
--- /dev/null
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.BaseStatement;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.IdentityStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class IdentityStatementImpl extends AbstractDeclaredStatement<QName>
+        implements IdentityStatement {
+
+    protected IdentityStatementImpl(
+            StmtContext<QName, IdentityStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, IdentityStatement, EffectiveStatement<QName, IdentityStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.IDENTITY);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public IdentityStatement createDeclared(
+                StmtContext<QName, IdentityStatement, ?> ctx) {
+            return new IdentityStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, IdentityStatement> createEffective(
+                StmtContext<QName, IdentityStatement, EffectiveStatement<QName, IdentityStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public BaseStatement getBase() {
+        return firstDeclared(BaseStatement.class);
+    }
+
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IfFeatureStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IfFeatureStatementImpl.java
new file mode 100644 (file)
index 0000000..42c5e1e
--- /dev/null
@@ -0,0 +1,58 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class IfFeatureStatementImpl extends AbstractDeclaredStatement<QName>
+        implements IfFeatureStatement {
+
+    protected IfFeatureStatementImpl(
+            StmtContext<QName, IfFeatureStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, IfFeatureStatement, EffectiveStatement<QName, IfFeatureStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.IF_FEATURE);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public IfFeatureStatement createDeclared(
+                StmtContext<QName, IfFeatureStatement, ?> ctx) {
+            return new IfFeatureStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, IfFeatureStatement> createEffective(
+                StmtContext<QName, IfFeatureStatement, EffectiveStatement<QName, IfFeatureStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+}
index df2ee7aa0f9ff9147f227c981da2f625a4e91210..2f9eb15799a1de0b1631ed5d3a78d46427d2d21b 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
-
 import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.SOURCE_LINKAGE;
 import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
-
+import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
 import com.google.common.base.Optional;
 import java.net.URI;
 import java.text.ParseException;
@@ -57,14 +57,18 @@ public class ImportStatementDefinition extends
     }
 
     @Override
-    public void onLinkageDeclared(final Mutable<String, ImportStatement, EffectiveStatement<String, ImportStatement>> stmt)
+    public void onLinkageDeclared(
+            final Mutable<String, ImportStatement, EffectiveStatement<String, ImportStatement>> stmt)
             throws InferenceException, SourceException {
         final ModuleIdentifier impIdentifier = getImportedModuleIdentifier(stmt);
         ModelActionBuilder importAction = stmt.newInferenceAction(SOURCE_LINKAGE);
         final Prerequisite<StmtContext<?, ?, ?>> imported;
         final Prerequisite<Mutable<?, ?, ?>> linkageTarget;
         imported = importAction.requiresCtx(stmt, ModuleNamespace.class, impIdentifier, SOURCE_LINKAGE);
-        linkageTarget = importAction.mutatesCtx(stmt.getRoot(),SOURCE_LINKAGE);
+        linkageTarget = importAction.mutatesCtx(stmt.getRoot(), SOURCE_LINKAGE);
+
+        String impPrefix = firstAttributeOf(stmt.declaredSubstatements(), PrefixStatement.class);
+        stmt.addToNs(ImpPrefixToModuleIdentifier.class, impPrefix, impIdentifier);
 
         importAction.apply(new InferenceAction() {
 
@@ -89,7 +93,9 @@ public class ImportStatementDefinition extends
         });
     }
 
-    private static ModuleIdentifier getImportedModuleIdentifier(Mutable<String, ImportStatement, ?> stmt) throws SourceException {
+    private static ModuleIdentifier getImportedModuleIdentifier(Mutable<String, ImportStatement, ?> stmt)
+            throws SourceException {
+
         String moduleName = stmt.getStatementArgument();
         String revisionArg = firstAttributeOf(stmt.declaredSubstatements(), RevisionDateStatement.class);
         final Optional<Date> revision;
@@ -97,12 +103,11 @@ public class ImportStatementDefinition extends
             try {
                 revision = Optional.of(SimpleDateFormatUtil.getRevisionFormat().parse(revisionArg));
             } catch (ParseException e) {
-                throw new SourceException(
-                        String.format("Revision value %s is not in required format yyyy-MM-dd", revisionArg),
-                        stmt.getStatementSourceReference(), e);
+                throw new SourceException(String.format("Revision value %s is not in required format yyyy-MM-dd",
+                        revisionArg), stmt.getStatementSourceReference(), e);
             }
         } else {
-            revision = Optional.absent();
+            revision = Optional.of(SimpleDateFormatUtil.DEFAULT_DATE_IMP);
         }
         return new ModuleIdentifierImpl(moduleName, Optional.<URI> absent(), revision);
     }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IncludeStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IncludeStatementImpl.java
new file mode 100644 (file)
index 0000000..5305e3b
--- /dev/null
@@ -0,0 +1,135 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.SOURCE_LINKAGE;
+import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
+
+import java.net.URI;
+import java.text.ParseException;
+import java.util.Collection;
+import java.util.Date;
+
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.IncludeStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RevisionDateStatement;
+import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleIdentifierImpl;
+import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.InferenceAction;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.Prerequisite;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import com.google.common.base.Optional;
+
+public class IncludeStatementImpl extends AbstractDeclaredStatement<String> implements IncludeStatement {
+
+    protected IncludeStatementImpl(StmtContext<String, IncludeStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends
+            AbstractStatementSupport<String, IncludeStatement, EffectiveStatement<String, IncludeStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.INCLUDE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public IncludeStatement createDeclared(StmtContext<String, IncludeStatement, ?> ctx) {
+            return new IncludeStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, IncludeStatement> createEffective(
+                StmtContext<String, IncludeStatement, EffectiveStatement<String, IncludeStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public void onLinkageDeclared(
+                final Mutable<String, IncludeStatement, EffectiveStatement<String, IncludeStatement>> stmt)
+                throws InferenceException, SourceException {
+            final ModuleIdentifier includeSubmoduleIdentifier = getIncludeSubmoduleIdentifier(stmt);
+
+            ModelActionBuilder includeAction = stmt.newInferenceAction(SOURCE_LINKAGE);
+            final Prerequisite<StmtContext<?, ?, ?>> requiresCtxPrerequisite = includeAction.requiresCtx(stmt,
+                    SubmoduleNamespace.class, includeSubmoduleIdentifier, SOURCE_LINKAGE);
+            final Prerequisite<Mutable<?, ?, ?>> mutatesCtxPrerequisite = includeAction.mutatesCtx(stmt.getRoot(),
+                    SOURCE_LINKAGE);
+
+            includeAction.apply(new InferenceAction() {
+
+                @Override
+                public void apply() throws InferenceException {
+                    StmtContext<?, ?, ?> includedSubmoduleStmt = requiresCtxPrerequisite.get();
+
+                    mutatesCtxPrerequisite.get().addToNs(IncludedModuleContext.class, includeSubmoduleIdentifier,
+                            includedSubmoduleStmt);
+                }
+
+                @Override
+                public void prerequisiteFailed(Collection<? extends Prerequisite<?>> failed) throws InferenceException {
+                    System.out.println("");
+                    if (failed.contains(requiresCtxPrerequisite)) {
+                        throw new InferenceException("Included submodule was not found.", stmt
+                                .getStatementSourceReference());
+                    }
+                }
+            });
+        }
+
+        private static ModuleIdentifier getIncludeSubmoduleIdentifier(Mutable<String, IncludeStatement, ?> stmt) {
+
+            String subModuleName = stmt.getStatementArgument();
+            String revisionArg = firstAttributeOf(stmt.declaredSubstatements(), RevisionDateStatement.class);
+            final Optional<Date> revision;
+            if (revisionArg != null) {
+                try {
+                    revision = Optional.of(SimpleDateFormatUtil.getRevisionFormat().parse(revisionArg));
+                } catch (ParseException e) {
+                    throw new IllegalArgumentException(e);
+                }
+            } else {
+                revision = Optional.of(SimpleDateFormatUtil.DEFAULT_DATE_IMP);
+            }
+
+            return new ModuleIdentifierImpl(subModuleName, Optional.<URI> absent(), revision);
+        }
+    }
+
+    @Override
+    public String getModule() {
+        return argument();
+    }
+
+    @Override
+    public PrefixStatement getPrefix() {
+        return firstDeclared(PrefixStatement.class);
+    }
+
+    @Override
+    public RevisionDateStatement getRevisionDate() {
+        return firstDeclared(RevisionDateStatement.class);
+    }
+
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IncludedModuleContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/IncludedModuleContext.java
new file mode 100644 (file)
index 0000000..6c561c0
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ImportedNamespaceContext;
+
+public interface IncludedModuleContext extends ImportedNamespaceContext<ModuleIdentifier> {
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/InputStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/InputStatementImpl.java
new file mode 100644 (file)
index 0000000..14a7391
--- /dev/null
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class InputStatementImpl extends AbstractDeclaredStatement<Void>
+        implements InputStatement {
+
+    protected InputStatementImpl(
+            StmtContext<Void, InputStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<Void, InputStatement, EffectiveStatement<Void, InputStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.INPUT);
+        }
+
+        @Override
+        public Void parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return null;
+        }
+
+        @Override
+        public InputStatement createDeclared(
+                StmtContext<Void, InputStatement, ?> ctx) {
+            return new InputStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<Void, InputStatement> createEffective(
+                StmtContext<Void, InputStatement, EffectiveStatement<Void, InputStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public Collection<? extends TypedefStatement> getTypedefs() {
+        return allDeclared(TypedefStatement.class);
+    }
+
+    @Override
+    public Collection<? extends GroupingStatement> getGroupings() {
+        return allDeclared(GroupingStatement.class);
+    }
+
+    @Override
+    public Collection<? extends DataDefinitionStatement> getDataDefinitions() {
+        return allDeclared(DataDefinitionStatement.class);
+    }
+}
+
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/InstanceIdentifierSpecificationImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/InstanceIdentifierSpecificationImpl.java
new file mode 100644 (file)
index 0000000..504498d
--- /dev/null
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+
+public class InstanceIdentifierSpecificationImpl extends
+        AbstractDeclaredStatement<String> implements
+        TypeStatement.InstanceIdentifierSpecification {
+
+    protected InstanceIdentifierSpecificationImpl(
+            StmtContext<String, TypeStatement.InstanceIdentifierSpecification, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, TypeStatement.InstanceIdentifierSpecification, EffectiveStatement<String, TypeStatement.InstanceIdentifierSpecification>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.REQUIRE_INSTANCE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return value;
+        }
+
+        @Override
+        public TypeStatement.InstanceIdentifierSpecification createDeclared(
+                StmtContext<String, TypeStatement.InstanceIdentifierSpecification, ?> ctx) {
+            return new InstanceIdentifierSpecificationImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, TypeStatement.InstanceIdentifierSpecification> createEffective(
+                StmtContext<String, TypeStatement.InstanceIdentifierSpecification, EffectiveStatement<String, TypeStatement.InstanceIdentifierSpecification>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+    @Override
+    public RequireInstanceStatement getRequireInstance() {
+        return firstDeclared(RequireInstanceStatement.class);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/KeyStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/KeyStatementImpl.java
new file mode 100644 (file)
index 0000000..f80e0cd
--- /dev/null
@@ -0,0 +1,79 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.KeyStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import com.google.common.base.Splitter;
+
+public class KeyStatementImpl extends AbstractDeclaredStatement<Collection<SchemaNodeIdentifier>> implements
+        KeyStatement {
+
+    protected KeyStatementImpl(StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<Collection<SchemaNodeIdentifier>, KeyStatement, EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> {
+
+        public static final char SEPARATOR = ' ';
+
+        public Definition() {
+            super(Rfc6020Mapping.KEY);
+        }
+
+        @Override
+        public Collection<SchemaNodeIdentifier> parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+
+            Splitter keySplitter = Splitter.on(SEPARATOR).omitEmptyStrings().trimResults();
+            List<String> keyTokens = keySplitter.splitToList(value);
+
+            // to detect if key contains duplicates
+            if ((new HashSet<>(keyTokens)).size() < keyTokens.size()) {
+                throw new IllegalArgumentException();
+            }
+
+            Set<SchemaNodeIdentifier> keyNodes = new HashSet<>();
+
+            for (String keyToken : keyTokens) {
+
+                SchemaNodeIdentifier keyNode = SchemaNodeIdentifier
+                        .create(true, Utils.qNameFromArgument(ctx, keyToken));
+                keyNodes.add(keyNode);
+            }
+
+            return keyNodes;
+        }
+
+        @Override
+        public KeyStatement createDeclared(StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, ?> ctx) {
+            return new KeyStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement> createEffective(
+                StmtContext<Collection<SchemaNodeIdentifier>, KeyStatement, EffectiveStatement<Collection<SchemaNodeIdentifier>, KeyStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LeafListStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LeafListStatementImpl.java
new file mode 100644 (file)
index 0000000..032e1b9
--- /dev/null
@@ -0,0 +1,140 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.MaxElementsStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MinElementsStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByStatement;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.LeafListStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Collection;
+
+public class LeafListStatementImpl extends AbstractDeclaredStatement<QName>
+        implements LeafListStatement {
+
+    protected LeafListStatementImpl(
+            StmtContext<QName, LeafListStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, LeafListStatement, EffectiveStatement<QName, LeafListStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.LEAF_LIST);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public LeafListStatement createDeclared(
+                StmtContext<QName, LeafListStatement, ?> ctx) {
+            return new LeafListStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, LeafListStatement> createEffective(
+                StmtContext<QName, LeafListStatement, EffectiveStatement<QName, LeafListStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+    @Nullable
+    @Override
+    public ConfigStatement getConfig() {
+        return firstDeclared(ConfigStatement.class);
+    }
+
+    @Override
+    public WhenStatement getWhenStatement() {
+        return firstDeclared(WhenStatement.class);
+    }
+
+    @Nonnull
+    @Override
+    public Collection<? extends IfFeatureStatement> getIfFeatures() {
+        return allDeclared(IfFeatureStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public MinElementsStatement getMinElements() {
+        return firstDeclared(MinElementsStatement.class);
+    }
+
+    @Override
+    public MaxElementsStatement getMaxElements() {
+        return firstDeclared(MaxElementsStatement.class);
+    }
+
+    @Override
+    public OrderedByStatement getOrderedBy() {
+        return firstDeclared(OrderedByStatement.class);
+    }
+
+    @Override
+    public Collection<? extends MustStatement> getMusts() {
+        return allDeclared(MustStatement.class);
+    }
+
+    @Override
+    public TypeStatement getType() {
+        return firstDeclared(TypeStatement.class);
+    }
+
+    @Override
+    public UnitsStatement getUnits() {
+        return firstDeclared(UnitsStatement.class);
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LeafStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LeafStatementImpl.java
new file mode 100644 (file)
index 0000000..4e06178
--- /dev/null
@@ -0,0 +1,121 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DefaultStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.LeafStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Collection;
+
+public class LeafStatementImpl extends AbstractDeclaredStatement<QName> implements LeafStatement {
+
+    protected LeafStatementImpl(StmtContext<QName, LeafStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<QName,LeafStatement,EffectiveStatement<QName,LeafStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.LEAF);
+        }
+
+        @Override public QName parseArgumentValue(StmtContext<?, ?, ?> ctx,
+                String value) throws SourceException {
+            return Utils.qNameFromArgument(ctx,value);
+        }
+
+        @Override public LeafStatement createDeclared(
+                StmtContext<QName, LeafStatement, ?> ctx) {
+            return new LeafStatementImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<QName, LeafStatement> createEffective(
+                StmtContext<QName, LeafStatement, EffectiveStatement<QName, LeafStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nullable @Override
+    public Collection<? extends MustStatement> getMusts() {
+        return allDeclared(MustStatement.class);
+    }
+
+    @Nullable @Override
+    public DefaultStatement getDefault() {
+        return firstDeclared(DefaultStatement.class);
+    }
+
+    @Nullable @Override
+    public ConfigStatement getConfig() {
+        return firstDeclared(ConfigStatement.class);
+    }
+
+    @Nullable @Override
+    public MandatoryStatement getMandatory() {
+        return firstDeclared(MandatoryStatement.class);
+    }
+
+    @Nonnull @Override
+    public QName getName() {
+        return argument();
+    }
+
+    @Override
+    public WhenStatement getWhenStatement() {
+        return firstDeclared(WhenStatement.class);
+    }
+
+    @Nonnull @Override
+    public Collection<? extends IfFeatureStatement> getIfFeatures() {
+        return allDeclared(IfFeatureStatement.class);
+    }
+
+    @Nullable @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Nonnull @Override
+    public TypeStatement getType() {
+        return firstDeclared(TypeStatement.class);
+    }
+
+    @Nullable @Override
+    public UnitsStatement getUnits() {
+        return firstDeclared(UnitsStatement.class);
+    }
+
+    @Nullable @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LeafrefSpecificationImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LeafrefSpecificationImpl.java
new file mode 100644 (file)
index 0000000..58b7d5c
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.PathStatement;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+
+public class LeafrefSpecificationImpl extends AbstractDeclaredStatement<String>
+        implements TypeStatement.LeafrefSpecification {
+
+    protected LeafrefSpecificationImpl(
+            StmtContext<String, TypeStatement.LeafrefSpecification, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, TypeStatement.LeafrefSpecification, EffectiveStatement<String, TypeStatement.LeafrefSpecification>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.PATH);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return value;
+        }
+
+        @Override
+        public TypeStatement.LeafrefSpecification createDeclared(
+                StmtContext<String, TypeStatement.LeafrefSpecification, ?> ctx) {
+            return new LeafrefSpecificationImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, TypeStatement.LeafrefSpecification> createEffective(
+                StmtContext<String, TypeStatement.LeafrefSpecification, EffectiveStatement<String, TypeStatement.LeafrefSpecification>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+    @Override
+    public PathStatement getPath() {
+        return firstDeclared(PathStatement.class);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LengthStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/LengthStatementImpl.java
new file mode 100644 (file)
index 0000000..bf959f8
--- /dev/null
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.LengthStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class LengthStatementImpl extends AbstractDeclaredStatement<String>
+        implements LengthStatement {
+
+    protected LengthStatementImpl(
+            StmtContext<String, LengthStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, LengthStatement, EffectiveStatement<String, LengthStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.LENGTH);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public LengthStatement createDeclared(
+                StmtContext<String, LengthStatement, ?> ctx) {
+            return new LengthStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, LengthStatement> createEffective(
+                StmtContext<String, LengthStatement, EffectiveStatement<String, LengthStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public ErrorAppTagStatement getErrorAppTagStatement() {
+        return firstDeclared(ErrorAppTagStatement.class);
+    }
+
+    @Override
+    public ErrorMessageStatement getErrorMessageStatement() {
+        return firstDeclared(ErrorMessageStatement.class);
+    }
+
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ListStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ListStatementImpl.java
new file mode 100644 (file)
index 0000000..3279abc
--- /dev/null
@@ -0,0 +1,157 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.KeyStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MaxElementsStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MinElementsStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.UniqueStatement;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ListStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+import java.util.Collection;
+
+public class ListStatementImpl extends AbstractDeclaredStatement<QName>
+        implements ListStatement {
+
+    protected ListStatementImpl(StmtContext<QName, ListStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, ListStatement, EffectiveStatement<QName, ListStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.LIST);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public ListStatement createDeclared(
+                StmtContext<QName, ListStatement, ?> ctx) {
+            return new ListStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, ListStatement> createEffective(
+                StmtContext<QName, ListStatement, EffectiveStatement<QName, ListStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+    @Nullable
+    @Override
+    public ConfigStatement getConfig() {
+        return firstDeclared(ConfigStatement.class);
+    }
+
+    @Override
+    public WhenStatement getWhenStatement() {
+        return firstDeclared(WhenStatement.class);
+    }
+
+    @Nonnull
+    @Override
+    public Collection<? extends IfFeatureStatement> getIfFeatures() {
+        return allDeclared(IfFeatureStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public MinElementsStatement getMinElements() {
+        return firstDeclared(MinElementsStatement.class);
+    }
+
+    @Override
+    public MaxElementsStatement getMaxElements() {
+        return firstDeclared(MaxElementsStatement.class);
+    }
+
+    @Override
+    public OrderedByStatement getOrderedBy() {
+        return firstDeclared(OrderedByStatement.class);
+    }
+
+    @Override
+    public Collection<? extends TypedefStatement> getTypedefs() {
+        return allDeclared(TypedefStatement.class);
+    }
+
+    @Override
+    public Collection<? extends GroupingStatement> getGroupings() {
+        return allDeclared(GroupingStatement.class);
+    }
+
+    @Override
+    public Collection<? extends DataDefinitionStatement> getDataDefinitions() {
+        return allDeclared(DataDefinitionStatement.class);
+    }
+
+    @Override
+    public Collection<? extends MustStatement> getMusts() {
+        return allDeclared(MustStatement.class);
+    }
+
+    @Override
+    public KeyStatement getKey() {
+        return firstDeclared(KeyStatement.class);
+    }
+
+    @Override
+    public Collection<? extends UniqueStatement> getUnique() {
+        return allDeclared(UniqueStatement.class);
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MandatoryStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MandatoryStatementImpl.java
new file mode 100644 (file)
index 0000000..fd9331f
--- /dev/null
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+
+public class MandatoryStatementImpl extends AbstractDeclaredStatement<Boolean> implements
+        MandatoryStatement {
+
+    protected MandatoryStatementImpl(
+            StmtContext<Boolean, MandatoryStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<Boolean,MandatoryStatement,EffectiveStatement<Boolean,MandatoryStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.MANDATORY);
+        }
+
+        @Override public Boolean parseArgumentValue(
+                StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return Boolean.valueOf(value);
+        }
+
+        @Override public MandatoryStatement createDeclared(
+                StmtContext<Boolean, MandatoryStatement, ?> ctx) {
+            return new MandatoryStatementImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<Boolean, MandatoryStatement> createEffective(
+                StmtContext<Boolean, MandatoryStatement, EffectiveStatement<Boolean, MandatoryStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull @Override
+    public Boolean getValue() {
+        return argument();
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MaxElementsStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MaxElementsStatementImpl.java
new file mode 100644 (file)
index 0000000..ed0f27e
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MaxElementsStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class MaxElementsStatementImpl extends AbstractDeclaredStatement<String>
+        implements MaxElementsStatement {
+
+    protected MaxElementsStatementImpl(
+            StmtContext<String, MaxElementsStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, MaxElementsStatement, EffectiveStatement<String, MaxElementsStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.MAX_ELEMENTS);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public MaxElementsStatement createDeclared(
+                StmtContext<String, MaxElementsStatement, ?> ctx) {
+            return new MaxElementsStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, MaxElementsStatement> createEffective(
+                StmtContext<String, MaxElementsStatement, EffectiveStatement<String, MaxElementsStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MinElementsStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MinElementsStatementImpl.java
new file mode 100644 (file)
index 0000000..b0b1ab0
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MinElementsStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class MinElementsStatementImpl extends AbstractDeclaredStatement<String>
+        implements MinElementsStatement {
+
+    protected MinElementsStatementImpl(
+            StmtContext<String, MinElementsStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, MinElementsStatement, EffectiveStatement<String, MinElementsStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.MIN_ELEMENTS);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public MinElementsStatement createDeclared(
+                StmtContext<String, MinElementsStatement, ?> ctx) {
+            return new MinElementsStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, MinElementsStatement> createEffective(
+                StmtContext<String, MinElementsStatement, EffectiveStatement<String, MinElementsStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+
+}
index fadc8fccf855db7ca1144d5dda24ea719904337a..fb2eb3892400813439605c6ac6287c6bb24f376f 100644 (file)
@@ -9,6 +9,16 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
 import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
 
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ModuleEffectiveStatementImpl;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
+import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleIdentifierToModuleQName;
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement;
 import com.google.common.base.Optional;
 import java.net.URI;
 import java.util.Date;
@@ -26,37 +36,89 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
-public class ModuleStatementSupport extends AbstractStatementSupport<String, ModuleStatement, EffectiveStatement<String,ModuleStatement>> {
+public class ModuleStatementSupport
+        extends
+        AbstractStatementSupport<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> {
 
     public ModuleStatementSupport() {
         super(Rfc6020Mapping.MODULE);
     }
 
     @Override
-    public String parseArgumentValue(StmtContext<?,?,?> ctx, String value) {
+    public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
         return value;
     }
 
     @Override
-    public ModuleStatement createDeclared(StmtContext<String, ModuleStatement,?> ctx) {
+    public ModuleStatement createDeclared(
+            StmtContext<String, ModuleStatement, ?> ctx) {
         return new ModuleStatementImpl(ctx);
     }
 
     @Override
-    public EffectiveStatement<String,ModuleStatement> createEffective(StmtContext<String, ModuleStatement,EffectiveStatement<String,ModuleStatement>> ctx) {
-        throw new UnsupportedOperationException();
+    public EffectiveStatement<String, ModuleStatement> createEffective(
+            StmtContext<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> ctx) {
+        return new ModuleEffectiveStatementImpl(ctx);
     }
 
     @Override
-    public void onLinkageDeclared(Mutable<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> stmt)
+    public void onLinkageDeclared(
+            Mutable<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> stmt)
             throws InferenceException, SourceException {
-        URI moduleNs = firstAttributeOf(stmt.declaredSubstatements(),NamespaceStatement.class);
 
-        QNameModule qnameNamespace = QNameModule.create(moduleNs, null);
-        ModuleIdentifierImpl moduleIdentifier = new ModuleIdentifierImpl(stmt.getStatementArgument(), Optional.<URI>absent(), Optional.<Date>absent());
+        Optional<URI> moduleNs = Optional.fromNullable(firstAttributeOf(
+                stmt.declaredSubstatements(), NamespaceStatement.class));
+        if (!moduleNs.isPresent()) {
+            throw new IllegalArgumentException("Namespace of the module ["
+                    + stmt.getStatementArgument() + "] is missing.");
+        }
+
+        Optional<Date> revisionDate = Optional.fromNullable(firstAttributeOf(
+                stmt.declaredSubstatements(), RevisionStatement.class));
+
+        QNameModule qNameModule = QNameModule.create(moduleNs.get(),
+                revisionDate.orNull());
+        ModuleIdentifier moduleIdentifier = new ModuleIdentifierImpl(
+                stmt.getStatementArgument(), Optional.<URI> absent(),
+                revisionDate);
+
+        stmt.addContext(ModuleNamespace.class, moduleIdentifier, stmt);
+        stmt.addContext(NamespaceToModule.class, qNameModule, stmt);
+
+        String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(),
+                PrefixStatement.class);
+        if (modulePrefix == null) {
+            throw new IllegalArgumentException("Prefix of the module ["
+                    + stmt.getStatementArgument() + "] is missing.");
+        }
+
+        stmt.addToNs(PrefixToModule.class, modulePrefix, qNameModule);
+        stmt.addToNs(ModuleNameToModuleQName.class, stmt.getStatementArgument(), qNameModule);
+        stmt.addToNs(ModuleQNameToModuleName.class, qNameModule, stmt.getStatementArgument());
+        stmt.addToNs(ModuleIdentifierToModuleQName.class, moduleIdentifier, qNameModule);
+
+        stmt.addToNs(ImpPrefixToModuleIdentifier.class, modulePrefix, moduleIdentifier);
 
-        stmt.addContext(ModuleNamespace.class,moduleIdentifier ,stmt);
-        stmt.addContext(NamespaceToModule.class, qnameNamespace, stmt);
     }
 
+
+
+//    @Override
+//    public void onFullDefinitionDeclared(
+//            Mutable<String, ModuleStatement, EffectiveStatement<String, ModuleStatement>> stmt)
+//            throws InferenceException, SourceException {
+//
+//        Optional<Date> revisionDate = Optional.fromNullable(firstAttributeOf(
+//                stmt.declaredSubstatements(), RevisionStatement.class));
+//
+//        ModuleIdentifier moduleIdentifier = new ModuleIdentifierImpl(
+//                stmt.getStatementArgument(), Optional.<URI> absent(),
+//                revisionDate);
+//
+//        String modulePrefix = firstAttributeOf(stmt.declaredSubstatements(),
+//                PrefixStatement.class);
+//
+//        stmt.addToNs(ImpPrefixToModuleIdentifier.class, modulePrefix, moduleIdentifier);
+//    }
+
 }
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MustStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/MustStatementImpl.java
new file mode 100644 (file)
index 0000000..c326f4c
--- /dev/null
@@ -0,0 +1,74 @@
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.MustStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.util.RevisionAwareXPathImpl;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+public class MustStatementImpl extends AbstractDeclaredStatement<RevisionAwareXPath> implements
+        MustStatement {
+
+    protected MustStatementImpl(
+            StmtContext<RevisionAwareXPath, MustStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<RevisionAwareXPath,MustStatement,EffectiveStatement<RevisionAwareXPath,MustStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.MUST);
+        }
+
+        @Override public RevisionAwareXPath parseArgumentValue(
+                StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return new RevisionAwareXPathImpl(value, false);
+        }
+
+        @Override public MustStatement createDeclared(
+                StmtContext<RevisionAwareXPath, MustStatement, ?> ctx) {
+            return new MustStatementImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<RevisionAwareXPath, MustStatement> createEffective(
+                StmtContext<RevisionAwareXPath, MustStatement, EffectiveStatement<RevisionAwareXPath, MustStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull @Override
+    public RevisionAwareXPath getCondition() {
+        return argument();
+    }
+
+    @Nullable @Override
+    public ErrorAppTagStatement getErrorAppTagStatement() {
+        return firstDeclared(ErrorAppTagStatement.class);
+    }
+
+    @Nullable @Override
+    public ErrorMessageStatement getErrorMessageStatement() {
+        return firstDeclared(ErrorMessageStatement.class);
+    }
+
+    @Nullable @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+}
index ad2eb0aee1e8a73fba915649401d9c6dee72c6c8..0c25f11ccbcad9a201a8d9e6662c5560298ada11 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.NamespaceEffectiveStatementImpl;
+
 import java.net.URI;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.NamespaceStatement;
@@ -34,7 +36,7 @@ public class NamespaceStatementImpl extends AbstractDeclaredStatement<URI> imple
 
         @Override
         public EffectiveStatement<URI,NamespaceStatement> createEffective(StmtContext<URI, NamespaceStatement,EffectiveStatement<URI,NamespaceStatement>> ctx) {
-            throw new UnsupportedOperationException();
+            return new NamespaceEffectiveStatementImpl(ctx);
         }
 
     }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/NotificationStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/NotificationStatementImpl.java
new file mode 100644 (file)
index 0000000..db4f195
--- /dev/null
@@ -0,0 +1,98 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import javax.annotation.Nullable;
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.NotificationStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class NotificationStatementImpl extends AbstractDeclaredStatement<QName>
+        implements NotificationStatement {
+
+    protected NotificationStatementImpl(
+            StmtContext<QName, NotificationStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.NOTIFICATION);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public NotificationStatement createDeclared(
+                StmtContext<QName, NotificationStatement, ?> ctx) {
+            return new NotificationStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, NotificationStatement> createEffective(
+                StmtContext<QName, NotificationStatement, EffectiveStatement<QName, NotificationStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+    @Override
+    public Collection<? extends TypedefStatement> getTypedefs() {
+        return allDeclared(TypedefStatement.class);
+    }
+
+    @Override
+    public Collection<? extends GroupingStatement> getGroupings() {
+        return allDeclared(GroupingStatement.class);
+    }
+
+    @Override
+    public Collection<? extends DataDefinitionStatement> getDataDefinitions() {
+        return allDeclared(DataDefinitionStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/NumericalRestrictionsImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/NumericalRestrictionsImpl.java
new file mode 100644 (file)
index 0000000..2415db6
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RangeStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+
+public class NumericalRestrictionsImpl extends AbstractDeclaredStatement<String> implements TypeStatement.NumericalRestrictions{
+
+    protected NumericalRestrictionsImpl(StmtContext<String, TypeStatement.NumericalRestrictions, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<String,TypeStatement.NumericalRestrictions,EffectiveStatement<String,TypeStatement.NumericalRestrictions>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.RANGE);
+        }
+
+        @Override public String parseArgumentValue(StmtContext<?, ?, ?> ctx,
+                String value) throws SourceException {
+            return value;
+        }
+
+        @Override public TypeStatement.NumericalRestrictions createDeclared(
+                StmtContext<String, TypeStatement.NumericalRestrictions, ?> ctx) {
+            return new NumericalRestrictionsImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<String, TypeStatement.NumericalRestrictions> createEffective(
+                StmtContext<String, TypeStatement.NumericalRestrictions, EffectiveStatement<String, TypeStatement.NumericalRestrictions>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+    @Override
+    public RangeStatement getRange() {
+       return firstDeclared(RangeStatement.class);
+    }
+
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/OrderedByStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/OrderedByStatementImpl.java
new file mode 100644 (file)
index 0000000..f47c68a
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.OrderedByStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class OrderedByStatementImpl extends AbstractDeclaredStatement<String>
+        implements OrderedByStatement {
+
+    protected OrderedByStatementImpl(
+            StmtContext<String, OrderedByStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, OrderedByStatement, EffectiveStatement<String, OrderedByStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.ORDERED_BY);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public OrderedByStatement createDeclared(
+                StmtContext<String, OrderedByStatement, ?> ctx) {
+            return new OrderedByStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, OrderedByStatement> createEffective(
+                StmtContext<String, OrderedByStatement, EffectiveStatement<String, OrderedByStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/OrganizationStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/OrganizationStatementImpl.java
new file mode 100644 (file)
index 0000000..11f38b1
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.OrganizationStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class OrganizationStatementImpl extends AbstractDeclaredStatement<String>
+        implements OrganizationStatement {
+
+    protected OrganizationStatementImpl(
+            StmtContext<String, OrganizationStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, OrganizationStatement, EffectiveStatement<String, OrganizationStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.ORGANIZATION);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public OrganizationStatement createDeclared(
+                StmtContext<String, OrganizationStatement, ?> ctx) {
+            return new OrganizationStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, OrganizationStatement> createEffective(
+                StmtContext<String, OrganizationStatement, EffectiveStatement<String, OrganizationStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getText() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/OutputStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/OutputStatementImpl.java
new file mode 100644 (file)
index 0000000..53044b4
--- /dev/null
@@ -0,0 +1,73 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.stmt.DataDefinitionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.OutputStatement;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class OutputStatementImpl extends AbstractDeclaredStatement<Void>
+        implements OutputStatement {
+
+    protected OutputStatementImpl(
+            StmtContext<Void, OutputStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<Void, OutputStatement, EffectiveStatement<Void, OutputStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.OUTPUT);
+        }
+
+        @Override
+        public Void parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return null;
+        }
+
+        @Override
+        public OutputStatement createDeclared(
+                StmtContext<Void, OutputStatement, ?> ctx) {
+            return new OutputStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<Void, OutputStatement> createEffective(
+                StmtContext<Void, OutputStatement, EffectiveStatement<Void, OutputStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public Collection<? extends TypedefStatement> getTypedefs() {
+        return allDeclared(TypedefStatement.class);
+    }
+
+    @Override
+    public Collection<? extends GroupingStatement> getGroupings() {
+        return allDeclared(GroupingStatement.class);
+    }
+
+    @Override
+    public Collection<? extends DataDefinitionStatement> getDataDefinitions() {
+        return allDeclared(DataDefinitionStatement.class);
+    }
+}
+
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/PatternStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/PatternStatementImpl.java
new file mode 100644 (file)
index 0000000..714c943
--- /dev/null
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PatternStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class PatternStatementImpl extends AbstractDeclaredStatement<String>
+        implements PatternStatement {
+
+    protected PatternStatementImpl(
+            StmtContext<String, PatternStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, PatternStatement, EffectiveStatement<String, PatternStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.PATTERN);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public PatternStatement createDeclared(
+                StmtContext<String, PatternStatement, ?> ctx) {
+            return new PatternStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, PatternStatement> createEffective(
+                StmtContext<String, PatternStatement, EffectiveStatement<String, PatternStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public ErrorAppTagStatement getErrorAppTagStatement() {
+        return firstDeclared(ErrorAppTagStatement.class);
+    }
+
+    @Override
+    public ErrorMessageStatement getErrorMessageStatement() {
+        return firstDeclared(ErrorMessageStatement.class);
+    }
+
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/PositionStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/PositionStatementImpl.java
new file mode 100644 (file)
index 0000000..0d0de1a
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PositionStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class PositionStatementImpl extends AbstractDeclaredStatement<String>
+        implements PositionStatement {
+
+    protected PositionStatementImpl(
+            StmtContext<String, PositionStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, PositionStatement, EffectiveStatement<String, PositionStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.POSITION);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public PositionStatement createDeclared(
+                StmtContext<String, PositionStatement, ?> ctx) {
+            return new PositionStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, PositionStatement> createEffective(
+                StmtContext<String, PositionStatement, EffectiveStatement<String, PositionStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+
+}
index eeb9824df407fc7e06aa92621403f73be5f87fdb..02e94621919299b71a9cbfec5d9330c854fa086c 100644 (file)
@@ -7,6 +7,8 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.PrefixEffectiveStatementImpl;
+
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
@@ -34,7 +36,7 @@ public class PrefixStatementImpl extends AbstractDeclaredStatement<String> imple
 
         @Override
         public EffectiveStatement<String,PrefixStatement> createEffective(StmtContext<String, PrefixStatement,EffectiveStatement<String,PrefixStatement>> ctx) {
-            throw new UnsupportedOperationException();
+            return new PrefixEffectiveStatementImpl(ctx);
         }
     }
 
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/PresenceStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/PresenceStatementImpl.java
new file mode 100644 (file)
index 0000000..101fa1b
--- /dev/null
@@ -0,0 +1,59 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.PresenceEffectiveStatementImpl;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class PresenceStatementImpl extends AbstractDeclaredStatement<String>
+        implements PresenceStatement {
+
+    protected PresenceStatementImpl(
+            StmtContext<String, PresenceStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, PresenceStatement, EffectiveStatement<String, PresenceStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.PRESENCE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public PresenceStatement createDeclared(
+                StmtContext<String, PresenceStatement, ?> ctx) {
+            return new PresenceStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, PresenceStatement> createEffective(
+                StmtContext<String, PresenceStatement, EffectiveStatement<String, PresenceStatement>> ctx) {
+            return new PresenceEffectiveStatementImpl(ctx);
+        }
+
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RangeStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RangeStatementImpl.java
new file mode 100644 (file)
index 0000000..d57c353
--- /dev/null
@@ -0,0 +1,81 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorAppTagStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RangeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class RangeStatementImpl extends AbstractDeclaredStatement<String>
+        implements RangeStatement {
+
+    protected RangeStatementImpl(
+            StmtContext<String, RangeStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, RangeStatement, EffectiveStatement<String, RangeStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.RANGE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public RangeStatement createDeclared(
+                StmtContext<String, RangeStatement, ?> ctx) {
+            return new RangeStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, RangeStatement> createEffective(
+                StmtContext<String, RangeStatement, EffectiveStatement<String, RangeStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public ErrorAppTagStatement getErrorAppTagStatement() {
+        return firstDeclared(ErrorAppTagStatement.class);
+    }
+
+    @Override
+    public ErrorMessageStatement getErrorMessageStatement() {
+        return firstDeclared(ErrorMessageStatement.class);
+    }
+
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public String getRange() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ReferenceStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ReferenceStatementImpl.java
new file mode 100644 (file)
index 0000000..69091e8
--- /dev/null
@@ -0,0 +1,54 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ReferenceEffectiveStatementImpl;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import javax.annotation.Nonnull;
+
+public class ReferenceStatementImpl extends AbstractDeclaredStatement<String> implements ReferenceStatement {
+
+    protected ReferenceStatementImpl(
+            StmtContext<String, ReferenceStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<String,ReferenceStatement,EffectiveStatement<String,ReferenceStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.REFERENCE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return value;
+        }
+
+        @Override
+        public ReferenceStatement createDeclared(StmtContext<String, ReferenceStatement, ?> ctx) {
+            return new ReferenceStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, ReferenceStatement> createEffective(StmtContext<String, ReferenceStatement, EffectiveStatement<String, ReferenceStatement>> ctx) {
+            return new ReferenceEffectiveStatementImpl(ctx);
+        }
+    }
+
+    @Nonnull @Override
+    public String getText() {
+        return rawArgument();
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RefineStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RefineStatementImpl.java
new file mode 100644 (file)
index 0000000..73f2163
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ * <p/>
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RefineStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SchemaNodeIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nullable;
+
+public class RefineStatementImpl extends AbstractDeclaredStatement<SchemaNodeIdentifier> implements RefineStatement {
+
+    protected RefineStatementImpl(
+            StmtContext<SchemaNodeIdentifier, RefineStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends
+            AbstractStatementSupport<SchemaNodeIdentifier, RefineStatement, EffectiveStatement<SchemaNodeIdentifier, RefineStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.REFINE);
+        }
+
+        @Override
+        public SchemaNodeIdentifier parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return SchemaNodeIdentifier.create(Utils.parseXPath(ctx, value), Utils.isXPathAbsolute(value));
+        }
+
+        @Override
+        public RefineStatement createDeclared(StmtContext<SchemaNodeIdentifier, RefineStatement, ?> ctx) {
+            return new RefineStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<SchemaNodeIdentifier, RefineStatement> createEffective(StmtContext<SchemaNodeIdentifier, RefineStatement, EffectiveStatement<SchemaNodeIdentifier, RefineStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public String getTargetNode() {
+        return rawArgument();
+    }
+
+    @Nullable
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RequireInstanceStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RequireInstanceStatementImpl.java
new file mode 100644 (file)
index 0000000..2d43039
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RequireInstanceStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class RequireInstanceStatementImpl extends
+        AbstractDeclaredStatement<Boolean> implements RequireInstanceStatement {
+
+    protected RequireInstanceStatementImpl(
+            StmtContext<Boolean, RequireInstanceStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<Boolean, RequireInstanceStatement, EffectiveStatement<Boolean, RequireInstanceStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.REQUIRE_INSTANCE);
+        }
+
+        @Override
+        public Boolean parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return Boolean.valueOf(value);
+        }
+
+        @Override
+        public RequireInstanceStatement createDeclared(
+                StmtContext<Boolean, RequireInstanceStatement, ?> ctx) {
+            return new RequireInstanceStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<Boolean, RequireInstanceStatement> createEffective(
+                StmtContext<Boolean, RequireInstanceStatement, EffectiveStatement<Boolean, RequireInstanceStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public Boolean getValue() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RevisionDateStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RevisionDateStatementImpl.java
new file mode 100644 (file)
index 0000000..7918d7a
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RevisionDateStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class RevisionDateStatementImpl extends
+        AbstractDeclaredStatement<String> implements RevisionDateStatement {
+
+    protected RevisionDateStatementImpl(
+            StmtContext<String, RevisionDateStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, RevisionDateStatement, EffectiveStatement<String, RevisionDateStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.REVISION_DATE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public RevisionDateStatement createDeclared(
+                StmtContext<String, RevisionDateStatement, ?> ctx) {
+            return new RevisionDateStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, RevisionDateStatement> createEffective(
+                StmtContext<String, RevisionDateStatement, EffectiveStatement<String, RevisionDateStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getDate() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RevisionStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RevisionStatementImpl.java
new file mode 100644 (file)
index 0000000..640a24f
--- /dev/null
@@ -0,0 +1,84 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.common.SimpleDateFormatUtil;
+
+import java.text.ParseException;
+import java.util.Date;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import javax.annotation.Nullable;
+
+public class RevisionStatementImpl extends AbstractDeclaredStatement<Date>
+        implements RevisionStatement {
+
+    protected RevisionStatementImpl(
+            StmtContext<Date, RevisionStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<Date, RevisionStatement, EffectiveStatement<Date, RevisionStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.REVISION);
+        }
+
+        @Override
+        public Date parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            Date revision;
+            try {
+                revision = SimpleDateFormatUtil.getRevisionFormat()
+                        .parse(value);
+            } catch (ParseException e) {
+                throw new IllegalArgumentException(e);
+            }
+
+            return revision;
+        }
+
+        @Override
+        public RevisionStatement createDeclared(
+                StmtContext<Date, RevisionStatement, ?> ctx) {
+            return new RevisionStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<Date, RevisionStatement> createEffective(
+                StmtContext<Date, RevisionStatement, EffectiveStatement<Date, RevisionStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public Date getDate() {
+        return argument();
+    }
+
+    @Nullable
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RpcStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/RpcStatementImpl.java
new file mode 100644 (file)
index 0000000..5d68f37
--- /dev/null
@@ -0,0 +1,109 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import javax.annotation.Nullable;
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.InputStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.OutputStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.stmt.RpcStatement;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class RpcStatementImpl extends AbstractDeclaredStatement<QName>
+        implements RpcStatement {
+
+    protected RpcStatementImpl(StmtContext<QName, RpcStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, RpcStatement, EffectiveStatement<QName, RpcStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.RPC);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public RpcStatement createDeclared(
+                StmtContext<QName, RpcStatement, ?> ctx) {
+            return new RpcStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, RpcStatement> createEffective(
+                StmtContext<QName, RpcStatement, EffectiveStatement<QName, RpcStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+    @Override
+    public Collection<? extends TypedefStatement> getTypedefs() {
+        return allDeclared(TypedefStatement.class);
+    }
+
+    @Override
+    public Collection<? extends GroupingStatement> getGroupings() {
+        return allDeclared(GroupingStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public InputStatement getInput() {
+        return firstDeclared(InputStatement.class);
+    }
+
+    @Override
+    public OutputStatement getOutput() {
+        return firstDeclared(OutputStatement.class);
+    }
+
+    @Override
+    public Collection<? extends IfFeatureStatement> getIfFeatures() {
+        return allDeclared(IfFeatureStatement.class);
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/StatusStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/StatusStatementImpl.java
new file mode 100644 (file)
index 0000000..323722e
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class StatusStatementImpl extends AbstractDeclaredStatement<String>
+        implements StatusStatement {
+
+    protected StatusStatementImpl(
+            StmtContext<String, StatusStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, StatusStatement, EffectiveStatement<String, StatusStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.STATUS);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public StatusStatement createDeclared(
+                StmtContext<String, StatusStatement, ?> ctx) {
+            return new StatusStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, StatusStatement> createEffective(
+                StmtContext<String, StatusStatement, EffectiveStatement<String, StatusStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/StringRestrictionsImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/StringRestrictionsImpl.java
new file mode 100644 (file)
index 0000000..7a85c17
--- /dev/null
@@ -0,0 +1,72 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.stmt.LengthStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PatternStatement;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+
+public class StringRestrictionsImpl extends AbstractDeclaredStatement<String>
+        implements TypeStatement.StringRestrictions {
+
+    protected StringRestrictionsImpl(
+            StmtContext<String, TypeStatement.StringRestrictions, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, TypeStatement.StringRestrictions, EffectiveStatement<String, TypeStatement.StringRestrictions>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.TYPE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return value;
+        }
+
+        @Override
+        public TypeStatement.StringRestrictions createDeclared(
+                StmtContext<String, TypeStatement.StringRestrictions, ?> ctx) {
+            return new StringRestrictionsImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, TypeStatement.StringRestrictions> createEffective(
+                StmtContext<String, TypeStatement.StringRestrictions, EffectiveStatement<String, TypeStatement.StringRestrictions>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+    @Override
+    public LengthStatement getLength() {
+        return firstDeclared(LengthStatement.class);
+    }
+
+    @Override
+    public Collection<? extends PatternStatement> getPatterns() {
+        return allDeclared(PatternStatement.class);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/SubmoduleStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/SubmoduleStatementImpl.java
new file mode 100644 (file)
index 0000000..66f1c71
--- /dev/null
@@ -0,0 +1,116 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
+import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.findFirstDeclaredSubstatement;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
+import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
+import com.google.common.base.Optional;
+import java.net.URI;
+import java.util.Date;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.RevisionStatement;
+import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleIdentifierImpl;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class SubmoduleStatementImpl extends
+        AbstractRootStatement<SubmoduleStatement> implements SubmoduleStatement {
+
+    protected SubmoduleStatementImpl(
+            StmtContext<String, SubmoduleStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.SUBMODULE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public SubmoduleStatement createDeclared(
+                StmtContext<String, SubmoduleStatement, ?> ctx) {
+            return new SubmoduleStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, SubmoduleStatement> createEffective(
+                StmtContext<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+        @Override
+        public void onLinkageDeclared(
+                Mutable<String, SubmoduleStatement, EffectiveStatement<String, SubmoduleStatement>> stmt)
+                throws InferenceException, SourceException {
+
+            Optional<Date> revisionDate = Optional
+                    .fromNullable(firstAttributeOf(
+                            stmt.declaredSubstatements(),
+                            RevisionStatement.class));
+
+            ModuleIdentifier submoduleIdentifier = new ModuleIdentifierImpl(
+                    stmt.getStatementArgument(), Optional.<URI> absent(),
+                    revisionDate);
+
+            stmt.addContext(SubmoduleNamespace.class, submoduleIdentifier, stmt);
+
+            String belongsToModuleName = firstAttributeOf(
+                    stmt.declaredSubstatements(), BelongsToStatement.class);
+            StmtContext<?, ?, ?> prefixSubStmtCtx = findFirstDeclaredSubstatement(
+                    stmt, 0, BelongsToStatement.class, PrefixStatement.class);
+
+            if(prefixSubStmtCtx == null) {
+                throw new IllegalArgumentException("Prefix of belongsTo statement is missing in submodule ["
+                        + stmt.getStatementArgument() + "].");
+            }
+
+            String prefix = (String) prefixSubStmtCtx.getStatementArgument();
+
+            stmt.addToNs(BelongsToPrefixToModuleName.class, prefix,
+                    belongsToModuleName);
+        }
+
+    }
+
+    @Override
+    public String getName() {
+        return rawArgument();
+    }
+
+    @Override
+    public YangVersionStatement getYangVersion() {
+        return firstDeclared(YangVersionStatement.class);
+    }
+
+    @Override
+    public BelongsToStatement getBelongsTo() {
+        return firstDeclared(BelongsToStatement.class);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/TypeStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/TypeStatementImpl.java
new file mode 100644 (file)
index 0000000..e96db5e
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+
+public class TypeStatementImpl extends AbstractDeclaredStatement<String> implements TypeStatement {
+
+    protected TypeStatementImpl(StmtContext<String, TypeStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<String,TypeStatement,EffectiveStatement<String,TypeStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.TYPE);
+        }
+
+        @Override public String parseArgumentValue(StmtContext<?, ?, ?> ctx,
+                String value) throws SourceException {
+            return value;
+        }
+
+        @Override public TypeStatement createDeclared(
+                StmtContext<String, TypeStatement, ?> ctx) {
+            return new TypeStatementImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<String, TypeStatement> createEffective(
+                StmtContext<String, TypeStatement, EffectiveStatement<String, TypeStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull @Override
+    public String getName() {
+        return argument();
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/TypedefStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/TypedefStatementImpl.java
new file mode 100644 (file)
index 0000000..595c280
--- /dev/null
@@ -0,0 +1,94 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.TypedefStatement;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.StatusStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import javax.annotation.Nullable;
+
+public class TypedefStatementImpl extends AbstractDeclaredStatement<QName>
+        implements TypedefStatement {
+
+    protected TypedefStatementImpl(
+            StmtContext<QName, TypedefStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<QName, TypedefStatement, EffectiveStatement<QName, TypedefStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.TYPEDEF);
+        }
+
+        @Override
+        public QName parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return Utils.qNameFromArgument(ctx, value);
+        }
+
+        @Override
+        public TypedefStatement createDeclared(
+                StmtContext<QName, TypedefStatement, ?> ctx) {
+            return new TypedefStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<QName, TypedefStatement> createEffective(
+                StmtContext<QName, TypedefStatement, EffectiveStatement<QName, TypedefStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nullable
+    @Override
+    public StatusStatement getStatus() {
+        return firstDeclared(StatusStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable
+    @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+
+    @Override
+    public TypeStatement getType() {
+        return firstDeclared(TypeStatement.class);
+    }
+
+    @Override
+    public UnitsStatement getUnits() {
+        return firstDeclared(UnitsStatement.class);
+    }
+
+    @Override
+    public QName getName() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/UnionSpecificationImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/UnionSpecificationImpl.java
new file mode 100644 (file)
index 0000000..36ca6f5
--- /dev/null
@@ -0,0 +1,64 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.TypeStatement;
+
+public class UnionSpecificationImpl extends AbstractDeclaredStatement<String>
+        implements TypeStatement.UnionSpecification {
+
+    protected UnionSpecificationImpl(
+            StmtContext<String, TypeStatement.UnionSpecification, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, TypeStatement.UnionSpecification, EffectiveStatement<String, TypeStatement.UnionSpecification>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.TYPE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value)
+                throws SourceException {
+            return value;
+        }
+
+        @Override
+        public TypeStatement.UnionSpecification createDeclared(
+                StmtContext<String, TypeStatement.UnionSpecification, ?> ctx) {
+            return new UnionSpecificationImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, TypeStatement.UnionSpecification> createEffective(
+                StmtContext<String, TypeStatement.UnionSpecification, EffectiveStatement<String, TypeStatement.UnionSpecification>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+    @Override
+    public Collection<? extends TypeStatement> getTypes() {
+        return allDeclared(TypeStatement.class);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/UnitsStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/UnitsStatementImpl.java
new file mode 100644 (file)
index 0000000..2778d3f
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.UnitsStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class UnitsStatementImpl extends AbstractDeclaredStatement<String>
+        implements UnitsStatement {
+
+    protected UnitsStatementImpl(StmtContext<String, UnitsStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, UnitsStatement, EffectiveStatement<String, UnitsStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.UNITS);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public UnitsStatement createDeclared(
+                StmtContext<String, UnitsStatement, ?> ctx) {
+            return new UnitsStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, UnitsStatement> createEffective(
+                StmtContext<String, UnitsStatement, EffectiveStatement<String, UnitsStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getName() {
+        return argument();
+    }
+
+}
index a9bab4de76eca85c0fcb34443526d4e38736a172..e1058c9f98a841ce11e97e3cec0baf0e43c58257 100644 (file)
@@ -7,6 +7,11 @@
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
+import static org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase.FULL_DECLARATION;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.UsesEffectiveStatementImpl;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import java.util.Collection;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
@@ -16,7 +21,6 @@ import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
 import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
 import org.opendaylight.yangtools.yang.model.api.stmt.AugmentStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
-import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.RefineStatement;
@@ -30,18 +34,17 @@ import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.InferenceAction;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelActionBuilder.Prerequisite;
-import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
-import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 
-public class UsesStatementImpl extends AbstractDeclaredStatement<QName> implements UsesStatement {
+public class UsesStatementImpl extends AbstractDeclaredStatement<QName>
+        implements UsesStatement {
 
     protected UsesStatementImpl(StmtContext<QName, UsesStatement, ?> context) {
         super(context);
     }
 
-    public static class Definition extends
+    public static class Definition
+            extends
             AbstractStatementSupport<QName, UsesStatement, EffectiveStatement<QName, UsesStatement>> {
 
         public Definition() {
@@ -53,30 +56,37 @@ public class UsesStatementImpl extends AbstractDeclaredStatement<QName> implemen
             return Utils.qNameFromArgument(ctx, value);
         }
 
-        public void onStatementDeclared(Mutable<QName, UsesStatement, ?> usesNode) throws InferenceException {
-            ModelActionBuilder modifier = usesNode.newInferenceAction(ModelProcessingPhase.EFFECTIVE_MODEL);
+        @Override
+        public void onFullDefinitionDeclared(final StmtContext.Mutable<QName,UsesStatement,EffectiveStatement<QName,UsesStatement>> usesNode) throws InferenceException ,SourceException {
+
+            ModelActionBuilder usesAction = usesNode.newInferenceAction(FULL_DECLARATION);
             final QName groupingName = usesNode.getStatementArgument();
-            final StatementSourceReference usesSource = usesNode.getStatementSourceReference();
-            final Prerequisite<?> targetPre = modifier.mutatesEffectiveCtx(usesNode.getParentContext());
-            final Prerequisite<EffectiveStatement<QName, GroupingStatement>> sourcePre = modifier.requiresEffective(
-                    usesNode, GroupingNamespace.class, groupingName);
 
-            modifier.apply(new InferenceAction() {
+            final Prerequisite<StmtContext<?, ?, ?>> sourceGroupingPre = usesAction.requiresCtx(usesNode, GroupingNamespace.class, groupingName, FULL_DECLARATION);
+            final Prerequisite< ?extends StmtContext.Mutable<?,?,?>> targetNodePre = usesAction.mutatesCtx(usesNode.getParentContext(), FULL_DECLARATION);
+
+            usesAction.apply(new InferenceAction() {
 
                 @Override
                 public void apply() throws InferenceException {
-                    Mutable<?, ?, ?> targetCtx = (Mutable<?, ?, ?>) targetPre.get();
-                    EffectiveStatement<QName, GroupingStatement> source = sourcePre.get();
-
-                    throw new UnsupportedOperationException("Copy of not not yet implemented.");
+                    StatementContextBase<?, ?, ?> targetNodeStmtCtx =  (StatementContextBase<?, ?, ?>) targetNodePre.get();
+                    StatementContextBase<?, ?, ?> sourceGrpStmtCtx = (StatementContextBase<?, ?, ?>) sourceGroupingPre.get();
+
+                    try {
+                        GroupingUtils.copyFromSourceToTarget(sourceGrpStmtCtx,targetNodeStmtCtx);
+                        GroupingUtils.resolveUsesNode(usesNode, targetNodeStmtCtx);
+                    } catch (SourceException e) {
+                        // TODO Auto-generated catch block
+                        e.printStackTrace();
+                    }
                 }
 
                 @Override
                 public void prerequisiteFailed(Collection<? extends Prerequisite<?>> failed) throws InferenceException {
-                    if(failed.contains(sourcePre)) {
-                        throw new InferenceException("Grouping " + groupingName + "was not found.", usesSource);
+                    if(failed.contains(sourceGroupingPre)) {
+                        throw new InferenceException("Grouping " + groupingName + " was not resoled.", usesNode.getStatementSourceReference());
                     }
-                    throw new InferenceException("Unknown error occured.", usesSource);
+                    throw new InferenceException("Unknown error occured.", usesNode.getStatementSourceReference());
                 }
 
             });
@@ -84,14 +94,15 @@ public class UsesStatementImpl extends AbstractDeclaredStatement<QName> implemen
         }
 
         @Override
-        public UsesStatement createDeclared(StmtContext<QName, UsesStatement, ?> ctx) {
+        public UsesStatement createDeclared(
+                StmtContext<QName, UsesStatement, ?> ctx) {
             return new UsesStatementImpl(ctx);
         }
 
         @Override
         public EffectiveStatement<QName, UsesStatement> createEffective(
                 StmtContext<QName, UsesStatement, EffectiveStatement<QName, UsesStatement>> ctx) {
-            throw new UnsupportedOperationException("Not implemented yet.");
+            return new UsesEffectiveStatementImpl(ctx);
         }
 
     }
index 101038d94fcb377ae3cb1ebc4bbc136f2e57a0e2..aa9899850b4569c68892eb0ef08dcc2303775f7f 100644 (file)
  */
 package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
+import static org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils.firstAttributeOf;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.List;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+import org.antlr.v4.runtime.tree.TerminalNode;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser;
 import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.SubmoduleStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
+import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
+import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleIdentifierToModuleQName;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
 import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import com.google.common.base.CharMatcher;
+import com.google.common.base.Splitter;
 
 public class Utils {
 
+    private static final CharMatcher DOUBLE_QUOTE_MATCHER = CharMatcher.is('"');
+    private static final CharMatcher SINGLE_QUOTE_MATCHER = CharMatcher.is('\'');
+
+    private static final char SEPARATOR_QNAME = '/';
+
+    private static final String REGEX_PATH_ABS = "/[^/].+";
+    private static final String REGEX_PATH_REL1 = "\\.\\.?\\s*/(.+)";
+    private static final String REGEX_PATH_REL2 = "//.*";
+
+    public static final StatementSourceReference CONTEXT_REF = new StatementSourceReference() {
+
+        @Override
+        public StatementSource getStatementSource() {
+            return StatementSource.CONTEXT;
+        }
+    };
+
+    public static void validateXPath(String path) {
+
+        final XPath xPath = XPathFactory.newInstance().newXPath();
+
+        try {
+            xPath.compile(path);
+        } catch (XPathExpressionException e) {
+            throw new IllegalArgumentException("An argument is not valid XPath string");
+        }
+    }
+
+    public static boolean isXPathAbsolute(String path) {
+
+        validateXPath(path);
+
+        return path.matches(REGEX_PATH_ABS);
+    }
+
+    public static Iterable<QName> parseXPath(StmtContext<?, ?, ?> ctx, String path) {
+
+        validateXPath(path);
 
-    public static QName qNameFromArgument(StmtContext<?,?,?> ctx, String value) {
-        // TODO: Implement real parsing
-        String prefix = "";
-        ctx.getFromNamespace(PrefixToModule.class, prefix);
+        Splitter keySplitter = Splitter.on(SEPARATOR_QNAME).omitEmptyStrings().trimResults();
+        List<String> nodeNames = keySplitter.splitToList(path);
+        List<QName> qNames = new ArrayList<>();
 
-        return QName.create(value);
+        for (String nodeName : nodeNames) {
+            try {
+                final QName qName = Utils.qNameFromArgument(ctx, nodeName);
+                qNames.add(qName);
+            } catch (Exception e) {
+                throw new IllegalArgumentException(e);
+            }
+        }
+
+        return qNames;
+    }
+
+    public static Iterable<QName> parseAugmentPath(StmtContext<?, ?, ?> ctx, String path) {
+
+        if (path.matches(REGEX_PATH_REL1) || path.matches(REGEX_PATH_REL2)) {
+            throw new IllegalArgumentException(
+                    "An argument for augment can be only absolute path; or descendant if used in uses");
+        }
+
+        return parseXPath(ctx, path);
+    }
+
+    public static String stringFromStringContext(final YangStatementParser.ArgumentContext context) {
+        StringBuilder sb = new StringBuilder();
+        List<TerminalNode> strings = context.STRING();
+        if (strings.size() == 0) {
+            strings = Arrays.asList(context.IDENTIFIER());
+        }
+        for (TerminalNode stringNode : strings) {
+            final String str = stringNode.getText();
+            char firstChar = str.charAt(0);
+            final CharMatcher quoteMatcher;
+            if (SINGLE_QUOTE_MATCHER.matches(firstChar)) {
+                quoteMatcher = SINGLE_QUOTE_MATCHER;
+            } else if (DOUBLE_QUOTE_MATCHER.matches(firstChar)) {
+                quoteMatcher = DOUBLE_QUOTE_MATCHER;
+            } else {
+                sb.append(str);
+                continue;
+            }
+            sb.append(quoteMatcher.removeFrom(str.substring(1, str.length() - 1)));
+        }
+        return sb.toString();
     }
 
+    public static QName qNameFromArgument(StmtContext<?, ?, ?> ctx, String value) {
+
+        String prefix = null;
+        QNameModule qNameModule = null;
+        try {
+            qNameModule = QNameModule.create(new URI(""), new Date(0));
+        } catch (URISyntaxException e) {
+            e.printStackTrace();
+        }
+        String localName = null;
 
+        String[] namesParts = value.split(":");
+        switch (namesParts.length) {
+        case 1:
+            localName = namesParts[0];
+
+            if (StmtContextUtils.producesDeclared(ctx.getRoot(), ModuleStatement.class)) {
+                prefix = firstAttributeOf(ctx.getRoot().declaredSubstatements(), PrefixStatement.class);
+                qNameModule = ctx.getFromNamespace(PrefixToModule.class, prefix);
+
+            } else if (StmtContextUtils.producesDeclared(ctx.getRoot(), SubmoduleStatement.class)) {
+                String belongsToModuleName = firstAttributeOf(ctx.getRoot().declaredSubstatements(),
+                        BelongsToStatement.class);
+                qNameModule = ctx.getFromNamespace(ModuleNameToModuleQName.class, belongsToModuleName);
+            }
+            break;
+        case 2:
+            prefix = namesParts[0];
+            localName = namesParts[1];
+
+            ModuleIdentifier impModIdentifier = ctx.getRoot().getFromNamespace(ImpPrefixToModuleIdentifier.class,
+                    prefix);
+            qNameModule = ctx.getFromNamespace(ModuleIdentifierToModuleQName.class, impModIdentifier);
+
+            if (qNameModule == null && StmtContextUtils.producesDeclared(ctx.getRoot(), SubmoduleStatement.class)) {
+                String moduleName = ctx.getRoot().getFromNamespace(BelongsToPrefixToModuleName.class, prefix);
+                qNameModule = ctx.getFromNamespace(ModuleNameToModuleQName.class, moduleName);
+            }
+
+            break;
+        default:
+            break;
+        }
+
+        return QName.create(qNameModule, localName);
+    }
 }
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ValueStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/ValueStatementImpl.java
new file mode 100644 (file)
index 0000000..5c4dfb7
--- /dev/null
@@ -0,0 +1,56 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ValueStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class ValueStatementImpl extends AbstractDeclaredStatement<String>
+        implements ValueStatement {
+
+    protected ValueStatementImpl(StmtContext<String, ValueStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<String, ValueStatement, EffectiveStatement<String, ValueStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.VALUE);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return value;
+        }
+
+        @Override
+        public ValueStatement createDeclared(
+                StmtContext<String, ValueStatement, ?> ctx) {
+            return new ValueStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, ValueStatement> createEffective(
+                StmtContext<String, ValueStatement, EffectiveStatement<String, ValueStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public String getValue() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/WhenStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/WhenStatementImpl.java
new file mode 100644 (file)
index 0000000..f647226
--- /dev/null
@@ -0,0 +1,69 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.RevisionAwareXPath;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.WhenStatement;
+import org.opendaylight.yangtools.yang.model.util.RevisionAwareXPathImpl;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+public class WhenStatementImpl extends AbstractDeclaredStatement<RevisionAwareXPath> implements
+        WhenStatement {
+
+    protected WhenStatementImpl(
+            StmtContext<RevisionAwareXPath, WhenStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<RevisionAwareXPath,WhenStatement,EffectiveStatement<RevisionAwareXPath,WhenStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.WHEN);
+        }
+
+        @Override public RevisionAwareXPath parseArgumentValue(
+                StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return new RevisionAwareXPathImpl(value, false);
+        }
+
+        @Override public WhenStatement createDeclared(
+                StmtContext<RevisionAwareXPath, WhenStatement, ?> ctx) {
+            return new WhenStatementImpl(ctx);
+        }
+
+        @Override public EffectiveStatement<RevisionAwareXPath, WhenStatement> createEffective(
+                StmtContext<RevisionAwareXPath, WhenStatement, EffectiveStatement<RevisionAwareXPath, WhenStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull @Override
+    public RevisionAwareXPath getCondition() {
+        return argument();
+    }
+
+    @Nullable @Override
+    public DescriptionStatement getDescription() {
+        return firstDeclared(DescriptionStatement.class);
+    }
+
+    @Nullable @Override
+    public ReferenceStatement getReference() {
+        return firstDeclared(ReferenceStatement.class);
+    }
+}
index 4dd537714d67401ce751ea0e95aaa1f43d9ee625..34fc0fccfd95ad8cd8a679dd3c21ac935280f717 100644 (file)
@@ -9,7 +9,17 @@ package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
 
 import static org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.global;
 import static org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.sourceLocal;
+import static org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.treeScoped;
 
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleQNameToModuleName;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.parser.spi.GroupingNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
+import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleIdentifierToModuleQName;
+import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToModuleIdentifier;
 import com.google.common.collect.ImmutableMap;
 import java.util.Map;
 import org.opendaylight.yangtools.yang.parser.spi.ModuleNamespace;
@@ -22,17 +32,102 @@ public final class YangInferencePipeline {
 
     public static final StatementSupportBundle LINKAGE_BUNDLE = StatementSupportBundle.builder()
             .addSupport(new ModuleStatementSupport())
+            .addSupport(new SubmoduleStatementImpl.Definition())
             .addSupport(new NamespaceStatementImpl.Definition())
             .addSupport(new ImportStatementDefinition())
+            .addSupport(new IncludeStatementImpl.Definition())
             .addSupport(new PrefixStatementImpl.Definition())
+            .addSupport(new YangVersionStatementImpl.Definition())
+            .addSupport(new DescriptionStatementImpl.Definition())
+            .addSupport(new RevisionStatementImpl.Definition())
+            .addSupport(new RevisionDateStatementImpl.Definition())
+            .addSupport(new ReferenceStatementImpl.Definition())
+            .addSupport(new ContactStatementImpl.Definition())
+            .addSupport(new OrganizationStatementImpl.Definition())
+            .addSupport(new BelongsToStatementImpl.Definition())
             .addSupport(global(ModuleNamespace.class))
+            .addSupport(global(SubmoduleNamespace.class))
             .addSupport(global(NamespaceToModule.class))
+            .addSupport(global(ModuleNameToModuleQName.class))
+            .addSupport(global(ModuleQNameToModuleName.class))
+            .addSupport(global(PrefixToModule.class))
+            .addSupport(global(ModuleIdentifierToModuleQName.class))
             .addSupport(sourceLocal(ImportedModuleContext.class))
-            .build();
+            .addSupport(sourceLocal(IncludedModuleContext.class))
+            .addSupport(sourceLocal(ImpPrefixToModuleIdentifier.class))
+            .addSupport(sourceLocal(BelongsToPrefixToModuleName.class))
+            //.addSupport(global(ImpPrefixToModuleIdentifier.class))
+                    .build();
 
-    private static final StatementSupportBundle STMT_DEF_BUNDLE = StatementSupportBundle.derivedFrom(LINKAGE_BUNDLE).build();
+    private static final StatementSupportBundle STMT_DEF_BUNDLE = StatementSupportBundle.
+            derivedFrom(LINKAGE_BUNDLE)
+            .addSupport(new YinElementStatementImpl.Definition())
+            .addSupport(new ArgumentStatementImpl.Definition())
+            .addSupport(new ExtensionStatementImpl.Definition())
+            //TODO: implement extension support in SourceSpecificContext
+            // in order to prepare statements for full declaration phase,
+            // when those ones are read.
+            .build();
 
-    private static final StatementSupportBundle FULL_DECL_BUNDLE = StatementSupportBundle.derivedFrom(STMT_DEF_BUNDLE).build();
+    private static final StatementSupportBundle FULL_DECL_BUNDLE = StatementSupportBundle.
+            derivedFrom(STMT_DEF_BUNDLE)
+            .addSupport(new ContainerStatementImpl.Definition())
+            .addSupport(new LeafStatementImpl.Definition())
+            .addSupport(new TypeStatementImpl.Definition())
+            .addSupport(new ConfigStatementImpl.Definition())
+            .addSupport(new DeviationStatementImpl.Definition())
+            .addSupport(new DeviateStatementImpl.Definition())
+            .addSupport(new ChoiceStatementImpl.Definition())
+            .addSupport(new CaseStatementImpl.Definition())
+            .addSupport(new DefaultStatementImpl.Definition())
+            .addSupport(new MustStatementImpl.Definition())
+            .addSupport(new MandatoryStatementImpl.Definition())
+            .addSupport(new TypedefStatementImpl.Definition())
+            .addSupport(new AnyxmlStatementImpl.Definition())
+            .addSupport(new IfFeatureStatementImpl.Definition())
+            .addSupport(new UsesStatementImpl.Definition())
+            .addSupport(new GroupingStatementImpl.Definition())
+            .addSupport(treeScoped(GroupingNamespace.class)) //treeScoped
+            .addSupport(new StatusStatementImpl.Definition())
+            .addSupport(new ErrorMessageStatementImpl.Definition())
+            .addSupport(new ErrorAppTagStatementImpl.Definition())
+            .addSupport(new LeafListStatementImpl.Definition())
+            .addSupport(new ListStatementImpl.Definition())
+            .addSupport(new PresenceStatementImpl.Definition())
+            .addSupport(new KeyStatementImpl.Definition())
+            .addSupport(new MaxElementsStatementImpl.Definition())
+            .addSupport(new MinElementsStatementImpl.Definition())
+            .addSupport(new OrderedByStatementImpl.Definition())
+            .addSupport(new WhenStatementImpl.Definition())
+            .addSupport(new AugmentStatementImpl.Definition())
+            .addSupport(new RefineStatementImpl.Definition())
+            .addSupport(new IdentityStatementImpl.Definition())
+            .addSupport(new BaseStatementImpl.Definition())
+            .addSupport(new FractionDigitsStatementImpl.Definition())
+            .addSupport(new EnumStatementImpl.Definition())
+            .addSupport(new FeatureStatementImpl.Definition())
+            .addSupport(new RpcStatementImpl.Definition())
+            .addSupport(new InputStatementImpl.Definition())
+            .addSupport(new OutputStatementImpl.Definition())
+            .addSupport(new LengthStatementImpl.Definition())
+            .addSupport(new NotificationStatementImpl.Definition())
+            .addSupport(new PatternStatementImpl.Definition())
+            .addSupport(new PositionStatementImpl.Definition())
+            .addSupport(new RangeStatementImpl.Definition())
+            .addSupport(new ValueStatementImpl.Definition())
+            .addSupport(new UnitsStatementImpl.Definition())
+            .addSupport(new RequireInstanceStatementImpl.Definition())
+            //TODO: add mapping to Rfc6020Mapping class and uncomment following. Please test it.
+//            .addSupport(new EnumSpecificationImpl.Definition())
+//            .addSupport(new Decimal64SpecificationImpl.Definition())
+//            .addSupport(new IdentityRefSpecificationImpl.Definition())
+//            .addSupport(new InstanceIdentifierSpecificationImpl.Definition())
+//            .addSupport(new LeafrefSpecificationImpl.Definition())
+//            .addSupport(new NumericalRestrictionsImpl.Definition())
+//            .addSupport(new StringRestrictionsImpl.Definition())
+//            .addSupport(new UnionSpecificationImpl.Definition())
+//            .addSupport(new BitStatementImpl.Definition())
+            .build();
 
     public static final Map<ModelProcessingPhase, StatementSupportBundle> RFC6020_BUNDLES = ImmutableMap
             .<ModelProcessingPhase, StatementSupportBundle> builder()
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangStatementSourceImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangStatementSourceImpl.java
new file mode 100644 (file)
index 0000000..7e28414
--- /dev/null
@@ -0,0 +1,83 @@
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.tree.ParseTreeWalker;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementLexer;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
+import org.opendaylight.yangtools.yang.parser.impl.YangStatementParserListenerImpl;
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ *
+ * This class represents implementation of StatementStreamSource
+ * in order to emit YANG statements using supplied StatementWriter
+ *
+ */
+
+public class YangStatementSourceImpl implements StatementStreamSource {
+
+    private YangStatementParserListenerImpl yangStatementModelParser;
+    private YangStatementParser.StatementContext statementContext;
+    private ParseTreeWalker walker;
+
+    public YangStatementSourceImpl(String fileName) {
+        try {
+            statementContext = parseYangSource(loadFile(fileName));
+            walker = new ParseTreeWalker();
+            yangStatementModelParser = new YangStatementParserListenerImpl(REF);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    private StatementSourceReference REF = new StatementSourceReference() {
+
+        @Override
+        public StatementSource getStatementSource() {
+            return StatementSource.DECLARATION;
+        }
+    };
+
+    @Override
+    public void writeLinkage(StatementWriter writer, QNameToStatementDefinition stmtDef) throws SourceException {
+        yangStatementModelParser.setAttributes(writer, stmtDef);
+        walker.walk(yangStatementModelParser, statementContext);
+    }
+
+    @Override
+    public void writeLinkageAndStatementDefinitions(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes) throws SourceException {
+        yangStatementModelParser.setAttributes(writer, stmtDef, prefixes);
+        walker.walk(yangStatementModelParser, statementContext);
+    }
+
+    @Override
+    public void writeFull(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes) throws SourceException {
+        yangStatementModelParser.setAttributes(writer, stmtDef, prefixes);
+        walker.walk(yangStatementModelParser, statementContext);
+    }
+
+    private FileInputStream loadFile(String fileName) throws Exception {
+        return new FileInputStream(new File(getClass().getResource(fileName).toURI()));
+    }
+
+    private YangStatementParser.StatementContext parseYangSource(final InputStream stream) throws IOException, YangSyntaxErrorException {
+        final YangStatementLexer lexer = new YangStatementLexer(new ANTLRInputStream(stream));
+        final CommonTokenStream tokens = new CommonTokenStream(lexer);
+        final YangStatementParser parser = new YangStatementParser(tokens);
+        final YangStatementParser.StatementContext result = parser.statement();
+        return result;
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangVersionStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YangVersionStatementImpl.java
new file mode 100644 (file)
index 0000000..4ce7f43
--- /dev/null
@@ -0,0 +1,52 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.YangVersionStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+import javax.annotation.Nonnull;
+
+public class YangVersionStatementImpl extends AbstractDeclaredStatement<String> implements YangVersionStatement {
+
+    protected YangVersionStatementImpl(StmtContext<String, YangVersionStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition extends AbstractStatementSupport<String,YangVersionStatement,EffectiveStatement<String,YangVersionStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.YANG_VERSION);
+        }
+
+        @Override
+        public String parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) throws SourceException {
+            return value;
+        }
+
+        @Override
+        public YangVersionStatement createDeclared(StmtContext<String, YangVersionStatement, ?> ctx) {
+            return new YangVersionStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<String, YangVersionStatement> createEffective(StmtContext<String, YangVersionStatement, EffectiveStatement<String, YangVersionStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+    }
+
+    @Nonnull @Override
+    public String getValue() {
+        return rawArgument();
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YinElementStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/YinElementStatementImpl.java
new file mode 100644 (file)
index 0000000..5411517
--- /dev/null
@@ -0,0 +1,57 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.YinElementStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class YinElementStatementImpl extends AbstractDeclaredStatement<Boolean>
+        implements YinElementStatement {
+
+    protected YinElementStatementImpl(
+            StmtContext<Boolean, YinElementStatement, ?> context) {
+        super(context);
+    }
+
+    public static class Definition
+            extends
+            AbstractStatementSupport<Boolean, YinElementStatement, EffectiveStatement<Boolean, YinElementStatement>> {
+
+        public Definition() {
+            super(Rfc6020Mapping.YIN_ELEMENT);
+        }
+
+        @Override
+        public Boolean parseArgumentValue(StmtContext<?, ?, ?> ctx, String value) {
+            return Boolean.valueOf(value);
+        }
+
+        @Override
+        public YinElementStatement createDeclared(
+                StmtContext<Boolean, YinElementStatement, ?> ctx) {
+            return new YinElementStatementImpl(ctx);
+        }
+
+        @Override
+        public EffectiveStatement<Boolean, YinElementStatement> createEffective(
+                StmtContext<Boolean, YinElementStatement, EffectiveStatement<Boolean, YinElementStatement>> ctx) {
+            throw new UnsupportedOperationException();
+        }
+
+    }
+
+    @Override
+    public Boolean getValue() {
+        return argument();
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedDataNodeContainer.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedDataNodeContainer.java
new file mode 100644 (file)
index 0000000..78906ce
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import java.util.Map;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.DataNodeContainer;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
+
+public abstract class AbstractEffectiveDocumentedDataNodeContainer<A, D extends DeclaredStatement<A>>
+        extends AbstractEffectiveDocumentedNode<A, D> implements
+        DataNodeContainer {
+
+    private final Map<QName, DataSchemaNode> childNodes;
+    private final Set<GroupingDefinition> groupings;
+    private final Set<UsesNode> uses;
+    private final Set<TypeDefinition<?>> typeDefinitions;
+    private final Set<DataSchemaNode> publicChildNodes;
+
+    protected AbstractEffectiveDocumentedDataNodeContainer(
+            final StmtContext<A, D, ?> ctx) {
+        super(ctx);
+
+        Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+        childNodes = new HashMap<QName, DataSchemaNode>();
+        groupings = new HashSet<GroupingDefinition>();
+        uses = new HashSet<UsesNode>();
+        typeDefinitions = new HashSet<TypeDefinition<?>>();
+        publicChildNodes = new HashSet<DataSchemaNode>();
+
+        for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+            if (effectiveStatement instanceof DataSchemaNode) {
+                DataSchemaNode dataSchemaNode = (DataSchemaNode) effectiveStatement;
+
+                childNodes.put(dataSchemaNode.getQName(), dataSchemaNode);
+                publicChildNodes.add(dataSchemaNode);
+            }
+            if (effectiveStatement instanceof UsesNode) {
+                UsesNode usesNode = (UsesNode) effectiveStatement;
+                uses.add(usesNode);
+            }
+            if (effectiveStatement instanceof TypeDefinition) {
+                TypeDefinition<?> typeDef = (TypeDefinition<?>) effectiveStatement;
+                typeDefinitions.add(typeDef);
+            }
+            if (effectiveStatement instanceof GroupingDefinition) {
+                GroupingDefinition grp = (GroupingDefinition) effectiveStatement;
+                groupings.add(grp);
+            }
+        }
+    }
+
+    @Override
+    public final Set<TypeDefinition<?>> getTypeDefinitions() {
+        return typeDefinitions;
+    }
+
+    @Override
+    public final Set<DataSchemaNode> getChildNodes() {
+        return publicChildNodes;
+    }
+
+    @Override
+    public final Set<GroupingDefinition> getGroupings() {
+        return groupings;
+    }
+
+    @Override
+    public final DataSchemaNode getDataChildByName(final QName name) {
+        // Child nodes are keyed by their container name, so we can do a direct
+        // lookup
+        return childNodes.get(name);
+    }
+
+    @Override
+    public final DataSchemaNode getDataChildByName(final String name) {
+        for (DataSchemaNode node : childNodes.values()) {
+            if (node.getQName().getLocalName().equals(name)) {
+                return node;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public Set<UsesNode> getUses() {
+        return uses;
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedNode.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveDocumentedNode.java
new file mode 100644 (file)
index 0000000..5bb79d2
--- /dev/null
@@ -0,0 +1,50 @@
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.DocumentedNode;
+import org.opendaylight.yangtools.yang.model.api.Status;
+
+public abstract class AbstractEffectiveDocumentedNode<A, D extends DeclaredStatement<A>>
+        extends EffectiveStatementBase<A, D> implements DocumentedNode {
+
+    private final String description;
+    private final String reference;
+    private final Status status;
+
+    AbstractEffectiveDocumentedNode(final StmtContext<A, D, ?> ctx) {
+        super(ctx);
+
+        DescriptionEffectiveStatementImpl descStmt = firstEffective(DescriptionEffectiveStatementImpl.class);
+        if (descStmt != null) {
+            description = descStmt.argument();
+        } else
+            description = "";
+
+        ReferenceEffectiveStatementImpl refStmt = firstEffective(ReferenceEffectiveStatementImpl.class);
+        if (refStmt != null) {
+            reference = refStmt.argument();
+        } else
+            reference = "";
+
+        // :TODO
+        status = null;
+    }
+
+    @Override
+    public final String getDescription() {
+        return description;
+    }
+
+    @Override
+    public final String getReference() {
+        return reference;
+    }
+
+    @Override
+    public final Status getStatus() {
+        return status;
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveSchemaContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/AbstractEffectiveSchemaContext.java
new file mode 100644 (file)
index 0000000..85bf899
--- /dev/null
@@ -0,0 +1,266 @@
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Supplier;
+import com.google.common.collect.SetMultimap;
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeSet;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.Status;
+import org.opendaylight.yangtools.yang.model.api.TypeDefinition;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
+
+
+public abstract class AbstractEffectiveSchemaContext implements SchemaContext {
+
+    protected static final Supplier<TreeSet<Module>> MODULE_SET_SUPPLIER = new Supplier<TreeSet<Module>>() {
+        @Override
+        public TreeSet<Module> get() {
+            return new TreeSet<>(REVISION_COMPARATOR);
+        }
+    };
+
+    protected static final Comparator<Module> REVISION_COMPARATOR = new Comparator<Module>() {
+        @Override
+        public int compare(final Module o1, final Module o2) {
+            if (o2.getRevision() == null) {
+                return -1;
+            }
+
+            return o2.getRevision().compareTo(o1.getRevision());
+        }
+    };
+
+    /**
+     * @return yang sources where key is ModuleIdentifier
+     */
+    protected abstract Map<ModuleIdentifier, String> getIdentifiersToSources();
+
+    /**
+     * @return Map of modules where key is namespace
+     */
+    protected abstract SetMultimap<URI, Module> getNamespaceToModules();
+
+    /**
+     * @return Map of modules where key is name of module
+     */
+    protected abstract SetMultimap<String, Module> getNameToModules();
+
+    @Override
+    public Set<DataSchemaNode> getDataDefinitions() {
+        final Set<DataSchemaNode> dataDefs = new HashSet<>();
+        for (Module m : getModules()) {
+            dataDefs.addAll(m.getChildNodes());
+        }
+        return dataDefs;
+    }
+
+    @Override
+    public Set<NotificationDefinition> getNotifications() {
+        final Set<NotificationDefinition> notifications = new HashSet<>();
+        for (Module m : getModules()) {
+            notifications.addAll(m.getNotifications());
+        }
+        return notifications;
+    }
+
+    @Override
+    public Set<RpcDefinition> getOperations() {
+        final Set<RpcDefinition> rpcs = new HashSet<>();
+        for (Module m : getModules()) {
+            rpcs.addAll(m.getRpcs());
+        }
+        return rpcs;
+    }
+
+    @Override
+    public Set<ExtensionDefinition> getExtensions() {
+        final Set<ExtensionDefinition> extensions = new HashSet<>();
+        for (Module m : getModules()) {
+            extensions.addAll(m.getExtensionSchemaNodes());
+        }
+        return extensions;
+    }
+
+    @Override
+    public Module findModuleByName(final String name, final Date revision) {
+        for (final Module module : getNameToModules().get(name)) {
+            if (revision == null || revision.equals(module.getRevision())) {
+                return module;
+            }
+        }
+
+        return null;
+    }
+
+    @Override
+    public Set<Module> findModuleByNamespace(final URI namespace) {
+        final Set<Module> ret = getNamespaceToModules().get(namespace);
+        return ret == null ? Collections.<Module>emptySet() : ret;
+    }
+
+    @Override
+    public Module findModuleByNamespaceAndRevision(final URI namespace, final Date revision) {
+        if (namespace == null) {
+            return null;
+        }
+        for (Module module : findModuleByNamespace(namespace)) {
+            if (revision == null || revision.equals(module.getRevision())) {
+                return module;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public boolean isAugmenting() {
+        return false;
+    }
+
+    @Override
+    public boolean isAddedByUses() {
+        return false;
+    }
+
+    @Override
+    public boolean isConfiguration() {
+        return false;
+    }
+
+    @Override
+    public ConstraintDefinition getConstraints() {
+        return null;
+    }
+
+    @Override
+    public QName getQName() {
+        return SchemaContext.NAME;
+    }
+
+    @Override
+    public SchemaPath getPath() {
+        return SchemaPath.ROOT;
+    }
+
+    @Override
+    public String getDescription() {
+        return null;
+    }
+
+    @Override
+    public String getReference() {
+        return null;
+    }
+
+    @Override
+    public Status getStatus() {
+        return Status.CURRENT;
+    }
+
+    @Override
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+        final List<UnknownSchemaNode> result = new ArrayList<>();
+        for (Module module : getModules()) {
+            result.addAll(module.getUnknownSchemaNodes());
+        }
+        return Collections.unmodifiableList(result);
+    }
+
+    @Override
+    public Set<TypeDefinition<?>> getTypeDefinitions() {
+        final Set<TypeDefinition<?>> result = new LinkedHashSet<>();
+        for (Module module : getModules()) {
+            result.addAll(module.getTypeDefinitions());
+        }
+        return Collections.unmodifiableSet(result);
+    }
+
+    @Override
+    public Set<DataSchemaNode> getChildNodes() {
+        final Set<DataSchemaNode> result = new LinkedHashSet<>();
+        for (Module module : getModules()) {
+            result.addAll(module.getChildNodes());
+        }
+        return Collections.unmodifiableSet(result);
+    }
+
+    @Override
+    public Set<GroupingDefinition> getGroupings() {
+        final Set<GroupingDefinition> result = new LinkedHashSet<>();
+        for (Module module : getModules()) {
+            result.addAll(module.getGroupings());
+        }
+        return Collections.unmodifiableSet(result);
+    }
+
+    @Override
+    public DataSchemaNode getDataChildByName(final QName name) {
+        for (Module module : getModules()) {
+            final DataSchemaNode result = module.getDataChildByName(name);
+            if (result != null) {
+                return result;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public DataSchemaNode getDataChildByName(final String name) {
+        for (Module module : getModules()) {
+            final DataSchemaNode result = module.getDataChildByName(name);
+            if (result != null) {
+                return result;
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public Set<UsesNode> getUses() {
+        return Collections.emptySet();
+    }
+
+    @Override
+    public boolean isPresenceContainer() {
+        return false;
+    }
+
+    @Override
+    public Set<AugmentationSchema> getAvailableAugmentations() {
+        return Collections.emptySet();
+    }
+
+    //FIXME: should work for submodules too
+    @Override
+    public Set<ModuleIdentifier> getAllModuleIdentifiers() {
+        return getIdentifiersToSources().keySet();
+    }
+
+    @Override
+    public Optional<String> getModuleSource(final ModuleIdentifier moduleIdentifier) {
+        String maybeSource = getIdentifiersToSources().get(moduleIdentifier);
+        return Optional.fromNullable(maybeSource);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContainerEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ContainerEffectiveStatementImpl.java
new file mode 100644 (file)
index 0000000..2c5b9c9
--- /dev/null
@@ -0,0 +1,168 @@
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.HashSet;
+
+import java.util.LinkedList;
+import java.util.Collection;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.model.api.stmt.ContainerStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import com.google.common.base.Optional;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.ConstraintDefinition;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DerivableSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class ContainerEffectiveStatementImpl extends
+        AbstractEffectiveDocumentedDataNodeContainer<QName, ContainerStatement>
+        implements ContainerSchemaNode, DerivableSchemaNode {
+    private final QName qname;
+    private final SchemaPath path;
+
+    boolean augmenting;
+    boolean addedByUses;
+    boolean configuration;
+    ContainerSchemaNode original;
+    ConstraintDefinition constraints;
+
+    boolean presence;
+
+    private Set<AugmentationSchema> augmentations;
+    private List<UnknownSchemaNode> unknownNodes;
+
+    public ContainerEffectiveStatementImpl(
+            StmtContext<QName, ContainerStatement, EffectiveStatement<QName, ContainerStatement>> ctx) {
+        super(ctx);
+        qname = ctx.getStatementArgument();
+
+        initSubstatementCollections();
+        initPresence();
+
+        // :TODO init other fields
+        path = null;
+
+    }
+
+    private void initPresence() {
+        presence = (firstEffective(PresenceEffectiveStatementImpl.class) == null) ? false
+                : true;
+    }
+
+    private void initSubstatementCollections() {
+        Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+        unknownNodes = new LinkedList<UnknownSchemaNode>();
+        augmentations = new HashSet<AugmentationSchema>();
+
+        for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+            if (effectiveStatement instanceof UnknownSchemaNode) {
+                UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+                unknownNodes.add(unknownNode);
+            }
+            if (effectiveStatement instanceof AugmentationSchema) {
+                AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
+                augmentations.add(augmentationSchema);
+            }
+        }
+
+        // :TODO other substatement collections ...
+    }
+
+    @Override
+    public QName getQName() {
+        return qname;
+    }
+
+    @Override
+    public SchemaPath getPath() {
+        return path;
+    }
+
+    @Override
+    public boolean isAugmenting() {
+        return augmenting;
+    }
+
+    @Override
+    public boolean isAddedByUses() {
+        return addedByUses;
+    }
+
+    @Override
+    public Optional<ContainerSchemaNode> getOriginal() {
+        return Optional.fromNullable(original);
+    }
+
+    @Override
+    public boolean isConfiguration() {
+        return configuration;
+    }
+
+    @Override
+    public ConstraintDefinition getConstraints() {
+        return constraints;
+    }
+
+    @Override
+    public Set<AugmentationSchema> getAvailableAugmentations() {
+        return augmentations;
+    }
+
+    @Override
+    public boolean isPresenceContainer() {
+        return presence;
+    }
+
+    @Override
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+        return unknownNodes;
+    }
+
+    @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());
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        ContainerEffectiveStatementImpl other = (ContainerEffectiveStatementImpl) 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;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        return "container " + qname.getLocalName();
+    }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DescriptionEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/DescriptionEffectiveStatementImpl.java
new file mode 100644 (file)
index 0000000..9e74771
--- /dev/null
@@ -0,0 +1,21 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
+
+public class DescriptionEffectiveStatementImpl extends EffectiveStatementBase<String, DescriptionStatement>  {
+
+    public DescriptionEffectiveStatementImpl(
+            StmtContext<String, DescriptionStatement, ?> ctx) {
+        super(ctx);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveSchemaContext.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveSchemaContext.java
new file mode 100644 (file)
index 0000000..9155c0d
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.HashSet;
+import com.google.common.collect.ImmutableList;
+import java.util.List;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.ImmutableSetMultimap;
+import com.google.common.collect.Multimaps;
+import com.google.common.collect.SetMultimap;
+import java.net.URI;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+
+public class EffectiveSchemaContext extends AbstractEffectiveSchemaContext {
+
+    private  final Map<ModuleIdentifier, String> identifiersToSources;
+    private  final SetMultimap<URI, Module> namespaceToModules;
+    private  final SetMultimap<String, Module> nameToModules;
+    private  final Set<Module> modules;
+
+
+    private final ImmutableList<DeclaredStatement<?>> rootDeclaredStatements;
+    private final ImmutableList<EffectiveStatement<?,?>> rootEffectiveStatements;
+
+    public EffectiveSchemaContext(List<DeclaredStatement<?>> rootDeclaredStatements, List<EffectiveStatement<?,?>> rootEffectiveStatements) {
+        this.rootDeclaredStatements = ImmutableList.copyOf(rootDeclaredStatements);
+        this.rootEffectiveStatements = ImmutableList.copyOf(rootEffectiveStatements);
+
+        HashSet<Module> modules = new HashSet<Module>();
+        for (EffectiveStatement<?, ?> rootEffectiveStatement : rootEffectiveStatements) {
+            if(rootEffectiveStatement instanceof Module) {
+                Module module = (Module) rootEffectiveStatement;
+                modules.add(module);
+            }
+        }
+        this.modules = ImmutableSet.copyOf(modules);
+
+       final SetMultimap<URI, Module> nsMap = Multimaps.newSetMultimap(
+               new TreeMap<URI, Collection<Module>>(), MODULE_SET_SUPPLIER);
+       final SetMultimap<String, Module> nameMap = Multimaps.newSetMultimap(
+               new TreeMap<String, Collection<Module>>(), MODULE_SET_SUPPLIER);
+
+       for (Module m : modules) {
+           nameMap.put(m.getName(), m);
+           nsMap.put(m.getNamespace(), m);
+       }
+
+       namespaceToModules = ImmutableSetMultimap.copyOf(nsMap);
+       nameToModules = ImmutableSetMultimap.copyOf(nameMap);
+
+       //:TODO
+       //this.identifiersToSources = ImmutableMap.copyOf(identifiersToSources);
+       this.identifiersToSources = null;
+
+    }
+
+    public ImmutableList<DeclaredStatement<?>> getRootDeclaredStatements() {
+        return rootDeclaredStatements;
+    }
+
+    public ImmutableList<EffectiveStatement<?,?>> getRootEffectiveStatements() {
+        return rootEffectiveStatements;
+    }
+
+    @Override
+    protected Map<ModuleIdentifier, String> getIdentifiersToSources(){
+
+        return identifiersToSources;
+    }
+
+    @Override
+    public Set<Module> getModules(){
+
+        return modules;
+    }
+
+    @Override
+    protected SetMultimap<URI, Module> getNamespaceToModules() {
+
+        return namespaceToModules;
+    }
+
+    @Override
+    protected SetMultimap<String, Module> getNameToModules() {
+
+        return nameToModules;
+    }
+
+    @Override
+    public String toString() {
+
+        return String.format("SchemaContextImpl{modules=%s}", modules);
+    }
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/EffectiveStatementBase.java
new file mode 100644 (file)
index 0000000..804be7b
--- /dev/null
@@ -0,0 +1,160 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collections;
+
+import java.util.NoSuchElementException;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import com.google.common.collect.Collections2;
+import com.google.common.base.Predicates;
+import com.google.common.collect.Iterables;
+import java.util.LinkedList;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.StatementContextBase;
+import com.google.common.collect.FluentIterable;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
+import com.google.common.collect.ImmutableList;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import java.util.Collection;
+import java.util.Map;
+import org.opendaylight.yangtools.yang.model.api.meta.IdentifierNamespace;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+
+abstract public class EffectiveStatementBase<A, D extends DeclaredStatement<A>>
+        implements EffectiveStatement<A, D> {
+
+    private final StmtContext<A, D, ?> stmtCtx;
+    private final ImmutableList<? extends EffectiveStatement<?, ?>> substatements;
+    private final StatementSource statementSource;
+    private final StatementDefinition statementDefinition;
+    private D declaredInstance;
+
+    private final A argument;
+
+    public EffectiveStatementBase(StmtContext<A, D, ?> ctx) {
+
+        this.stmtCtx = ctx;
+        this.statementDefinition = ctx.getPublicDefinition();
+        this.argument = ctx.getStatementArgument();
+        this.statementSource = ctx.getStatementSource();
+
+        Collection<StatementContextBase<?, ?, ?>> declaredSubstatements = ctx
+                .declaredSubstatements();
+        Collection<StatementContextBase<?, ?, ?>> effectiveSubstatements = ctx
+                .effectiveSubstatements();
+
+        Collection<StatementContextBase<?, ?, ?>> substatements = new LinkedList<StatementContextBase<?, ?, ?>>();
+        substatements.addAll(declaredSubstatements);
+        substatements.addAll(effectiveSubstatements);
+
+        this.substatements = FluentIterable.from(substatements)
+                .transform(StmtContextUtils.buildEffective()).toList();
+    }
+
+    @Override
+    public StatementDefinition statementDefinition() {
+        return statementDefinition;
+    }
+
+    @Override
+    public A argument() {
+        return argument;
+    }
+
+    @Override
+    public StatementSource getStatementSource() {
+        return statementSource;
+    }
+
+    @Override
+    public D getDeclared() {
+        if (declaredInstance == null) {
+            declaredInstance = stmtCtx.buildDeclared();
+        }
+
+        return declaredInstance;
+    }
+
+    // public <K, V, N extends IdentifierNamespace<? super K, ? extends V>> V
+    // get(
+    @Override
+    public <K, V, N extends IdentifierNamespace<K, V>> V get(
+            Class<N> namespace, K identifier) {
+        return stmtCtx.getFromNamespace(namespace, identifier);
+    }
+
+    @Override
+    public <K, V, N extends IdentifierNamespace<K, V>> Map<K, V> getAll(
+            Class<N> namespace) {
+        return (Map<K, V>) stmtCtx.getAllFromNamespace(namespace);
+    }
+
+    @Override
+    public Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements() {
+        return substatements;
+    }
+
+    public StmtContext<A, D, ?> getStatementContext() {
+        return stmtCtx;
+    }
+
+    protected final <S extends EffectiveStatement<?, ?>> S firstEffective(
+            Class<S> type) {
+        S result = null;
+        try {
+            result = type.cast(Iterables.find(substatements,
+                    Predicates.instanceOf(type)));
+        } catch (NoSuchElementException e) {
+            result = null;
+        }
+        return result;
+    }
+
+    @SuppressWarnings("unchecked")
+    protected final <S extends EffectiveStatement<?, ?>> Collection<? extends S> allEffective(
+            Class<S> type) {
+        Collection<? extends S> result = null;
+
+        try {
+            result = Collection.class.cast(Collections2.filter(substatements,
+                    Predicates.instanceOf(type)));
+        } catch (NoSuchElementException e) {
+            result = Collections.EMPTY_LIST;
+        }
+        return result;
+    }
+
+    protected final <S extends SchemaNode> S firstSchemaNode(Class<S> type) {
+        S result = null;
+        try {
+            result = type.cast(Iterables.find(substatements,
+                    Predicates.instanceOf(type)));
+        } catch (NoSuchElementException e) {
+            result = null;
+        }
+        return result;
+    }
+
+    @SuppressWarnings("unchecked")
+    protected final <S extends SchemaNode> Collection<? extends S> allSchemaNodes(
+            Class<S> type) {
+        Collection<? extends S> result = null;
+
+        try {
+            result = Collection.class.cast(Collections2.filter(substatements,
+                    Predicates.instanceOf(type)));
+        } catch (NoSuchElementException e) {
+            result = Collections.EMPTY_LIST;
+        }
+        return result;
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/GroupingEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/GroupingEffectiveStatementImpl.java
new file mode 100644 (file)
index 0000000..e7cbe4c
--- /dev/null
@@ -0,0 +1,115 @@
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.util.Collection;
+import java.util.LinkedList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.stmt.GroupingStatement;
+import java.util.List;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+
+public class GroupingEffectiveStatementImpl extends
+        AbstractEffectiveDocumentedDataNodeContainer<QName, GroupingStatement>
+        implements GroupingDefinition {
+    private final QName qname;
+    private final SchemaPath path;
+
+    private boolean addedByUses;
+    private List<UnknownSchemaNode> unknownNodes;
+
+    public GroupingEffectiveStatementImpl(
+            StmtContext<QName, GroupingStatement, EffectiveStatement<QName, GroupingStatement>> ctx) {
+        super(ctx);
+
+        qname = ctx.getStatementArgument();
+        // :TODO init other fields
+        path = null;
+
+        initSubstatementCollections();
+    }
+
+    private void initSubstatementCollections() {
+        Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+        unknownNodes = new LinkedList<UnknownSchemaNode>();
+
+        for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+            if (effectiveStatement instanceof UnknownSchemaNode) {
+                UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+                unknownNodes.add(unknownNode);
+            }
+        }
+
+    }
+
+    @Override
+    public QName getQName() {
+        return qname;
+    }
+
+    @Override
+    public SchemaPath getPath() {
+        return path;
+    }
+
+    @Override
+    public boolean isAddedByUses() {
+        return addedByUses;
+    }
+
+    @Override
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+        return unknownNodes;
+    }
+
+    @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());
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final GroupingEffectiveStatementImpl other = (GroupingEffectiveStatementImpl) 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;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder(
+                GroupingEffectiveStatementImpl.class.getSimpleName());
+        sb.append("[");
+        sb.append("qname=").append(qname);
+        sb.append("]");
+        return sb.toString();
+    }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ModuleEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ModuleEffectiveStatementImpl.java
new file mode 100644 (file)
index 0000000..1e82cf1
--- /dev/null
@@ -0,0 +1,254 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.parser.spi.source.ModuleNameToModuleQName;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.LinkedList;
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import java.net.URI;
+import java.util.Date;
+import org.opendaylight.yangtools.yang.parser.builder.impl.ModuleImpl;
+import java.util.List;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.Deviation;
+import org.opendaylight.yangtools.yang.model.api.ExtensionDefinition;
+import org.opendaylight.yangtools.yang.model.api.FeatureDefinition;
+import org.opendaylight.yangtools.yang.model.api.IdentitySchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ModuleImport;
+import org.opendaylight.yangtools.yang.model.api.NotificationDefinition;
+import org.opendaylight.yangtools.yang.model.api.RpcDefinition;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.concepts.Immutable;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.model.api.stmt.ModuleStatement;
+
+public class ModuleEffectiveStatementImpl extends
+        AbstractEffectiveDocumentedDataNodeContainer<String, ModuleStatement>
+        implements Module, Immutable {
+
+    private QNameModule qnameModule;
+    private String name;
+    private String sourcePath;
+    private String prefix;
+    private String yangVersion;
+    private String organization;
+    private String contact;
+    private Set<ModuleImport> imports;
+    private Set<Module> submodules;
+    private Set<FeatureDefinition> features;
+    private Set<NotificationDefinition> notifications;
+    private Set<AugmentationSchema> augmentations;
+    private Set<RpcDefinition> rpcs;
+    private Set<Deviation> deviations;
+    private List<ExtensionDefinition> extensionNodes;
+    private Set<IdentitySchemaNode> identities;
+    private List<UnknownSchemaNode> unknownNodes;
+    private String source;
+
+    public ModuleEffectiveStatementImpl(
+            StmtContext<String, ModuleStatement, ?> ctx) {
+        super(ctx);
+
+        name = argument();
+        qnameModule = ctx.getFromNamespace(ModuleNameToModuleQName.class, name);
+
+        initSubstatementCollections();
+
+        // :TODO init other fields
+    }
+
+    private void initSubstatementCollections() {
+        Collection<? extends EffectiveStatement<?, ?>> effectiveSubstatements = effectiveSubstatements();
+
+        unknownNodes = new LinkedList<UnknownSchemaNode>();
+        augmentations = new HashSet<AugmentationSchema>();
+
+        for (EffectiveStatement<?, ?> effectiveStatement : effectiveSubstatements) {
+            if (effectiveStatement instanceof UnknownSchemaNode) {
+                UnknownSchemaNode unknownNode = (UnknownSchemaNode) effectiveStatement;
+                unknownNodes.add(unknownNode);
+            }
+            if (effectiveStatement instanceof AugmentationSchema) {
+                AugmentationSchema augmentationSchema = (AugmentationSchema) effectiveStatement;
+                augmentations.add(augmentationSchema);
+            }
+        }
+
+        // :TODO other substatement collections ...
+    }
+
+    @Override
+    public String getModuleSourcePath() {
+        return sourcePath;
+    }
+
+    @Override
+    public URI getNamespace() {
+        return qnameModule.getNamespace();
+    }
+
+    @Override
+    public String getName() {
+        return name;
+    }
+
+    @Override
+    public Date getRevision() {
+        return qnameModule.getRevision();
+    }
+
+    @Override
+    public String getPrefix() {
+        return prefix;
+    }
+
+    @Override
+    public String getYangVersion() {
+        return yangVersion;
+    }
+
+    @Override
+    public String getOrganization() {
+        return organization;
+    }
+
+    @Override
+    public String getContact() {
+        return contact;
+    }
+
+    @Override
+    public Set<ModuleImport> getImports() {
+        return imports;
+    }
+
+    @Override
+    public Set<Module> getSubmodules() {
+        return submodules;
+    }
+
+    @Override
+    public Set<FeatureDefinition> getFeatures() {
+        return features;
+    }
+
+    @Override
+    public Set<NotificationDefinition> getNotifications() {
+        return notifications;
+    }
+
+    @Override
+    public Set<AugmentationSchema> getAugmentations() {
+        return augmentations;
+    }
+
+    @Override
+    public Set<RpcDefinition> getRpcs() {
+        return rpcs;
+    }
+
+    @Override
+    public Set<Deviation> getDeviations() {
+        return deviations;
+    }
+
+    @Override
+    public List<ExtensionDefinition> getExtensionSchemaNodes() {
+        return extensionNodes;
+    }
+
+    @Override
+    public Set<IdentitySchemaNode> getIdentities() {
+        return identities;
+    }
+
+    @Override
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+        return unknownNodes;
+    }
+
+    @Override
+    public String getSource() {
+        return source;
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((name == null) ? 0 : name.hashCode());
+        result = prime * result
+                + ((yangVersion == null) ? 0 : yangVersion.hashCode());
+        result = prime * result + qnameModule.hashCode();
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        ModuleEffectiveStatementImpl other = (ModuleEffectiveStatementImpl) obj;
+        if (name == null) {
+            if (other.name != null) {
+                return false;
+            }
+        } else if (!name.equals(other.name)) {
+            return false;
+        }
+        if (!qnameModule.equals(other.qnameModule)) {
+            return false;
+        }
+        if (yangVersion == null) {
+            if (other.yangVersion != null) {
+                return false;
+            }
+        } else if (!yangVersion.equals(other.yangVersion)) {
+            return false;
+        }
+        return true;
+    }
+
+    // private static <T extends SchemaNode> Set<T> toImmutableSortedSet(final
+    // Set<T> original) {
+    // TreeSet<T> sorted = new TreeSet<>(Comparators.SCHEMA_NODE_COMP);
+    // sorted.addAll(original);
+    // return Collections.unmodifiableSet(sorted);
+    // }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder(ModuleImpl.class.getSimpleName());
+        sb.append("[");
+        sb.append("name=").append(name);
+        sb.append(", namespace=").append(getNamespace());
+        sb.append(", revision=").append(getRevision());
+        sb.append(", prefix=").append(prefix);
+        sb.append(", yangVersion=").append(yangVersion);
+        sb.append("]");
+        return sb.toString();
+    }
+
+    @Override
+    public QNameModule getQNameModule() {
+        return qnameModule;
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NamespaceEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/NamespaceEffectiveStatementImpl.java
new file mode 100644 (file)
index 0000000..4d2be0f
--- /dev/null
@@ -0,0 +1,22 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import java.net.URI;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.NamespaceStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class NamespaceEffectiveStatementImpl extends EffectiveStatementBase<URI, NamespaceStatement>  {
+
+    public NamespaceEffectiveStatementImpl(
+            StmtContext<URI, NamespaceStatement, ?> ctx) {
+        super(ctx);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PrefixEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PrefixEffectiveStatementImpl.java
new file mode 100644 (file)
index 0000000..67f29fb
--- /dev/null
@@ -0,0 +1,21 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
+
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public class PrefixEffectiveStatementImpl extends EffectiveStatementBase<String, PrefixStatement>  {
+
+    public PrefixEffectiveStatementImpl(
+            StmtContext<String, PrefixStatement, ?> ctx) {
+        super(ctx);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PresenceEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/PresenceEffectiveStatementImpl.java
new file mode 100644 (file)
index 0000000..0fce331
--- /dev/null
@@ -0,0 +1,21 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
+
+public class PresenceEffectiveStatementImpl extends EffectiveStatementBase<String, PresenceStatement>  {
+
+    public PresenceEffectiveStatementImpl(
+            StmtContext<String, PresenceStatement, ?> ctx) {
+        super(ctx);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ReferenceEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/ReferenceEffectiveStatementImpl.java
new file mode 100644 (file)
index 0000000..5e1708c
--- /dev/null
@@ -0,0 +1,21 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
+
+public class ReferenceEffectiveStatementImpl extends EffectiveStatementBase<String, ReferenceStatement>  {
+
+    public ReferenceEffectiveStatementImpl(
+            StmtContext<String, ReferenceStatement, ?> ctx) {
+        super(ctx);
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UsesEffectiveStatementImpl.java b/yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/effective/UsesEffectiveStatementImpl.java
new file mode 100644 (file)
index 0000000..f2c7f50
--- /dev/null
@@ -0,0 +1,119 @@
+/*
+ * Copyright (c) 2013-2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective;
+
+import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.stmt.UsesStatement;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+import com.google.common.collect.ImmutableSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.opendaylight.yangtools.yang.model.api.AugmentationSchema;
+import org.opendaylight.yangtools.yang.model.api.SchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaPath;
+import org.opendaylight.yangtools.yang.model.api.UnknownSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.UsesNode;
+
+public class UsesEffectiveStatementImpl extends EffectiveStatementBase<QName, UsesStatement>implements UsesNode {
+    private SchemaPath groupingPath;
+    ImmutableSet<AugmentationSchema> augmentations;
+    private boolean addedByUses;
+    ImmutableMap<SchemaPath, SchemaNode> refines;
+    ImmutableList<UnknownSchemaNode> unknownNodes;
+
+    public UsesEffectiveStatementImpl(StmtContext<QName, UsesStatement, EffectiveStatement<QName, UsesStatement>> ctx) {
+        super(ctx);
+
+        this.groupingPath = null;
+    }
+
+    @Override
+    public SchemaPath getGroupingPath() {
+        return groupingPath;
+    }
+
+    @Override
+    public Set<AugmentationSchema> getAugmentations() {
+        return augmentations;
+    }
+
+    @Override
+    public boolean isAugmenting() {
+        return false;
+    }
+
+    @Override
+    public boolean isAddedByUses() {
+        return addedByUses;
+    }
+
+    void setAddedByUses(final boolean addedByUses) {
+        this.addedByUses = addedByUses;
+    }
+
+    @Override
+    public Map<SchemaPath, SchemaNode> getRefines() {
+        return refines;
+    }
+
+    public List<UnknownSchemaNode> getUnknownSchemaNodes() {
+        return unknownNodes;
+    }
+
+    @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());
+        return result;
+    }
+
+    @Override
+    public boolean equals(final Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (obj == null) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        final UsesEffectiveStatementImpl other = (UsesEffectiveStatementImpl) 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;
+        }
+        return true;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder(UsesEffectiveStatementImpl.class.getSimpleName());
+        sb.append("[groupingPath=");
+        sb.append(groupingPath);
+        sb.append("]");
+        return sb.toString();
+    }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/effective/build/test/EffectiveBuildTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/effective/build/test/EffectiveBuildTest.java
new file mode 100644 (file)
index 0000000..83a3abd
--- /dev/null
@@ -0,0 +1,89 @@
+package org.opendaylight.yangtools.yang.stmt.effective.build.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.EffectiveSchemaContext;
+import org.opendaylight.yangtools.yang.model.api.GroupingDefinition;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import java.net.URI;
+import org.opendaylight.yangtools.yang.common.QNameModule;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+public class EffectiveBuildTest {
+
+    private static final YangFileStatementSource SIMPLE_MODULE = new YangFileStatementSource("/stmt-test/effective-build/simple-module.yang");
+    private static final QNameModule SIMPLE_MODULE_QNAME = QNameModule.create(URI.create("simple.yang"), null);
+
+    @Test
+    public void effectiveBuildTest() throws SourceException, ReactorException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, SIMPLE_MODULE);
+        EffectiveSchemaContext result = reactor.buildEffective();
+
+        assertNotNull(result);
+
+        Module simpleModule = result.findModuleByName("simple-module",null);
+        assertNotNull(simpleModule);
+
+        QName q1 = QName.create(SIMPLE_MODULE_QNAME, "root-container");
+        QName q2 = QName.create(SIMPLE_MODULE_QNAME, "sub-container");
+        QName q3 = QName.create(SIMPLE_MODULE_QNAME, "sub-sub-container");
+        QName q4 = QName.create(SIMPLE_MODULE_QNAME, "root-container2");
+        QName q5 = QName.create(SIMPLE_MODULE_QNAME, "sub-container2");
+        QName q6 = QName.create(SIMPLE_MODULE_QNAME, "sub-sub-container2");
+        QName q7 = QName.create(SIMPLE_MODULE_QNAME, "grp");
+
+        ContainerSchemaNode rootCon = (ContainerSchemaNode)simpleModule.getDataChildByName(q1);
+        assertNotNull(rootCon);
+
+        ContainerSchemaNode subCon = (ContainerSchemaNode)rootCon.getDataChildByName(q2);
+        assertNotNull(subCon);
+
+        ContainerSchemaNode subSubCon = (ContainerSchemaNode)subCon.getDataChildByName(q3);
+        assertNotNull(subSubCon);
+
+        ContainerSchemaNode rootCon2 = (ContainerSchemaNode)simpleModule.getDataChildByName(q4);
+        assertNotNull(rootCon2);
+
+        ContainerSchemaNode subCon2 = (ContainerSchemaNode)rootCon2.getDataChildByName(q5);
+        assertNotNull(subCon2);
+
+        ContainerSchemaNode subSubCon2 = (ContainerSchemaNode)subCon2.getDataChildByName(q6);
+        assertNotNull(subSubCon2);
+
+        GroupingDefinition grp = simpleModule.getGroupings().iterator().next();
+        assertNotNull(grp);
+        assertEquals(q7,grp.getQName());
+
+        ContainerSchemaNode grpSubCon2 = (ContainerSchemaNode) grp.getDataChildByName(q5);
+        assertNotNull(grpSubCon2);
+
+        ContainerSchemaNode grpSubSubCon2 = (ContainerSchemaNode)grpSubCon2.getDataChildByName(q6);
+        assertNotNull(grpSubSubCon2);
+
+    }
+
+    private void log(Throwable e, String indent) {
+        System.out.println(indent + e.getMessage());
+
+        Throwable[] suppressed = e.getSuppressed();
+        for (Throwable throwable : suppressed) {
+            log(throwable, indent + "        ");
+        }
+
+    }
+
+    private void addSources(BuildAction reactor,
+            YangFileStatementSource... sources) {
+        for (YangFileStatementSource source : sources) {
+            reactor.addSource(source);
+        }
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/effective/build/test/YangFileStatementSource.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/effective/build/test/YangFileStatementSource.java
new file mode 100644 (file)
index 0000000..9738c46
--- /dev/null
@@ -0,0 +1,80 @@
+package org.opendaylight.yangtools.yang.stmt.effective.build.test;
+
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.tree.ParseTreeWalker;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementLexer;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.parser.impl.YangStatementParserListenerImpl;
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class YangFileStatementSource implements StatementStreamSource {
+
+        private YangStatementParserListenerImpl yangStatementModelParser;
+        private YangStatementParser.StatementContext statementContext;
+        private ParseTreeWalker walker;
+
+        public YangFileStatementSource(String fileName) {
+                try {
+                        statementContext = parseYangSource(loadFile(fileName));
+                        walker = new ParseTreeWalker();
+                        yangStatementModelParser = new YangStatementParserListenerImpl(REF);
+                } catch (Exception e) {
+                        e.printStackTrace();
+                }
+        }
+
+        private StatementSourceReference REF = new StatementSourceReference() {
+
+                @Override
+                public StatementSource getStatementSource() {
+                        return StatementSource.DECLARATION;
+                }
+        };
+
+        @Override
+        public void writeLinkage(StatementWriter writer, QNameToStatementDefinition stmtDef) throws SourceException {
+                yangStatementModelParser.setAttributes(writer, stmtDef);
+                walker.walk(yangStatementModelParser, statementContext);
+        }
+
+        @Override
+        public void writeLinkageAndStatementDefinitions(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes) throws SourceException {
+                yangStatementModelParser.setAttributes(writer, stmtDef, prefixes);
+                walker.walk(yangStatementModelParser, statementContext);
+        }
+
+        @Override
+        public void writeFull(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes) throws SourceException {
+                yangStatementModelParser.setAttributes(writer, stmtDef, prefixes);
+                walker.walk(yangStatementModelParser, statementContext);
+        }
+
+        private FileInputStream loadFile(String fileName) throws Exception {
+                return new FileInputStream(new File(getClass().getResource(fileName).toURI()));
+        }
+
+        private YangStatementParser.StatementContext parseYangSource(final InputStream stream) throws IOException {
+                final YangStatementLexer lexer = new YangStatementLexer(new ANTLRInputStream(stream));
+                final CommonTokenStream tokens = new CommonTokenStream(lexer);
+                final YangStatementParser parser = new YangStatementParser(tokens);
+                //TODO: no error listener yet
+                //parser.removeErrorListeners();
+                //final YangErrorListener errorListener = new YangErrorListener();
+                //parser.addErrorListener(errorListener);
+                final YangStatementParser.StatementContext result = parser.statement();
+                //errorListener.validate();
+                return result;
+        }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/ImportBasicTestStatementSource.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/ImportBasicTestStatementSource.java
new file mode 100644 (file)
index 0000000..cfdc863
--- /dev/null
@@ -0,0 +1,162 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.IMPORT;
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.MODULE;
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.NAMESPACE;
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.*;
+
+import java.util.Arrays;
+import java.util.List;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
+
+class ImportBasicTestStatementSource implements StatementStreamSource {
+
+    private static final String NS_PREFIX = "urn:org:opendaylight:yangtools:test:";
+
+    private final String name;
+    private final List<String> imports;
+    private StatementWriter writer;
+    private StatementSourceReference REF = new StatementSourceReference() {
+
+        @Override
+        public StatementSource getStatementSource() {
+            return StatementSource.DECLARATION;
+        }
+    };
+
+
+    public ImportBasicTestStatementSource(String name, String... imports) {
+        this.name = name;
+        this.imports = Arrays.asList(imports);
+    }
+
+    @Override
+    public void writeFull(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes)
+            throws SourceException {
+        this.writer = writer;
+        header();
+        extensions();
+        body();
+        end();
+
+    }
+
+
+
+    @Override
+    public void writeLinkage(StatementWriter writer, QNameToStatementDefinition stmtDef) throws SourceException {
+        this.writer = writer;
+        header().end();
+    }
+
+    @Override
+    public void writeLinkageAndStatementDefinitions(StatementWriter writer, QNameToStatementDefinition stmtDef,
+            PrefixToModule prefixes) throws SourceException {
+        this.writer = writer;
+        header();
+        extensions();
+        end();
+
+    }
+
+    protected void extensions() throws SourceException {
+
+    }
+
+    protected void body() throws SourceException {
+//        stmt(YangVersion).arg("1");end();
+//        stmt(Description).arg("Here goes description of this module");end();
+//        stmt(Contact).arg("Here goes our address...");end();
+//
+//        stmt(Revision).arg("2015-03-12");
+//            stmt(Description).arg("This revision brings this and that...");end();
+//            stmt(Reference).arg("Learn more here...");end();
+//        end();
+
+        stmt(CONTAINER).arg(name+":my-container-with-prefix");
+//            stmt(Leaf).arg("MyContainerLeaf");
+//                stmt(Type).arg("string");end();
+//                stmt(Config).arg("TRUE");end();
+//            end();
+//            stmt(Choice).arg("choose-your-destiny");
+//                stmt(Default).arg("destiny-one");end();
+//                stmt(Case).arg("destiny-one");
+//                    stmt(Leaf).arg("destiny-one-leaf");end();
+//                end();
+//                stmt(Case).arg("destiny-two");
+//                    stmt(Mandatory).arg("true");
+//                    stmt(Container).arg("InnerContainer");
+//                        stmt(Leaf).arg("leaf-of-deep");end();
+//                    end();
+//                end();
+//            end();
+//            stmt(Container).arg("MyContainerInContainer");
+//                stmt(Must).arg("xpath expression");
+//                stmt(Leaf).arg("MyContainerInContainerLeaf");
+//                    stmt(Type).arg("string");end();
+//                end();
+//                stmt(Deviation).arg("/tst:test/tst:element");
+//                    stmt(Deviate).arg("add");end();
+//                end();
+//            end();
+        end();
+        stmt(CONTAINER).arg("my-container-without-prefix").end();
+
+        int i = 0;
+        for(String imp : imports)  {
+            i++;
+            stmt(CONTAINER).arg(imp+":my-container-with-imported-prefix"+i).end();
+        }
+
+    }
+
+    ImportBasicTestStatementSource header() throws SourceException {
+        stmt(MODULE).arg(name); {
+            stmt(NAMESPACE).arg(getNamespace()).end();
+            stmt(PREFIX).arg(name).end();
+            stmt(REVISION).arg("2000-01-01").end();
+            for(String imp : imports)  {
+                stmt(IMPORT).arg(imp);
+                    stmt(PREFIX).arg(imp).end();
+                    stmt(REVISION_DATE).arg("2000-01-01").end();
+                end();
+            }
+        }
+        return this;
+    }
+
+    private String getNamespace() {
+        return NS_PREFIX + name;
+    }
+
+    protected ImportBasicTestStatementSource arg(String arg) throws SourceException {
+        writer.argumentValue(arg, REF);
+        return this;
+    }
+
+    protected ImportBasicTestStatementSource stmt(Rfc6020Mapping stmt) throws SourceException {
+        writer.startStatement(stmt.getStatementName(), REF);
+        return this;
+    }
+
+    protected ImportBasicTestStatementSource end() throws SourceException {
+        writer.endStatement(REF);
+        return this;
+    }
+
+
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/ImportResolutionBasicTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/ImportResolutionBasicTest.java
new file mode 100644 (file)
index 0000000..6f08b94
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+
+public class ImportResolutionBasicTest {
+
+    private static final ImportBasicTestStatementSource ROOT_WITHOUT_IMPORT = new ImportBasicTestStatementSource("nature");
+    private static final ImportBasicTestStatementSource IMPORT_ROOT = new ImportBasicTestStatementSource("mammal","nature");
+    private static final ImportBasicTestStatementSource IMPORT_DERIVED = new ImportBasicTestStatementSource("human", "mammal");
+    private static final ImportBasicTestStatementSource IMPORT_SELF = new ImportBasicTestStatementSource("egocentric", "egocentric");
+    private static final ImportBasicTestStatementSource CICLE_YIN = new ImportBasicTestStatementSource("cycle-yin", "cycle-yang");
+    private static final ImportBasicTestStatementSource CICLE_YANG = new ImportBasicTestStatementSource("cycle-yang", "cycle-yin");
+
+
+    @Test
+    public void inImportOrderTest() throws SourceException, ReactorException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor,ROOT_WITHOUT_IMPORT,IMPORT_ROOT,IMPORT_DERIVED);
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void inInverseOfImportOrderTest() throws SourceException, ReactorException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor,IMPORT_DERIVED,IMPORT_ROOT,ROOT_WITHOUT_IMPORT);
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void missingImportedSourceTest() throws SourceException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor,IMPORT_DERIVED,ROOT_WITHOUT_IMPORT);
+        try {
+            reactor.build();
+            fail("reactor.process should fail doe to misssing imported source");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE,e.getPhase());
+        }
+
+    }
+
+    @Test
+    public void circularImportsTest() throws SourceException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor,CICLE_YIN,CICLE_YANG);
+        try {
+            reactor.build();
+            fail("reactor.process should fail doe to circular import");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE,e.getPhase());
+        }
+    }
+
+    @Test
+    public void selfImportTest() throws SourceException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor,IMPORT_SELF,IMPORT_ROOT,ROOT_WITHOUT_IMPORT);
+        try {
+            reactor.build();
+            fail("reactor.process should fail doe to self import");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE,e.getPhase());
+        }
+    }
+
+
+    private void addSources(BuildAction reactor, ImportBasicTestStatementSource... sources) {
+        for(ImportBasicTestStatementSource source : sources) {
+            reactor.addSource(source);
+        }
+    }
+
+}
index b1bcbd351d352663e136e3100629403683667153..1c4b2dc9af63c8ddc419c94d87da644e290e6f83 100644 (file)
@@ -21,21 +21,28 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
 import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.stmt.test.TestStatementSource.ModuleEntry;
 
 public class ImportResolutionTest {
 
-    private static final TestStatementSource ROOT_WITHOUT_IMPORT = new TestStatementSource("nature");
-    private static final TestStatementSource IMPORT_ROOT = new TestStatementSource("mammal","nature");
-    private static final TestStatementSource IMPORT_DERIVED = new TestStatementSource("human", "mammal");
-    private static final TestStatementSource IMPORT_SELF = new TestStatementSource("egocentric", "egocentric");
-    private static final TestStatementSource CICLE_YIN = new TestStatementSource("cycle-yin", "cycle-yang");
-    private static final TestStatementSource CICLE_YANG = new TestStatementSource("cycle-yang", "cycle-yin");
+    private static final ModuleEntry modNature = new ModuleEntry("nature", "2000-01-01");
+    private static final ModuleEntry modMammal = new ModuleEntry("mammal", "2000-01-01");
+    private static final ModuleEntry modHuman = new ModuleEntry("human", "2000-01-01");
+    private static final ModuleEntry modEgocentric = new ModuleEntry("egocentric", "2000-01-01");
+    private static final ModuleEntry modCycleYin = new ModuleEntry("cycle-yin", "2000-01-01");
+    private static final ModuleEntry modCycleYang = new ModuleEntry("cycle-yang", "2000-01-01");
 
+    private static final TestStatementSource ROOT_WITHOUT_IMPORT = new TestStatementSource(modNature);
+    private static final TestStatementSource IMPORT_ROOT = new TestStatementSource(modMammal, modNature);
+    private static final TestStatementSource IMPORT_DERIVED = new TestStatementSource(modHuman, modMammal);
+    private static final TestStatementSource IMPORT_SELF = new TestStatementSource(modEgocentric, modEgocentric);
+    private static final TestStatementSource CICLE_YIN = new TestStatementSource(modCycleYin, modCycleYang);
+    private static final TestStatementSource CICLE_YANG = new TestStatementSource(modCycleYang, modCycleYin);
 
     @Test
     public void inImportOrderTest() throws SourceException, ReactorException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor,ROOT_WITHOUT_IMPORT,IMPORT_ROOT,IMPORT_DERIVED);
+        addSources(reactor, ROOT_WITHOUT_IMPORT, IMPORT_ROOT, IMPORT_DERIVED);
         EffectiveModelContext result = reactor.build();
         assertNotNull(result);
     }
@@ -43,7 +50,7 @@ public class ImportResolutionTest {
     @Test
     public void inInverseOfImportOrderTest() throws SourceException, ReactorException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor,IMPORT_DERIVED,IMPORT_ROOT,ROOT_WITHOUT_IMPORT);
+        addSources(reactor, IMPORT_DERIVED, IMPORT_ROOT, ROOT_WITHOUT_IMPORT);
         EffectiveModelContext result = reactor.build();
         assertNotNull(result);
     }
@@ -51,46 +58,44 @@ public class ImportResolutionTest {
     @Test
     public void missingImportedSourceTest() throws SourceException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor,IMPORT_DERIVED,ROOT_WITHOUT_IMPORT);
+        addSources(reactor, IMPORT_DERIVED, ROOT_WITHOUT_IMPORT);
         try {
             reactor.build();
-            fail("reactor.process should fail doe to misssing imported source");
+            fail("reactor.process should fail due to misssing imported source");
         } catch (ReactorException e) {
             assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE,e.getPhase());
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
         }
-
     }
 
     @Test
     public void circularImportsTest() throws SourceException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor,CICLE_YIN,CICLE_YANG);
+        addSources(reactor, CICLE_YIN, CICLE_YANG);
         try {
             reactor.build();
-            fail("reactor.process should fail doe to circular import");
+            fail("reactor.process should fail due to circular import");
         } catch (ReactorException e) {
             assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE,e.getPhase());
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
         }
     }
 
     @Test
     public void selfImportTest() throws SourceException {
         BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
-        addSources(reactor,IMPORT_SELF,IMPORT_ROOT,ROOT_WITHOUT_IMPORT);
+        addSources(reactor, IMPORT_SELF, IMPORT_ROOT, ROOT_WITHOUT_IMPORT);
         try {
             reactor.build();
-            fail("reactor.process should fail doe to self import");
+            fail("reactor.process should fail due to self import");
         } catch (ReactorException e) {
             assertTrue(e instanceof SomeModifiersUnresolvedException);
-            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE,e.getPhase());
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
         }
     }
 
-
     private void addSources(BuildAction reactor, TestStatementSource... sources) {
-        for(TestStatementSource source : sources) {
+        for (TestStatementSource source : sources) {
             reactor.addSource(source);
         }
     }
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/ImportRevisionsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/ImportRevisionsTest.java
new file mode 100644 (file)
index 0000000..c70e2d5
--- /dev/null
@@ -0,0 +1,119 @@
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.stmt.test.TestStatementSource.ModuleEntry;
+
+public class ImportRevisionsTest {
+
+    private static final ModuleEntry modImported = new ModuleEntry("nature", "2006-05-05");
+    private static final ModuleEntry modImportedRevDiff = new ModuleEntry("nature", "2011-12-12");
+    private static final ModuleEntry modImportedRevMiss = new ModuleEntry("nature", null);
+    private static final ModuleEntry modImported1970 = new ModuleEntry("nature", "1970-01-01");
+
+    private static final ModuleEntry modImporter = new ModuleEntry("mammal", "2006-05-05");
+
+    private static final TestStatementSource IMPORTED = new TestStatementSource(modImported);
+    private static final TestStatementSource IMPORTED_NO_REV = new TestStatementSource(modImportedRevMiss);
+
+    private static final TestStatementSource IMPORT = new TestStatementSource(modImporter, modImported);
+    private static final TestStatementSource IMPORT_REV_DFLT = new TestStatementSource(modImporter, modImported1970);
+    private static final TestStatementSource IMPORT_REV_DIFF = new TestStatementSource(modImporter, modImportedRevDiff);
+    private static final TestStatementSource IMPORT_NO_REV = new TestStatementSource(modImporter, modImportedRevMiss);
+
+    @Test
+    public void revsEqualTest() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, IMPORTED, IMPORT);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void revsDiffTest() throws SourceException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, IMPORTED, IMPORT_REV_DIFF);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to unequal revisions in imported modules");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
+        }
+    }
+
+    @Test
+    public void revInModuleOnly() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, IMPORTED, IMPORT_NO_REV);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void revImportOnly() throws SourceException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, IMPORTED_NO_REV, IMPORT);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to missing revision in imported module");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
+        }
+    }
+
+    @Test
+    public void revDefault1970InImport() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, IMPORTED_NO_REV, IMPORT_REV_DFLT);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void revNowhere() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, IMPORTED_NO_REV, IMPORT_NO_REV);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    private void log(Throwable e, String indent) {
+        System.out.println(indent + e.getMessage());
+
+        Throwable[] suppressed = e.getSuppressed();
+        for (Throwable throwable : suppressed) {
+            log(throwable, indent + "        ");
+        }
+    }
+
+    private void addSources(BuildAction reactor, TestStatementSource... sources) {
+        for (TestStatementSource source : sources) {
+            reactor.addSource(source);
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/IncludeResolutionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/IncludeResolutionTest.java
new file mode 100644 (file)
index 0000000..17dcaaa
--- /dev/null
@@ -0,0 +1,89 @@
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.util.logging.Logger;
+
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+public class IncludeResolutionTest {
+
+    private static final Logger log = Logger.getLogger(IncludeResolutionTest.class.getName());
+
+    private static final IncludeTestStatementSource ROOT = new IncludeTestStatementSource(false,"root-module",null, "submodule-1");
+    private static final IncludeTestStatementSource SUBMODULE1 = new IncludeTestStatementSource(true,"submodule-1","root-module", "submodule-2");
+    private static final IncludeTestStatementSource SUBMODULE2 = new IncludeTestStatementSource(true,"submodule-2", "root-module");
+    private static final IncludeTestStatementSource ERROR_MODULE = new IncludeTestStatementSource(false,"error-module", null, "foo");
+    private static final IncludeTestStatementSource ERROR_SUBMODULE = new IncludeTestStatementSource(true,"error-submodule", "root-module", "foo");
+
+    private static final IncludeTestStatementSource MISSING_PARENT_MODULE = new IncludeTestStatementSource(true,"missing-parent", "foo");
+    @Test
+    public void includeTest() throws SourceException, ReactorException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor,ROOT,SUBMODULE1,SUBMODULE2);
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void missingIncludedSourceTest() throws SourceException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor,ERROR_MODULE);
+        try {
+            reactor.build();
+            fail("reactor.process should fail doe to misssing included source");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE,e.getPhase());
+            log.info(e.getMessage());
+        }
+
+    }
+
+    @Test
+    public void missingIncludedSourceTest2() throws SourceException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor,ERROR_SUBMODULE);
+        try {
+            reactor.build();
+            fail("reactor.process should fail doe to misssing included source");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE,e.getPhase());
+            log.info(e.getMessage());
+        }
+
+    }
+
+    //@Test
+    public void missingIncludedSourceTest3() throws SourceException, ReactorException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor,MISSING_PARENT_MODULE);
+        try {
+            EffectiveModelContext build = reactor.build();
+            //fail("reactor.process should fail doe to misssing belongsTo source");
+        } catch (ReactorException e) {
+            //assertTrue(e instanceof SomeModifiersUnresolvedException);
+            //assertEquals(ModelProcessingPhase.SourceLinkage,e.getPhase());
+            throw(e);
+        }
+
+    }
+
+    private void addSources(BuildAction reactor, IncludeTestStatementSource... sources) {
+        for(IncludeTestStatementSource source : sources) {
+            reactor.addSource(source);
+        }
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/IncludeRevisionsTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/IncludeRevisionsTest.java
new file mode 100644 (file)
index 0000000..9a72f73
--- /dev/null
@@ -0,0 +1,111 @@
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+public class IncludeRevisionsTest {
+
+    private static final YangStatementSourceImpl EQUAL_ROOT = new YangStatementSourceImpl("/revisions/equal-root.yang");
+    private static final YangStatementSourceImpl EQUAL_REV = new YangStatementSourceImpl("/revisions/equal-rev.yang");
+    private static final YangStatementSourceImpl UNEQUAL_ROOT = new YangStatementSourceImpl("/revisions/unequal-root.yang");
+    private static final YangStatementSourceImpl UNEQUAL_REV = new YangStatementSourceImpl("/revisions/unequal-rev.yang");
+    private static final YangStatementSourceImpl SUBMOD_ONLY_ROOT = new YangStatementSourceImpl("/revisions/submod-only-root.yang");
+    private static final YangStatementSourceImpl SUBMOD_ONLY_REV = new YangStatementSourceImpl("/revisions/submod-only-rev.yang");
+    private static final YangStatementSourceImpl MOD_ONLY_ROOT = new YangStatementSourceImpl("/revisions/mod-only-root.yang");
+    private static final YangStatementSourceImpl MOD_ONLY_REV = new YangStatementSourceImpl("/revisions/mod-only-rev.yang");
+    private static final YangStatementSourceImpl MOD_ONLY_1970_ROOT = new YangStatementSourceImpl("/revisions/mod-1970-root.yang");
+    private static final YangStatementSourceImpl MOD_ONLY_1970_REV = new YangStatementSourceImpl("/revisions/mod-1970-rev.yang");
+    private static final YangStatementSourceImpl NOWHERE_ROOT = new YangStatementSourceImpl("/revisions/nowhere-root.yang");
+    private static final YangStatementSourceImpl NOWHERE_REV = new YangStatementSourceImpl("/revisions/nowhere-rev.yang");
+
+
+    @Test
+    public void revsEqualTest() throws SourceException, ReactorException {
+
+        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, EQUAL_REV, EQUAL_ROOT);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void revsUnequalTest() throws SourceException, ReactorException {
+
+        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, UNEQUAL_REV, UNEQUAL_ROOT);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to unequal revisions in include and submodule");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
+        }
+    }
+
+    @Test
+    public void revIncludeOnly() throws SourceException, ReactorException {
+
+        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, SUBMOD_ONLY_REV, SUBMOD_ONLY_ROOT);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void revInModuleOnly() throws SourceException, ReactorException {
+
+        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, MOD_ONLY_REV, MOD_ONLY_ROOT);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to missing revision in included submodule");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.SOURCE_LINKAGE, e.getPhase());
+        }
+    }
+
+
+    @Test
+    public void rev1970InModuleOnlyTest() throws SourceException, ReactorException {
+
+        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, MOD_ONLY_1970_REV, MOD_ONLY_1970_ROOT);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void revNowhereTest() throws SourceException, ReactorException {
+
+        CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, NOWHERE_REV, NOWHERE_ROOT);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    private void addSources(CrossSourceStatementReactor.BuildAction reactor, StatementStreamSource... sources) {
+        for (StatementStreamSource source : sources) {
+            reactor.addSource(source);
+        }
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/IncludeTestStatementSource.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/IncludeTestStatementSource.java
new file mode 100644 (file)
index 0000000..41b9459
--- /dev/null
@@ -0,0 +1,157 @@
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.*;
+import java.util.Arrays;
+import java.util.List;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
+
+
+
+
+class IncludeTestStatementSource implements StatementStreamSource {
+
+    private static final String NS_PREFIX = "urn:org:opendaylight:yangtools:test:";
+
+    private final String name;
+    private final List<String> includes;
+    private StatementWriter writer;
+    private StatementSourceReference REF = new StatementSourceReference() {
+
+        @Override
+        public StatementSource getStatementSource() {
+            return StatementSource.DECLARATION;
+        }
+    };
+
+    private boolean isSubmodule;
+
+    private String belongsTo;
+
+
+    public IncludeTestStatementSource(boolean isSubmodule, String name, String belongsTo, String... includes) {
+        this.name = name;
+        this.includes = Arrays.asList(includes);
+        this.isSubmodule=isSubmodule;
+        this.belongsTo = belongsTo;
+    }
+
+    @Override
+    public void writeFull(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes)
+            throws SourceException {
+        this.writer = writer;
+        header();
+        extensions();
+        body();
+        end();
+
+    }
+
+
+
+    @Override
+    public void writeLinkage(StatementWriter writer, QNameToStatementDefinition stmtDef) throws SourceException {
+        this.writer = writer;
+        header().end();
+    }
+
+    @Override
+    public void writeLinkageAndStatementDefinitions(StatementWriter writer, QNameToStatementDefinition stmtDef,
+            PrefixToModule prefixes) throws SourceException {
+        this.writer = writer;
+        header();
+        extensions();
+        end();
+
+    }
+
+    protected void extensions() throws SourceException {
+
+    }
+
+    protected void body() throws SourceException {
+
+        String prefix = isSubmodule ? belongsTo : name;
+
+        stmt(CONTAINER).arg(prefix+":my-container-with-prefix");
+
+        end();
+        stmt(CONTAINER).arg("my-container-without-prefix").end();
+
+    }
+
+    IncludeTestStatementSource header() throws SourceException {
+
+        if(isSubmodule) writeSubmoduleHeader();
+        else writeModuleHeader();
+
+        return this;
+    }
+
+    /**
+     *
+     */
+    private void writeSubmoduleHeader() throws SourceException {
+        stmt(SUBMODULE).arg(name); {
+
+
+            stmt(REVISION).arg("2000-01-01").end();
+            if(belongsTo != null) {
+                stmt(BELONGS_TO).arg(belongsTo);
+                stmt(PREFIX).arg(belongsTo).end();
+                end();
+            }
+
+            for(String inc : includes)  {
+                stmt(INCLUDE).arg(inc);
+                    stmt(REVISION_DATE).arg("2000-01-01").end();
+                end();
+            }
+        }
+
+    }
+
+    /**
+     *
+     */
+    private void writeModuleHeader() throws SourceException{
+        stmt(MODULE).arg(name); {
+            stmt(NAMESPACE).arg(getNamespace()).end();
+            stmt(PREFIX).arg(name).end();
+            stmt(REVISION).arg("2000-01-01").end();
+            for(String inc : includes)  {
+                stmt(INCLUDE).arg(inc);
+                    stmt(REVISION_DATE).arg("2000-01-01").end();
+                end();
+            }
+        }
+
+    }
+
+    private String getNamespace() {
+        return NS_PREFIX + name;
+    }
+
+    protected IncludeTestStatementSource arg(String arg) throws SourceException {
+        writer.argumentValue(arg, REF);
+        return this;
+    }
+
+    protected IncludeTestStatementSource stmt(Rfc6020Mapping stmt) throws SourceException {
+        writer.startStatement(stmt.getStatementName(), REF);
+        return this;
+    }
+
+    protected IncludeTestStatementSource end() throws SourceException {
+        writer.endStatement(REF);
+        return this;
+    }
+
+
+}
index 8893e7401b43def09d8e8871893b70380383b159..e068a4d3e18003646d0fff54f3eb5760ff99562e 100644 (file)
@@ -7,11 +7,13 @@
  */
 package org.opendaylight.yangtools.yang.stmt.test;
 
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.CONTAINER;
 import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.IMPORT;
 import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.MODULE;
 import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.NAMESPACE;
 import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.PREFIX;
-
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.REVISION;
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.REVISION_DATE;
 import java.util.Arrays;
 import java.util.List;
 import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
@@ -25,10 +27,34 @@ import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
 
 class TestStatementSource implements StatementStreamSource {
 
+    public static class ModuleEntry {
+
+        private final String name;
+        private final String revision;
+
+        public ModuleEntry(String name, String revision) {
+
+            this.name = name;
+            this.revision = revision;
+        }
+
+        public String getName() {
+
+            return name;
+        }
+
+        public String getRevision() {
+
+            return revision;
+        }
+    }
+
     private static final String NS_PREFIX = "urn:org:opendaylight:yangtools:test:";
 
     private final String name;
-    private final List<String> imports;
+    private final String revision;
+    private final List<ModuleEntry> imports;
+    private String container;
     private StatementWriter writer;
     private StatementSourceReference REF = new StatementSourceReference() {
 
@@ -38,12 +64,18 @@ class TestStatementSource implements StatementStreamSource {
         }
     };
 
+    public TestStatementSource(ModuleEntry module, ModuleEntry... imports) {
 
-    public TestStatementSource(String name, String... imports) {
-        this.name = name;
+        this.name = module.getName();
+        this.revision = module.getRevision();
         this.imports = Arrays.asList(imports);
     }
 
+    public void setContainer(String container) {
+
+        this.container = container;
+    }
+
     @Override
     public void writeFull(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes)
             throws SourceException {
@@ -69,22 +101,40 @@ class TestStatementSource implements StatementStreamSource {
         end();
     }
 
-    protected void extensions() {
-        // TODO Auto-generated method stub
+    protected void extensions() throws SourceException {
 
     }
 
-    protected void body() {
+    protected void body() throws SourceException {
 
+        if (container != null)
+            stmt(CONTAINER).arg(container).end();
     }
 
     TestStatementSource header() throws SourceException {
-        stmt(MODULE).arg(name); {
+
+        stmt(MODULE).arg(name);
+        {
             stmt(NAMESPACE).arg(getNamespace()).end();
             stmt(PREFIX).arg(name).end();
-            for(String imp : imports) {
+
+            if (revision != null) {
+                stmt(REVISION).arg(revision).end();
+            }
+
+            for (ModuleEntry impEntry : imports) {
+
+                String imp = impEntry.getName();
+                String rev = impEntry.getRevision();
+
                 stmt(IMPORT).arg(imp);
+                {
                     stmt(PREFIX).arg(imp).end();
+
+                    if (rev != null) {
+                        stmt(REVISION_DATE).arg(rev).end();
+                    }
+                }
                 end();
             }
         }
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/TestYangFileStatementSource.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/TestYangFileStatementSource.java
new file mode 100644 (file)
index 0000000..cb4d32d
--- /dev/null
@@ -0,0 +1,80 @@
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import org.antlr.v4.runtime.ANTLRInputStream;
+import org.antlr.v4.runtime.CommonTokenStream;
+import org.antlr.v4.runtime.tree.ParseTreeWalker;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementLexer;
+import org.opendaylight.yangtools.antlrv4.code.gen.YangStatementParser;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.parser.impl.YangStatementParserListenerImpl;
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class TestYangFileStatementSource implements StatementStreamSource {
+
+        private YangStatementParserListenerImpl yangStatementModelParser;
+        private YangStatementParser.StatementContext statementContext;
+        private ParseTreeWalker walker;
+
+        public TestYangFileStatementSource(String fileName) {
+                try {
+                        statementContext = parseYangSource(loadFile(fileName));
+                        walker = new ParseTreeWalker();
+                        yangStatementModelParser = new YangStatementParserListenerImpl(REF);
+                } catch (Exception e) {
+                        e.printStackTrace();
+                }
+        }
+
+        private StatementSourceReference REF = new StatementSourceReference() {
+
+                @Override
+                public StatementSource getStatementSource() {
+                        return StatementSource.DECLARATION;
+                }
+        };
+
+        @Override
+        public void writeLinkage(StatementWriter writer, QNameToStatementDefinition stmtDef) throws SourceException {
+                yangStatementModelParser.setAttributes(writer, stmtDef);
+                walker.walk(yangStatementModelParser, statementContext);
+        }
+
+        @Override
+        public void writeLinkageAndStatementDefinitions(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes) throws SourceException {
+                yangStatementModelParser.setAttributes(writer, stmtDef, prefixes);
+                walker.walk(yangStatementModelParser, statementContext);
+        }
+
+        @Override
+        public void writeFull(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes) throws SourceException {
+                yangStatementModelParser.setAttributes(writer, stmtDef, prefixes);
+                walker.walk(yangStatementModelParser, statementContext);
+        }
+
+        private FileInputStream loadFile(String fileName) throws Exception {
+                return new FileInputStream(new File(getClass().getResource(fileName).toURI()));
+        }
+
+        private YangStatementParser.StatementContext parseYangSource(final InputStream stream) throws IOException {
+                final YangStatementLexer lexer = new YangStatementLexer(new ANTLRInputStream(stream));
+                final CommonTokenStream tokens = new CommonTokenStream(lexer);
+                final YangStatementParser parser = new YangStatementParser(tokens);
+                //TODO: no error listener yet
+                //parser.removeErrorListeners();
+                //final YangErrorListener errorListener = new YangErrorListener();
+                //parser.addErrorListener(errorListener);
+                final YangStatementParser.StatementContext result = parser.statement();
+                //errorListener.validate();
+                return result;
+        }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/UsesResolutionTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/UsesResolutionTest.java
new file mode 100644 (file)
index 0000000..790e17c
--- /dev/null
@@ -0,0 +1,127 @@
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
+import org.opendaylight.yangtools.yang.parser.spi.meta.SomeModifiersUnresolvedException;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+
+public class UsesResolutionTest {
+
+    //private static final Logger log = Logger.getLogger(IncludeResolutionTest.class.getName());
+
+    public static enum TYPE {
+        CYCLIC,
+        MISSING,
+        NON_CYCLIC,
+        ROOT,
+        IMPORT,
+        INCORRECT_ROOT,
+        DEFAULT
+    }
+
+    private static final UsesTestStatementSource GRP_TST = new UsesTestStatementSource(
+            "my-module", "grouping-1", "grouping-2");
+
+    private static final UsesTestStatementSource CYCLIC = new UsesTestStatementSource("my-module",TYPE.CYCLIC);
+
+    private static final UsesTestStatementSource MISSING = new UsesTestStatementSource("my-module",TYPE.MISSING);
+
+    private static final UsesTestStatementSource NON_CYCLIC = new UsesTestStatementSource("my-module",TYPE.NON_CYCLIC);
+
+    private static final UsesTestStatementSource ROOT = new UsesTestStatementSource("root-module",TYPE.ROOT);
+    private static final UsesTestStatementSource IMPORT = new UsesTestStatementSource("import-module",TYPE.IMPORT);
+    private static final UsesTestStatementSource INCORRECT_ROOT = new UsesTestStatementSource("import-module",TYPE.INCORRECT_ROOT);
+
+    @Test
+    public void usesImportTest() throws SourceException, ReactorException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, ROOT,IMPORT);
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void usesTest() throws SourceException, ReactorException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, GRP_TST);
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void usesAlmostCyclicTest() throws SourceException, ReactorException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, NON_CYCLIC);
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void usesCyclicTest() throws SourceException, ReactorException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, CYCLIC);
+        try {
+            EffectiveModelContext result = reactor.build();
+            fail("reactor.process should fail doe to cyclic uses-grouping statements");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.FULL_DECLARATION, e.getPhase());
+            log(e,"");
+        }
+    }
+
+    @Test
+    public void usesMissingTest() throws SourceException, ReactorException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, MISSING);
+        try {
+            EffectiveModelContext result = reactor.build();
+            fail("reactor.process should fail doe to misssing grouping");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.FULL_DECLARATION, e.getPhase());
+            log(e,"");
+        }
+    }
+
+    @Test
+    public void usesBadImportTest() throws SourceException, ReactorException {
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, INCORRECT_ROOT, IMPORT);
+        try {
+            EffectiveModelContext result = reactor.build();
+            fail("reactor.process should fail doe to misssing grouping");
+        } catch (ReactorException e) {
+            assertTrue(e instanceof SomeModifiersUnresolvedException);
+            assertEquals(ModelProcessingPhase.FULL_DECLARATION, e.getPhase());
+            log(e,"");
+        }
+    }
+
+    private void log(Throwable e, String indent) {
+        System.out.println(indent + e.getMessage());
+
+        Throwable[] suppressed = e.getSuppressed();
+        for (Throwable throwable : suppressed) {
+            log(throwable, indent + "        ");
+        }
+
+    }
+
+    private void addSources(BuildAction reactor,
+            UsesTestStatementSource... sources) {
+        for (UsesTestStatementSource source : sources) {
+            reactor.addSource(source);
+        }
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/UsesTestStatementSource.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/UsesTestStatementSource.java
new file mode 100644 (file)
index 0000000..c6e6edd
--- /dev/null
@@ -0,0 +1,298 @@
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.*;
+
+import java.util.Arrays;
+import java.util.List;
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
+
+class UsesTestStatementSource implements StatementStreamSource {
+
+    private static final String NS_PREFIX = "urn:org:opendaylight:yangtools:test:";
+
+    private final String name;
+    private StatementWriter writer;
+    private List<String> groupingChain;
+    private UsesResolutionTest.TYPE type;
+    private StatementSourceReference REF = new StatementSourceReference() {
+
+        @Override
+        public StatementSource getStatementSource() {
+            return StatementSource.DECLARATION;
+        }
+    };
+
+    public UsesTestStatementSource(String name, String... groupingChain) {
+        this.name = name;
+        this.groupingChain = Arrays.asList(groupingChain);
+        this.type = UsesResolutionTest.TYPE.DEFAULT;
+    }
+
+    /**
+     * @param name2
+     * @param cyclic
+     */
+    public UsesTestStatementSource(String name, UsesResolutionTest.TYPE type) {
+        this.name = name;
+        this.type = type;
+    }
+
+    @Override
+    public void writeFull(StatementWriter writer,
+            QNameToStatementDefinition stmtDef, PrefixToModule prefixes)
+            throws SourceException {
+        this.writer = writer;
+        header();
+        extensions();
+        body();
+        end();
+
+    }
+
+    @Override
+    public void writeLinkage(StatementWriter writer,
+            QNameToStatementDefinition stmtDef) throws SourceException {
+        this.writer = writer;
+        header().end();
+    }
+
+    @Override
+    public void writeLinkageAndStatementDefinitions(StatementWriter writer,
+            QNameToStatementDefinition stmtDef, PrefixToModule prefixes)
+            throws SourceException {
+        this.writer = writer;
+        header();
+        extensions();
+        end();
+
+    }
+
+    protected void extensions() throws SourceException {
+
+    }
+
+    protected void body() throws SourceException {
+
+        switch (type) {
+        case CYCLIC:
+            writeCyclic();
+            break;
+        case NON_CYCLIC:
+            writeNonCyclic();
+            break;
+        case MISSING:
+            writeMissing();
+            break;
+        case ROOT:
+            writeRoot();
+            break;
+        case INCORRECT_ROOT:
+            writeIncorrectRoot();
+            break;
+        case IMPORT:
+            writeImport();
+            break;
+
+        default:
+            writeDefault();
+
+        }
+
+    }
+
+
+    private void writeIncorrectRoot() throws SourceException {
+        stmt(CONTAINER).arg("root-container-with-uses");
+        {
+            stmt(USES).arg("imp-grp").end();
+            stmt(USES).arg("local-grp").end();
+        }
+        end();
+
+        stmt(GROUPING).arg("local-grp");
+        {
+            writeGroupingBody("local-grp");
+        }
+        end();
+    }
+
+    private void writeRoot() throws SourceException {
+        stmt(CONTAINER).arg("root-container-with-uses");
+        {
+            stmt(USES).arg("imp:imp-grp").end();
+            stmt(USES).arg("local-grp").end();
+        }
+        end();
+
+        stmt(GROUPING).arg("local-grp");
+        {
+            writeGroupingBody("local-grp");
+        }
+        end();
+    }
+
+    private void writeImport() throws SourceException {
+        stmt(GROUPING).arg("imp-grp");
+        {
+            writeGroupingBody("imp-grp");
+        }
+        end();
+    }
+
+    private void writeNonCyclic() throws SourceException {
+        stmt(CONTAINER).arg("container-with-uses");
+        stmt(USES).arg("grp1").end();
+        end();
+
+        stmt(GROUPING).arg("grp1");
+        stmt(USES).arg("grp2").end();
+        end();
+
+        stmt(GROUPING).arg("grp2");
+        stmt(USES).arg("grp3").end();
+        end();
+
+        stmt(GROUPING).arg("grp3");
+        writeGroupingBody("grp3");
+        end();
+    }
+
+    private void writeMissing() throws SourceException {
+        stmt(CONTAINER).arg("container-with-uses");
+        stmt(USES).arg("grp1").end();
+        stmt(USES).arg("missing-grp").end();
+        end();
+
+        stmt(GROUPING).arg("grp1");
+        writeGroupingBody("grp1");
+        end();
+    }
+
+    private void writeCyclic() throws SourceException {
+        stmt(CONTAINER).arg("container-with-uses");
+        stmt(USES).arg("grp1").end();
+        end();
+
+        stmt(GROUPING).arg("grp1");
+        stmt(USES).arg("grp2").end();
+        end();
+
+        stmt(GROUPING).arg("grp2");
+        stmt(USES).arg("grp3").end();
+        end();
+
+        stmt(GROUPING).arg("grp3");
+        stmt(USES).arg("grp1").end();
+        end();
+    }
+
+    private void writeDefault() throws SourceException {
+        stmt(CONTAINER).arg("container-with-uses");
+        for (String grpName : groupingChain) {
+            stmt(USES).arg(grpName).end();
+        }
+        end();
+
+        for (String grpName : groupingChain) {
+            stmt(GROUPING).arg(grpName);
+            writeGroupingBody(grpName);
+            stmt(USES).arg("inner-" + grpName).end();
+            end();
+        }
+
+        for (String grpName : groupingChain) {
+            stmt(GROUPING).arg("inner-" + grpName);
+            writeGroupingBody("inner-" + grpName);
+            end();
+        }
+    }
+
+    private void writeGroupingBody(String groupingName) throws SourceException {
+        stmt(CONTAINER).arg(groupingName + "-container");
+        stmt(CONTAINER).arg(groupingName + "-container-2");
+        stmt(CONTAINER).arg(groupingName + "-container-3");
+        end();
+        end();
+        end();
+
+        stmt(CONTAINER).arg(groupingName + "-container-b");
+        stmt(CONTAINER).arg(groupingName + "-container-2-b");
+        stmt(CONTAINER).arg(groupingName + "-container-3-b");
+        end();
+        end();
+        end();
+    }
+
+    UsesTestStatementSource header() throws SourceException {
+        switch (type) {
+        case ROOT:
+            writeRootHeader();
+            break;
+        default:
+            writeModuleHeader();
+
+        }
+        return this;
+    }
+
+    private void writeRootHeader() throws SourceException {
+        stmt(MODULE).arg(name);
+        {
+            stmt(NAMESPACE).arg(getNamespace()).end();
+            stmt(PREFIX).arg(name).end();
+            stmt(REVISION).arg("2000-01-01").end();
+
+            stmt(IMPORT).arg("import-module");
+            stmt(PREFIX).arg("imp").end();
+            stmt(REVISION_DATE).arg("2000-01-01").end();
+            end();
+        }
+    }
+
+    /**
+     *
+     */
+    private void writeModuleHeader() throws SourceException {
+
+        stmt(MODULE).arg(name);
+        {
+            stmt(NAMESPACE).arg(getNamespace()).end();
+            stmt(PREFIX).arg(name).end();
+            stmt(REVISION).arg("2000-01-01").end();
+            // for(String inc : includes) {
+            // stmt(Include).arg(inc);
+            // stmt(RevisionDate).arg("2000-01-01").end();
+            // end();
+            // }
+        }
+
+    }
+
+    private String getNamespace() {
+        return NS_PREFIX + name;
+    }
+
+    protected UsesTestStatementSource arg(String arg) throws SourceException {
+        writer.argumentValue(arg, REF);
+        return this;
+    }
+
+    protected UsesTestStatementSource stmt(Rfc6020Mapping stmt)
+            throws SourceException {
+        writer.startStatement(stmt.getStatementName(), REF);
+        return this;
+    }
+
+    protected UsesTestStatementSource end() throws SourceException {
+        writer.endStatement(REF);
+        return this;
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/YangFileStmtTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/YangFileStmtTest.java
new file mode 100644 (file)
index 0000000..c88ad9c
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.stmt.test;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangStatementSourceImpl;
+
+import static org.junit.Assert.assertNotNull;
+
+public class YangFileStmtTest {
+        private static final YangStatementSourceImpl YANGFILE = new YangStatementSourceImpl("/semantic-statement-parser/test.yang");
+        private static final YangStatementSourceImpl IMPORTEDYANGFILE = new YangStatementSourceImpl("/semantic-statement-parser/importedtest.yang");
+        private static final YangStatementSourceImpl SIMPLENODES = new YangStatementSourceImpl("/semantic-statement-parser/simple-nodes-semantic.yang");
+        private static final YangStatementSourceImpl FOO = new YangStatementSourceImpl("/semantic-statement-parser/foo.yang");
+        private static final YangStatementSourceImpl FILE1 = new YangStatementSourceImpl("/model/bar.yang");
+        private static final YangStatementSourceImpl FILE2 = new YangStatementSourceImpl("/model/baz.yang");
+        private static final YangStatementSourceImpl FILE3 = new YangStatementSourceImpl("/model/foo.yang");
+        private static final YangStatementSourceImpl FILE4 = new YangStatementSourceImpl("/model/subfoo.yang");
+        private static final YangStatementSourceImpl EXTFILE = new YangStatementSourceImpl("/semantic-statement-parser/ext-typedef.yang");
+        private static final YangStatementSourceImpl EXTUSE = new YangStatementSourceImpl("/semantic-statement-parser/ext-use.yang");
+
+        @Test
+        public void readAndParseYangFileTest() throws SourceException, ReactorException {
+                CrossSourceStatementReactor.BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+                addSources(reactor, YANGFILE, SIMPLENODES, IMPORTEDYANGFILE, FOO);
+                addSources(reactor, FILE1, FILE2, FILE3, FILE4);
+                addSources(reactor, EXTFILE, EXTUSE);
+                EffectiveModelContext result = reactor.build();
+                assertNotNull(result);
+        }
+
+        private void addSources(CrossSourceStatementReactor.BuildAction reactor, StatementStreamSource... sources) {
+                for (StatementStreamSource source : sources) {
+                        reactor.addSource(source);
+                }
+        }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/augment/AugmentTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/augment/AugmentTest.java
new file mode 100644 (file)
index 0000000..69b1242
--- /dev/null
@@ -0,0 +1,184 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yangtools.yang.stmt.test.augment;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.fail;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+
+public class AugmentTest {
+
+    private static final TestAugmentSource IMPORTED = new TestAugmentSource("imp", "/a");
+    private static final TestAugmentSource VALID_ABS = new TestAugmentSource("root", "/aug1/aug11/aug111");
+    private static final TestAugmentSource VALID_ABS_PREFIXED = new TestAugmentSource("root",
+            "/imp:aug1/imp:aug11/imp:aug111", "imp");
+    private static final TestAugmentSource VALID_REL = new TestAugmentSource("root", "aug1/aug11");
+    private static final TestAugmentSource VALID_REL_PREFIXED = new TestAugmentSource("root",
+            "imp:aug1/imp:aug11/imp:aug111", "imp");
+    private static final TestAugmentSource INVALID_REL_WHITE_SPACE = new TestAugmentSource("root", "..   /aug1/aug11");
+    private static final TestAugmentSource INVALID_REL1 = new TestAugmentSource("root", "./aug1/aug11");
+    private static final TestAugmentSource INVALID_REL2 = new TestAugmentSource("root", "../aug1/aug11");
+    private static final TestAugmentSource INVALID_ABS = new TestAugmentSource("root", "//aug1/aug11/aug111");
+    private static final TestAugmentSource INVALID_ABS_PREFIXED_NO_IMP = new TestAugmentSource("root",
+            "imp:aug1/imp:aug11/imp:aug111");
+    private static final TestAugmentSource INVALID_EMPTY = new TestAugmentSource("root", "");
+    private static final TestAugmentSource INVALID_XPATH = new TestAugmentSource("root", "/aug1/-");
+
+    @Test
+    public void validAugAbsTest() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, VALID_ABS);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void validAugAbsPrefixedTest() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, IMPORTED, VALID_ABS_PREFIXED);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void validAugRelTest() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, VALID_REL);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void validAugRelPrefixedTest() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, IMPORTED, VALID_REL_PREFIXED);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void validAugRelWhiteSpaceTest() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, INVALID_REL_WHITE_SPACE);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to invalid relative path");
+        } catch (Exception e) {
+            assertEquals(IllegalArgumentException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void invalidAugRel1Test() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, INVALID_REL1);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to invalid relative path");
+        } catch (Exception e) {
+            assertEquals(IllegalArgumentException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void invalidAugRel2Test() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, INVALID_REL2);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to invalid relative path");
+        } catch (Exception e) {
+            assertEquals(IllegalArgumentException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void invalidAugAbs() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, INVALID_ABS);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to invalid absolute path");
+        } catch (Exception e) {
+            assertEquals(IllegalArgumentException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void invalidAugAbsPrefixedNoImp() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, INVALID_ABS_PREFIXED_NO_IMP);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to missing import from augment path");
+        } catch (Exception e) {
+            assertEquals(IllegalArgumentException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void invalidAugEmptyTest() throws SourceException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, INVALID_EMPTY);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to empty path");
+        } catch (Exception e) {
+            assertEquals(IllegalArgumentException.class, e.getClass());
+        }
+    }
+
+    @Test
+    public void invalidAugXPathTest() throws SourceException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, INVALID_XPATH);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to invalid XPath");
+        } catch (Exception e) {
+            assertEquals(IllegalArgumentException.class, e.getClass());
+        }
+    }
+
+    private void addSources(BuildAction reactor, TestAugmentSource... sources) {
+        for (TestAugmentSource source : sources) {
+            reactor.addSource(source);
+        }
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/augment/TestAugmentSource.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/augment/TestAugmentSource.java
new file mode 100644 (file)
index 0000000..ba9c745
--- /dev/null
@@ -0,0 +1,115 @@
+package org.opendaylight.yangtools.yang.stmt.test.augment;
+
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.AUGMENT;
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.IMPORT;
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.MODULE;
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.NAMESPACE;
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.PREFIX;
+
+import java.util.Arrays;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
+
+public class TestAugmentSource implements StatementStreamSource {
+
+    private static final String NS_PREFIX = "urn:org:opendaylight:yangtools:test:";
+
+    private final String name;
+    private final String augment;
+    private final java.util.List<String> imports;
+    private StatementWriter writer;
+    private StatementSourceReference REF = new StatementSourceReference() {
+
+        @Override
+        public StatementSource getStatementSource() {
+            return StatementSource.DECLARATION;
+        }
+    };
+
+    public TestAugmentSource(String name, String augment, String... imports) {
+        this.name = name;
+        this.augment = augment;
+        this.imports = Arrays.asList(imports);
+    }
+
+    @Override
+    public void writeFull(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes)
+            throws SourceException {
+        this.writer = writer;
+        header();
+        extensions();
+        body();
+        end();
+    }
+
+    @Override
+    public void writeLinkage(StatementWriter writer, QNameToStatementDefinition stmtDef) throws SourceException {
+        this.writer = writer;
+        header().end();
+    }
+
+    @Override
+    public void writeLinkageAndStatementDefinitions(StatementWriter writer, QNameToStatementDefinition stmtDef,
+            PrefixToModule prefixes) throws SourceException {
+        this.writer = writer;
+        header();
+        extensions();
+        end();
+    }
+
+    protected void extensions() throws SourceException {
+
+    }
+
+    protected void body() throws SourceException {
+
+        stmt(AUGMENT).arg(augment);
+        end();
+    }
+
+    TestAugmentSource header() throws SourceException {
+
+        stmt(MODULE).arg(name);
+        {
+            stmt(NAMESPACE).arg(getNamespace()).end();
+            stmt(PREFIX).arg(name).end();
+        }
+
+        for (String impEntry : imports) {
+
+            stmt(IMPORT).arg(impEntry);
+            {
+                stmt(PREFIX).arg(impEntry).end();
+            }
+            end();
+        }
+
+        return this;
+    }
+
+    private String getNamespace() {
+        return NS_PREFIX + name;
+    }
+
+    protected TestAugmentSource arg(String arg) throws SourceException {
+        writer.argumentValue(arg, REF);
+        return this;
+    }
+
+    protected TestAugmentSource stmt(Rfc6020Mapping stmt) throws SourceException {
+        writer.startStatement(stmt.getStatementName(), REF);
+        return this;
+    }
+
+    protected TestAugmentSource end() throws SourceException {
+        writer.endStatement(REF);
+        return this;
+    }
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/key/KeyTest.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/key/KeyTest.java
new file mode 100644 (file)
index 0000000..0a1569a
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.yangtools.yang.stmt.test.key;
+
+import org.junit.Test;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ReactorException;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.CrossSourceStatementReactor.BuildAction;
+import org.opendaylight.yangtools.yang.parser.stmt.reactor.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.YangInferencePipeline;
+
+import static org.junit.Assert.*;
+
+public class KeyTest {
+
+    private static final TestKeySource KEY_SIMPLE = new TestKeySource("root", "key");
+    private static final TestKeySource KEY_COMP = new TestKeySource("root", "key1 key2 key3");
+    private static final TestKeySource KEY_COMP_DUPLICATE = new TestKeySource("root", "key1 key1 key2");
+
+    @Test
+    public void keySimpleTest() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, KEY_SIMPLE);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void keyCompositeTest() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, KEY_COMP);
+
+        EffectiveModelContext result = reactor.build();
+        assertNotNull(result);
+    }
+
+    @Test
+    public void keyCompositeInvalid() throws SourceException, ReactorException {
+
+        BuildAction reactor = YangInferencePipeline.RFC6020_REACTOR.newBuild();
+        addSources(reactor, KEY_COMP_DUPLICATE);
+
+        try {
+            reactor.build();
+            fail("reactor.process should fail due to duplicate name in key");
+        } catch (Exception e) {
+            assertEquals(IllegalArgumentException.class, e.getClass());
+        }
+    }
+
+    private void addSources(BuildAction reactor, TestKeySource... sources) {
+        for (TestKeySource source : sources) {
+            reactor.addSource(source);
+        }
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/key/TestKeySource.java b/yang/yang-parser-impl/src/test/java/org/opendaylight/yangtools/yang/stmt/test/key/TestKeySource.java
new file mode 100644 (file)
index 0000000..fea5430
--- /dev/null
@@ -0,0 +1,106 @@
+package org.opendaylight.yangtools.yang.stmt.test.key;
+
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.KEY;
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.MODULE;
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.NAMESPACE;
+import static org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping.PREFIX;
+
+import org.opendaylight.yangtools.yang.model.api.Rfc6020Mapping;
+import org.opendaylight.yangtools.yang.model.api.meta.StatementSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.PrefixToModule;
+import org.opendaylight.yangtools.yang.parser.spi.source.QNameToStatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementStreamSource;
+import org.opendaylight.yangtools.yang.parser.spi.source.StatementWriter;
+
+public class TestKeySource implements StatementStreamSource {
+
+    private static final String NS_PREFIX = "urn:org:opendaylight:yangtools:test:";
+
+    private final String name;
+    private final String key;
+    private StatementWriter writer;
+    private StatementSourceReference REF = new StatementSourceReference() {
+
+        @Override
+        public StatementSource getStatementSource() {
+            return StatementSource.DECLARATION;
+        }
+    };
+
+    public TestKeySource(String name, String key) {
+        this.name = name;
+        this.key = key;
+    }
+
+    @Override
+    public void writeFull(StatementWriter writer, QNameToStatementDefinition stmtDef, PrefixToModule prefixes)
+            throws SourceException {
+
+        this.writer = writer;
+
+        header();
+        extensions();
+        body();
+        end();
+    }
+
+    @Override
+    public void writeLinkage(StatementWriter writer, QNameToStatementDefinition stmtDef) throws SourceException {
+        this.writer = writer;
+        header().end();
+    }
+
+    @Override
+    public void writeLinkageAndStatementDefinitions(StatementWriter writer, QNameToStatementDefinition stmtDef,
+            PrefixToModule prefixes) throws SourceException {
+        this.writer = writer;
+        header();
+        extensions();
+        end();
+    }
+
+    protected void extensions() throws SourceException {
+
+    }
+
+    protected void body() throws SourceException {
+
+        stmt(Rfc6020Mapping.LIST).arg("lst");
+        {
+            stmt(KEY).arg(key).end();
+        }
+        end();
+    }
+
+    TestKeySource header() throws SourceException {
+
+        stmt(MODULE).arg(name);
+        {
+            stmt(NAMESPACE).arg(getNamespace()).end();
+            stmt(PREFIX).arg(name).end();
+        }
+
+        return this;
+    }
+
+    private String getNamespace() {
+        return NS_PREFIX + name;
+    }
+
+    protected TestKeySource arg(String arg) throws SourceException {
+        writer.argumentValue(arg, REF);
+        return this;
+    }
+
+    protected TestKeySource stmt(Rfc6020Mapping stmt) throws SourceException {
+        writer.startStatement(stmt.getStatementName(), REF);
+        return this;
+    }
+
+    protected TestKeySource end() throws SourceException {
+        writer.endStatement(REF);
+        return this;
+    }
+}
index 98ee7f2d91122a68f5db6c312c9655a113a7ef30..254f3e8c9c1c646191f73edc741cce560b8fc16f 100644 (file)
@@ -13,7 +13,9 @@ module foo {
         revision-date 2013-02-27;
     }
 
-    include subfoo;
+    include subfoo {
+        revision-date "2013-02-27";
+    }
 
     organization "opendaylight";
     contact "http://www.opendaylight.org/";
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/equal-rev.yang b/yang/yang-parser-impl/src/test/resources/revisions/equal-rev.yang
new file mode 100644 (file)
index 0000000..923e18d
--- /dev/null
@@ -0,0 +1,7 @@
+submodule equal-rev {
+       belongs-to "equal-root" {
+               prefix equal-root;
+       }
+
+       revision "2001-05-19";
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/equal-root.yang b/yang/yang-parser-impl/src/test/resources/revisions/equal-root.yang
new file mode 100644 (file)
index 0000000..aca7f58
--- /dev/null
@@ -0,0 +1,8 @@
+module equal-root {
+       namespace equal-root;
+       prefix equal-root;
+
+       include equal-rev {
+               revision-date "2001-05-19";
+       }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/mod-1970-rev.yang b/yang/yang-parser-impl/src/test/resources/revisions/mod-1970-rev.yang
new file mode 100644 (file)
index 0000000..8871c5d
--- /dev/null
@@ -0,0 +1,5 @@
+submodule mod-1970-rev {
+       belongs-to "mod-1970-root" {
+               prefix mod-1970-root;
+       }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/mod-1970-root.yang b/yang/yang-parser-impl/src/test/resources/revisions/mod-1970-root.yang
new file mode 100644 (file)
index 0000000..5597379
--- /dev/null
@@ -0,0 +1,8 @@
+module mod-1970-root {
+       namespace mod-1970-root;
+       prefix mod-1970-root;
+
+       include mod-1970-rev {
+               revision-date "1970-01-01";
+       }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/mod-only-rev.yang b/yang/yang-parser-impl/src/test/resources/revisions/mod-only-rev.yang
new file mode 100644 (file)
index 0000000..28ff5aa
--- /dev/null
@@ -0,0 +1,5 @@
+submodule mod-only-rev {
+       belongs-to "mod-only-root" {
+               prefix mod-only-root;
+       }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/mod-only-root.yang b/yang/yang-parser-impl/src/test/resources/revisions/mod-only-root.yang
new file mode 100644 (file)
index 0000000..37d0971
--- /dev/null
@@ -0,0 +1,8 @@
+module mod-only-root {
+       namespace mod-only-root;
+       prefix mod-only-root;
+
+       include mod-only-rev {
+               revision-date "2001-05-19";
+       }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/nowhere-rev.yang b/yang/yang-parser-impl/src/test/resources/revisions/nowhere-rev.yang
new file mode 100644 (file)
index 0000000..1d2ea8e
--- /dev/null
@@ -0,0 +1,5 @@
+submodule nowhere-rev {
+       belongs-to "nowhere-root" {
+               prefix nowhere-root;
+       }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/nowhere-root.yang b/yang/yang-parser-impl/src/test/resources/revisions/nowhere-root.yang
new file mode 100644 (file)
index 0000000..3913c42
--- /dev/null
@@ -0,0 +1,6 @@
+module nowhere-root {
+       namespace nowhere-root;
+       prefix nowhere-root;
+
+       include nowhere-rev;
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/submod-only-rev.yang b/yang/yang-parser-impl/src/test/resources/revisions/submod-only-rev.yang
new file mode 100644 (file)
index 0000000..843f04b
--- /dev/null
@@ -0,0 +1,7 @@
+submodule submod-only-rev {
+       belongs-to "submod-only-root" {
+               prefix submod-only-root;
+       }
+
+       revision "2001-05-19";
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/submod-only-root.yang b/yang/yang-parser-impl/src/test/resources/revisions/submod-only-root.yang
new file mode 100644 (file)
index 0000000..4f98af3
--- /dev/null
@@ -0,0 +1,6 @@
+module submod-only-root {
+       namespace submod-only-root;
+       prefix submod-only-root;
+
+       include submod-only-rev;
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/unequal-rev.yang b/yang/yang-parser-impl/src/test/resources/revisions/unequal-rev.yang
new file mode 100644 (file)
index 0000000..cd0de43
--- /dev/null
@@ -0,0 +1,7 @@
+submodule unequal-rev {
+       belongs-to "unequal-root" {
+               prefix unequal-root;
+       }
+
+       revision "2001-05-20";
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/revisions/unequal-root.yang b/yang/yang-parser-impl/src/test/resources/revisions/unequal-root.yang
new file mode 100644 (file)
index 0000000..b0c6717
--- /dev/null
@@ -0,0 +1,8 @@
+module unequal-root {
+       namespace unequal-root;
+       prefix unequal-root;
+
+       include unequal-rev {
+               revision-date "2001-05-19";
+       }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/ext-typedef.yang b/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/ext-typedef.yang
new file mode 100644 (file)
index 0000000..02ea794
--- /dev/null
@@ -0,0 +1,26 @@
+module ext-typedef {
+    yang-version 1;
+    namespace "urn:simple.extension.typedefs";
+    prefix "ext";
+
+    organization "opendaylight";
+    contact "http://www.opendaylight.org/";
+
+    description "Model for testing and resolving of extension typedefs.";
+
+    revision "2015-03-30" {
+        reference "Initial revision.";
+    }
+
+    extension simple-ext-w-arg {
+        argument "ext-arg";
+        description "Extension with single argument definition.";
+    }
+
+    leaf myleaf {
+        type union {
+            type string;
+            type int32;
+        }
+    }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/ext-use.yang b/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/ext-use.yang
new file mode 100644 (file)
index 0000000..f2b6b65
--- /dev/null
@@ -0,0 +1,43 @@
+module ext-use {
+    yang-version 1;
+    namespace "urn:simple.extension.use";
+    prefix "ext-use";
+
+    import ext-typedef {
+        prefix "ext";
+    }
+
+    organization "opendaylight";
+    contact "http://www.opendaylight.org/";
+
+    description "Model for testing of used extensions across model.";
+
+    revision "2015-03-30" {
+        reference "Initial revision.";
+    }
+
+    leaf value {
+      ext:simple-ext-w-arg "key:value";
+      type uint32;
+      description "value";
+    }
+
+    grouping inner-ext {
+        ext:simple-ext-w-arg "value:test";
+
+        leaf inner-value {
+          ext:simple-ext-w-arg "key:inner-value";
+          type uint32;
+          description "value";
+        }
+    }
+
+    container cont-ext {
+        ext:simple-ext-w-arg "value:test";
+
+        leaf inner-value {
+            ext:simple-ext-w-arg "value:test";
+            type string;
+        }
+    }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/foo.yang b/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/foo.yang
new file mode 100644 (file)
index 0000000..6854e33
--- /dev/null
@@ -0,0 +1,49 @@
+module foo {
+    yang-version 1;
+    namespace "urn:opendaylight.foo";
+    prefix "foo";
+
+    revision "2015-07-08" {
+    }
+
+    container x {
+        leaf x15 {
+            type string;
+        }
+
+        list x10 {}
+
+        container x5 {}
+
+        leaf-list x1 {
+            type string;
+        }
+
+        uses a;
+
+        container x2 {}
+
+        uses b;
+
+        container x3 {}
+    }
+
+
+    grouping a {
+        anyxml a5;
+        anyxml a1;
+    }
+
+    grouping b {
+        anyxml b5;
+        anyxml b1;
+    }
+
+    augment /x  {
+        leaf ax15 {
+            type string;
+        }
+        container ax5 {}
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/importedtest.yang b/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/importedtest.yang
new file mode 100644 (file)
index 0000000..9aacac9
--- /dev/null
@@ -0,0 +1,15 @@
+module importedtest {
+    yang-version 1;
+    namespace "urn:imptst:yang";
+    prefix "imptst";
+
+    description "This is a to be imported test module";
+
+    revision 2015-03-20;
+
+    container myimportedcontainer {
+        leaf myimportedleaf {
+            type string;
+        }
+    }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/simple-nodes-semantic.yang b/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/simple-nodes-semantic.yang
new file mode 100644 (file)
index 0000000..dcc8578
--- /dev/null
@@ -0,0 +1,52 @@
+module simple-nodes {
+    yang-version 1;
+    namespace "urn:opendaylight:"+
+        "simple-nodes";
+    prefix "sn";
+
+    organization "opendaylight";
+
+    import test {
+        prefix tst;
+    }
+
+    description
+        "test file containing yang data nodes";
+
+    revision "2013-07-30" {
+        description
+            "Initial revision.";
+        reference "will be defined";
+    }
+
+
+    typedef mytype {
+        type string;
+    }
+
+    // NOTE: simple comment
+
+
+
+    anyxml data {
+        config false;
+         description "anyxml desc";
+         if-feature has-name;
+         mandatory true;
+         must "ifType != 'ethernet' or " +
+                      "(ifType = 'ethernet' and ifMTU = 1500)" {
+            error-message "An ethernet MTU must be 1500";
+         }
+         must "ifType != 'atm' or " +
+                      "(ifType = 'atm' and ifMTU <= 17966 and ifMTU >= 64)" {
+                     error-app-tag "anyxml data error-app-tag";
+                     error-message "An atm MTU must be  64 .. 17966";
+                     description "an error occured in data";
+                     reference "data must ref";
+                }
+         reference "data ref";
+         status obsolete;
+         when "class != 'wheel'";
+    }
+
+}
diff --git a/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/test.yang b/yang/yang-parser-impl/src/test/resources/semantic-statement-parser/test.yang
new file mode 100644 (file)
index 0000000..6c5fef5
--- /dev/null
@@ -0,0 +1,19 @@
+module test {
+    yang-version 1;
+    namespace "urn:tst:yang";
+    prefix "tst";
+
+    import importedtest {
+            prefix "imptst";
+    }
+
+    description "This is a test module";
+
+    revision 2015-03-04;
+
+    container mycontainer {
+        leaf myleaf {
+            type string;
+        }
+    }
+}
\ No newline at end of file
diff --git a/yang/yang-parser-impl/src/test/resources/stmt-test/effective-build/simple-module.yang b/yang/yang-parser-impl/src/test/resources/stmt-test/effective-build/simple-module.yang
new file mode 100644 (file)
index 0000000..0cd39fd
--- /dev/null
@@ -0,0 +1,30 @@
+module simple-module {
+
+    namespace "simple.yang";
+    prefix sim;
+
+    container root-container {
+        container sim:sub-container {
+            container sub-sub-container {
+            }
+        }
+    }
+    
+//    container sim:root-container2 {
+//        container sub-container2 {
+//            container "sim:sub-sub-container2" {
+//            }
+//        }
+//    }
+    
+    container sim:root-container2 {
+        uses grp;
+    }
+    
+    grouping grp{
+        container sub-container2 {
+            container "sim:sub-sub-container2" {
+            }
+        }
+    }
+}