Move OpenConfigVersion support
[yangtools.git] / parser / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / reactor / RFC7950Reactors.java
index 0822ec6978b9b305a7ac78359060a3bad3a0f053..e756825b2c6d710a6847caccc334659d5b0b7356 100644 (file)
@@ -16,7 +16,6 @@ import com.google.common.collect.Sets;
 import org.eclipse.jdt.annotation.NonNull;
 import org.opendaylight.yangtools.yang.common.YangVersion;
 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
-import org.opendaylight.yangtools.yang.parser.openconfig.stmt.OpenConfigVersionSupport;
 import org.opendaylight.yangtools.yang.parser.rfc7950.namespace.ModuleQNameToPrefix;
 import org.opendaylight.yangtools.yang.parser.rfc7950.namespace.YangNamespaceContextNamespace;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.augment.AugmentImplicitHandlingNamespace;
@@ -29,7 +28,6 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.if_feature.IfFeatureS
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.if_feature.IfFeatureStatementRFC7950Support;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.import_.ImportStatementSupport;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.import_.ImportedVersionNamespace;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.leaf_list.LeafListStatementSupport;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.list.ConfigListWarningNamespace;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.list.ListStatementSupport;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.ActionStatementSupport;
@@ -57,6 +55,7 @@ import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.IdentityStatemen
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.IncludeStatementSupport;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.InputStatementSupport;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.KeyStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.LeafListStatementSupport;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.LeafStatementSupport;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.LengthStatementSupport;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta.MandatoryStatementSupport;
@@ -111,8 +110,6 @@ import org.opendaylight.yangtools.yang.parser.spi.SchemaTreeNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.SubmoduleNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.TypeNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionModuleNamespace;
-import org.opendaylight.yangtools.yang.parser.spi.meta.SemanticVersionNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementDefinitionNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupportBundle;
 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToModuleContext;
@@ -120,7 +117,6 @@ import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModule
 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToPrefixToModuleName;
 import org.opendaylight.yangtools.yang.parser.spi.source.ImpPrefixToNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.source.ImportPrefixToModuleCtx;
-import org.opendaylight.yangtools.yang.parser.spi.source.ImportPrefixToSemVerSourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.source.ImportedModuleContext;
 import org.opendaylight.yangtools.yang.parser.spi.source.IncludedModuleContext;
 import org.opendaylight.yangtools.yang.parser.spi.source.IncludedSubmoduleNameToModuleCtx;
