BUG-4688: Switch BelongsToModuleContext to SourceIdentifier 47/64547/5
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 19 Oct 2017 18:18:25 +0000 (20:18 +0200)
committerRobert Varga <robert.varga@pantheon.tech>
Fri, 20 Oct 2017 10:00:25 +0000 (12:00 +0200)
Instead of using deprecated ModuleIdentifier, use SourceIdentifier.

Change-Id: Ifb3dc771db3664260b44e5e824b5aa769811bd0a
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
yang/yang-parser-impl/src/main/java/org/opendaylight/yangtools/yang/parser/stmt/rfc6020/BelongsToStatementImpl.java
yang/yang-parser-spi/src/main/java/org/opendaylight/yangtools/yang/parser/spi/source/BelongsToModuleContext.java

index 3cdfbba48d3ae50f87547ac513789ca6d820cbf0..bba1fd029cb746e58b492736178fe70ac1a79830 100644 (file)
@@ -17,6 +17,7 @@ import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.BelongsToStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.PrefixStatement;
 import org.opendaylight.yangtools.yang.model.repo.api.RevisionSourceIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.model.util.ModuleIdentifierImpl;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
@@ -72,7 +73,7 @@ public class BelongsToStatementImpl extends AbstractDeclaredStatement<String>
         @Override
         public void onPreLinkageDeclared(final StmtContext.Mutable<String, BelongsToStatement,
                 EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
-            belongsToCtx.addRequiredSource(RevisionSourceIdentifier.create(belongsToCtx.getStatementArgument()));
+            belongsToCtx.addRequiredSource(getSourceIdentifier(belongsToCtx));
         }
 
         @Override
@@ -80,7 +81,10 @@ public class BelongsToStatementImpl extends AbstractDeclaredStatement<String>
                 EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
             ModelActionBuilder belongsToAction = belongsToCtx.newInferenceAction(ModelProcessingPhase.SOURCE_LINKAGE);
 
-            final ModuleIdentifier belongsToModuleIdentifier = getModuleIdentifier(belongsToCtx);
+            final SourceIdentifier belongsToSourceIdentifier = getSourceIdentifier(belongsToCtx);
+            final ModuleIdentifier belongsToModuleIdentifier = ModuleIdentifierImpl.create(
+                belongsToCtx.getStatementArgument(), Optional.empty(),
+                Optional.of(SimpleDateFormatUtil.DEFAULT_BELONGS_TO_DATE));
             final Prerequisite<StmtContext<?, ?, ?>> belongsToPrereq = belongsToAction.requiresCtx(belongsToCtx,
                 ModuleNamespaceForBelongsTo.class, belongsToModuleIdentifier.getName(),
                 ModelProcessingPhase.SOURCE_LINKAGE);
@@ -90,7 +94,7 @@ public class BelongsToStatementImpl extends AbstractDeclaredStatement<String>
                 public void apply(final InferenceContext ctx) {
                     StmtContext<?, ?, ?> belongsToModuleCtx = belongsToPrereq.resolve(ctx);
 
-                    belongsToCtx.addToNs(BelongsToModuleContext.class, belongsToModuleIdentifier, belongsToModuleCtx);
+                    belongsToCtx.addToNs(BelongsToModuleContext.class, belongsToSourceIdentifier, belongsToModuleCtx);
                     belongsToCtx.addToNs(BelongsToPrefixToModuleIdentifier.class,
                         StmtContextUtils.findFirstDeclaredSubstatement(belongsToCtx, PrefixStatement.class)
                         .getStatementArgument(), belongsToModuleIdentifier);
@@ -106,10 +110,9 @@ public class BelongsToStatementImpl extends AbstractDeclaredStatement<String>
             });
         }
 
-        private static ModuleIdentifier getModuleIdentifier(final Mutable<String, BelongsToStatement,
+        private static SourceIdentifier getSourceIdentifier(final StmtContext<String, BelongsToStatement,
                 EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
-            return ModuleIdentifierImpl.create(belongsToCtx.getStatementArgument(), Optional.empty(),
-                Optional.of(SimpleDateFormatUtil.DEFAULT_BELONGS_TO_DATE));
+            return RevisionSourceIdentifier.create(belongsToCtx.getStatementArgument());
         }
 
         @Override
index 86c0d5c73a33dfc5cfa056069d719a4731d458d4..3c78266aad9337f96e63ef19b9a52b56251edc35 100644 (file)
@@ -7,12 +7,12 @@
  */
 package org.opendaylight.yangtools.yang.parser.spi.source;
 
-import org.opendaylight.yangtools.yang.model.api.ModuleIdentifier;
+import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ImportedNamespaceContext;
 
 /**
- * namespace key class for storing belongs-to statements in Yang model storage.
+ * Namespace key class for storing belongs-to statements in YANG model storage.
  */
-public interface BelongsToModuleContext extends ImportedNamespaceContext<ModuleIdentifier> {
+public interface BelongsToModuleContext extends ImportedNamespaceContext<SourceIdentifier> {
 
 }