Migrate coerceStatementArgument() callers
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / revision_date / RevisionDateStatementSupport.java
index 8fa8e7840b1c7e5a454dcf907fa9aadd329f1391..1b75579cce48eb032f7d8fc8af02968ced7258b3 100644 (file)
@@ -7,24 +7,28 @@
  */
 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.revision_date;
 
+import com.google.common.collect.ImmutableList;
 import java.time.format.DateTimeParseException;
 import org.opendaylight.yangtools.yang.common.Revision;
 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
+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.stmt.RevisionDateEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.RevisionDateStatement;
-import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
 import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
 public final class RevisionDateStatementSupport
-        extends AbstractStatementSupport<Revision, RevisionDateStatement, RevisionDateEffectiveStatement> {
+        extends BaseStatementSupport<Revision, RevisionDateStatement, RevisionDateEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
             SubstatementValidator.builder(YangStmtMapping.REVISION_DATE).build();
     private static final RevisionDateStatementSupport INSTANCE = new RevisionDateStatementSupport();
 
     private RevisionDateStatementSupport() {
-        super(YangStmtMapping.REVISION_DATE);
+        super(YangStmtMapping.REVISION_DATE, CopyPolicy.CONTEXT_INDEPENDENT);
     }
 
     public static RevisionDateStatementSupport getInstance() {
@@ -36,24 +40,31 @@ public final class RevisionDateStatementSupport
         try {
             return Revision.of(value);
         } catch (DateTimeParseException e) {
-            throw new SourceException(ctx.getStatementSourceReference(), e,
+            throw new SourceException(ctx.sourceReference(), e,
                 "Revision value %s is not in required format yyyy-MM-dd", value);
         }
     }
 
     @Override
-    public RevisionDateStatement createDeclared(final StmtContext<Revision, RevisionDateStatement, ?> ctx) {
-        return new RevisionDateStatementImpl(ctx);
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    public RevisionDateEffectiveStatement createEffective(
-            final StmtContext<Revision, RevisionDateStatement, RevisionDateEffectiveStatement> ctx) {
-        return new RevisionDateEffectiveStatementImpl(ctx);
+    protected RevisionDateStatement createDeclared(final StmtContext<Revision, RevisionDateStatement, ?> ctx,
+            final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+        return new RegularRevisionDateStatement(ctx.getArgument(), substatements);
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected RevisionDateStatement createEmptyDeclared(final StmtContext<Revision, RevisionDateStatement, ?> ctx) {
+        return new EmptyRevisionDateStatement(ctx.getArgument());
+    }
+
+    @Override
+    protected RevisionDateEffectiveStatement createEffective(final Current<Revision, RevisionDateStatement> stmt,
+            final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+        return substatements.isEmpty() ? new EmptyRevisionDateEffectiveStatement(stmt.declared())
+            : new RegularRevisionDateEffectiveStatement(stmt.declared(), substatements);
     }
 }
\ No newline at end of file