@@ -210,11 +206,6 @@ public final class RFC7950Reactors {
 
     private static StatementSupportBundle stmtDefBundle(final StatementSupportBundle linkageBundle,
             final YangParserConfiguration config) {
-        final InputStatementSupport rfc6020input = InputStatementSupport.rfc6020Instance(config);
-        final InputStatementSupport rfc7950input = InputStatementSupport.rfc7950Instance(config);
-        final OutputStatementSupport rfc6020output = OutputStatementSupport.rfc6020Instance(config);
-        final OutputStatementSupport rfc7950output = OutputStatementSupport.rfc7950Instance(config);
-
         return StatementSupportBundle.derivedFrom(linkageBundle)
             .addSupport(new YinElementStatementSupport(config))
             .addSupport(new ArgumentStatementSupport(config))
@@ -252,13 +243,13 @@ public final class RFC7950Reactors {
             .addVersionSpecificSupport(VERSION_1_1, ListStatementSupport.rfc7950Instance(config))
             .addSupport(ConfigListWarningNamespace.BEHAVIOUR)
             .addSupport(new UniqueStatementSupport(config))
-            .addVersionSpecificSupport(VERSION_1_1, new ActionStatementSupport(config, rfc7950input, rfc7950output))
-            .addVersionSpecificSupport(VERSION_1, new RpcStatementSupport(config, rfc6020input, rfc6020output))
-            .addVersionSpecificSupport(VERSION_1_1, new RpcStatementSupport(config, rfc7950input, rfc7950output))
-            .addVersionSpecificSupport(VERSION_1, rfc6020input)
-            .addVersionSpecificSupport(VERSION_1_1, rfc7950input)
-            .addVersionSpecificSupport(VERSION_1, rfc6020output)
-            .addVersionSpecificSupport(VERSION_1_1, rfc7950output)
+            .addVersionSpecificSupport(VERSION_1_1, new ActionStatementSupport(config))
+            .addVersionSpecificSupport(VERSION_1, new RpcStatementSupport(config))
+            .addVersionSpecificSupport(VERSION_1_1, new RpcStatementSupport(config))
+            .addVersionSpecificSupport(VERSION_1, InputStatementSupport.rfc6020Instance(config))
+            .addVersionSpecificSupport(VERSION_1_1, InputStatementSupport.rfc7950Instance(config))
+            .addVersionSpecificSupport(VERSION_1, OutputStatementSupport.rfc6020Instance(config))
+            .addVersionSpecificSupport(VERSION_1_1, OutputStatementSupport.rfc7950Instance(config))
             .addVersionSpecificSupport(VERSION_1, new NotificationStatementRFC6020Support(config))
             .addVersionSpecificSupport(VERSION_1_1, new NotificationStatementRFC7950Support(config))
             .addSupport(new FractionDigitsStatementSupport(config))
@@ -290,7 +281,7 @@ public final class RFC7950Reactors {
 
     public static @NonNull CustomCrossSourceStatementReactorBuilder defaultReactorBuilder(
             final YangParserConfiguration config) {
-        return addExtensions(vanillaReactorBuilder(config), config);
+        return vanillaReactorBuilder(config);
     }
 
     public static @NonNull CustomCrossSourceStatementReactorBuilder defaultReactorBuilder(
@@ -300,18 +291,7 @@ public final class RFC7950Reactors {
 
     public static @NonNull CustomCrossSourceStatementReactorBuilder defaultReactorBuilder(
             final YangXPathParserFactory xpathFactory, final YangParserConfiguration config) {
-        return addExtensions(vanillaReactorBuilder(xpathFactory, config), config);
-    }
-
-    private static @NonNull CustomCrossSourceStatementReactorBuilder addExtensions(
-            final @NonNull CustomCrossSourceStatementReactorBuilder builder, final YangParserConfiguration config) {
-        return builder
-                // Semantic version support
-                .addStatementSupport(ModelProcessingPhase.SOURCE_LINKAGE, new OpenConfigVersionSupport(config))
-                .addNamespaceSupport(ModelProcessingPhase.SOURCE_LINKAGE, SemanticVersionNamespace.BEHAVIOUR)
-                .addNamespaceSupport(ModelProcessingPhase.SOURCE_LINKAGE, SemanticVersionModuleNamespace.BEHAVIOUR)
-                .addNamespaceSupport(ModelProcessingPhase.SOURCE_LINKAGE,
-                    ImportPrefixToSemVerSourceIdentifier.BEHAVIOUR);
+        return vanillaReactorBuilder(xpathFactory, config);
     }
 
     /**
@@ -380,19 +360,16 @@ public final class RFC7950Reactors {
 
     private static @NonNull StatementSupportBundle fullDeclarationBundle(final StatementSupportBundle stmtDefBundle,
             final XPathSupport xpathSupport, final YangParserConfiguration config) {
-        final CaseStatementSupport rfc6020case = CaseStatementSupport.rfc6020Instance(config);
-        final CaseStatementSupport rfc7950case = CaseStatementSupport.rfc7950Instance(config);
-
         return StatementSupportBundle.derivedFrom(stmtDefBundle)
             .addSupport(new LeafStatementSupport(config))
             .addSupport(new ConfigStatementSupport(config))
             .addSupport(new DeviationStatementSupport(config))
             .addVersionSpecificSupport(VERSION_1, new DeviateStatementRFC6020Support(config))
             .addVersionSpecificSupport(VERSION_1_1, new DeviateStatementRFC7950Support(config))
-            .addVersionSpecificSupport(VERSION_1, ChoiceStatementSupport.rfc6020Instance(config, rfc6020case))
-            .addVersionSpecificSupport(VERSION_1_1, ChoiceStatementSupport.rfc7950Instance(config, rfc7950case))
-            .addVersionSpecificSupport(VERSION_1, rfc6020case)
-            .addVersionSpecificSupport(VERSION_1_1, rfc7950case)
+            .addVersionSpecificSupport(VERSION_1, ChoiceStatementSupport.rfc6020Instance(config))
+            .addVersionSpecificSupport(VERSION_1_1, ChoiceStatementSupport.rfc7950Instance(config))
+            .addVersionSpecificSupport(VERSION_1, CaseStatementSupport.rfc6020Instance(config))
+            .addVersionSpecificSupport(VERSION_1_1, CaseStatementSupport.rfc7950Instance(config))
             .addSupport(new MustStatementSupport(xpathSupport, config))
             .addSupport(new MandatoryStatementSupport(config))
             .addSupport(new AnyxmlStatementSupport(config))