Move more statements
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / choice / ChoiceStatementSupport.java
index 6258a056922d795c3d56e719f12c79e9f3927d08..48449760d1138211e72f1c7b9b921a05f1a34462 100644 (file)
@@ -27,11 +27,13 @@ import org.opendaylight.yangtools.yang.model.api.stmt.ChoiceStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DefaultEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.MandatoryEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.StatusEffectiveStatement;
+import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
+import org.opendaylight.yangtools.yang.model.ri.stmt.EffectiveStatements;
+import org.opendaylight.yangtools.yang.model.spi.meta.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
+import org.opendaylight.yangtools.yang.model.spi.meta.SubstatementIndexingException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.reactor.YangValidationBundles;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseSchemaTreeStatementSupport;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.EffectiveStatementMixins.EffectiveStatementWithFlags.FlagsBuilder;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.SubstatementIndexingException;
 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.case_.CaseStatementSupport;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractSchemaTreeStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
 import org.opendaylight.yangtools.yang.parser.spi.meta.ImplicitParentAwareStatementSupport;
 import org.opendaylight.yangtools.yang.parser.spi.meta.InferenceException;
@@ -42,7 +44,7 @@ import org.opendaylight.yangtools.yang.parser.spi.source.SourceException;
 
 @Beta
 public final class ChoiceStatementSupport
-        extends BaseSchemaTreeStatementSupport<ChoiceStatement, ChoiceEffectiveStatement>
+        extends AbstractSchemaTreeStatementSupport<ChoiceStatement, ChoiceEffectiveStatement>
         implements ImplicitParentAwareStatementSupport {
     private static final @NonNull ChoiceStatementSupport RFC6020_INSTANCE = new ChoiceStatementSupport(
         SubstatementValidator.builder(YangStmtMapping.CHOICE)
@@ -114,20 +116,19 @@ public final class ChoiceStatementSupport
     @Override
     protected ChoiceStatement createDeclared(@NonNull final StmtContext<QName, ChoiceStatement, ?> ctx,
             final ImmutableList<? extends DeclaredStatement<?>> substatements) {
-        return new RegularChoiceStatement(ctx.getArgument(), substatements);
+        return DeclaredStatements.createChoice(ctx.getArgument(), substatements);
     }
 
     @Override
     protected ChoiceStatement createEmptyDeclared(@NonNull final StmtContext<QName, ChoiceStatement, ?> ctx) {
-        return new EmptyChoiceStatement(ctx.getArgument());
+        return DeclaredStatements.createChoice(ctx.getArgument());
     }
 
     @Override
     public ChoiceEffectiveStatement copyEffective(final Current<QName, ChoiceStatement> stmt,
             final ChoiceEffectiveStatement original) {
-        return new ChoiceEffectiveStatementImpl((ChoiceEffectiveStatementImpl) original,
-            computeFlags(stmt, original.effectiveSubstatements()), stmt.wrapSchemaPath(),
-            (ChoiceSchemaNode) stmt.original());
+        return EffectiveStatements.copyChoice(original, stmt.effectivePath(),
+            computeFlags(stmt, original.effectiveSubstatements()), stmt.original(ChoiceSchemaNode.class));
     }
 
     @Override
@@ -151,8 +152,8 @@ public final class ChoiceStatementSupport
         }
 
         try {
-            return new ChoiceEffectiveStatementImpl(stmt.declared(), substatements, computeFlags(stmt, substatements),
-                stmt.wrapSchemaPath(), defaultCase, (ChoiceSchemaNode) stmt.original());
+            return EffectiveStatements.createChoice(stmt.declared(), stmt.effectivePath(),
+                computeFlags(stmt, substatements), substatements, defaultCase, stmt.original(ChoiceSchemaNode.class));
         } catch (SubstatementIndexingException e) {
             throw new SourceException(e.getMessage(), stmt, e);
         }