BUG-4688: Rename StmtContext.Mutable.addRequiredModule()
[yangtools.git] / yang / yang-parser-impl / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / rfc6020 / BelongsToStatementImpl.java
index 8a138f36be4e4cf45bab0048729aa5552f5213fa..3cdfbba48d3ae50f87547ac513789ca6d820cbf0 100644 (file)
@@ -16,6 +16,7 @@ import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
 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.util.ModuleIdentifierImpl;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractDeclaredStatement;
 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
@@ -23,8 +24,10 @@ 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.InferenceContext;
+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.meta.StmtContextUtils;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.source.BelongsToModuleContext;
@@ -69,17 +72,17 @@ public class BelongsToStatementImpl extends AbstractDeclaredStatement<String>
         @Override
         public void onPreLinkageDeclared(final StmtContext.Mutable<String, BelongsToStatement,
                 EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
-            belongsToCtx.addRequiredModule(getModuleIdentifier(belongsToCtx));
+            belongsToCtx.addRequiredSource(RevisionSourceIdentifier.create(belongsToCtx.getStatementArgument()));
         }
 
         @Override
-        public void onLinkageDeclared(
-                final StmtContext.Mutable<String, BelongsToStatement, EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
+        public void onLinkageDeclared(final Mutable<String, BelongsToStatement,
+                EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
             ModelActionBuilder belongsToAction = belongsToCtx.newInferenceAction(ModelProcessingPhase.SOURCE_LINKAGE);
 
             final ModuleIdentifier belongsToModuleIdentifier = getModuleIdentifier(belongsToCtx);
-            final ModelActionBuilder.Prerequisite<StmtContext<?, ?, ?>> belongsToPrereq = belongsToAction.requiresCtx(
-                belongsToCtx, ModuleNamespaceForBelongsTo.class, belongsToModuleIdentifier.getName(),
+            final Prerequisite<StmtContext<?, ?, ?>> belongsToPrereq = belongsToAction.requiresCtx(belongsToCtx,
+                ModuleNamespaceForBelongsTo.class, belongsToModuleIdentifier.getName(),
                 ModelProcessingPhase.SOURCE_LINKAGE);
 
             belongsToAction.apply(new InferenceAction() {
@@ -103,10 +106,9 @@ public class BelongsToStatementImpl extends AbstractDeclaredStatement<String>
             });
         }
 
-        private static ModuleIdentifier getModuleIdentifier(
-                final StmtContext.Mutable<String, BelongsToStatement, EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
-            String moduleName = belongsToCtx.getStatementArgument();
-            return ModuleIdentifierImpl.create(moduleName, Optional.empty(),
+        private static ModuleIdentifier getModuleIdentifier(final Mutable<String, BelongsToStatement,
+                EffectiveStatement<String, BelongsToStatement>> belongsToCtx) {
+            return ModuleIdentifierImpl.create(belongsToCtx.getStatementArgument(), Optional.empty(),
                 Optional.of(SimpleDateFormatUtil.DEFAULT_BELONGS_TO_DATE));
         }
 
@@ -127,5 +129,4 @@ public class BelongsToStatementImpl extends AbstractDeclaredStatement<String>
     public PrefixStatement getPrefix() {
         return firstDeclared(PrefixStatement.class);
     }
-
 }