Split out yang-model-ri
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / description / DescriptionStatementSupport.java
index c7d7a65613d151e3ac126fc144e7b37183b96261..8238c2b776303ea7e0387113d7d2753d27cd9407 100644 (file)
@@ -9,21 +9,25 @@ package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.description;
 
 import com.google.common.collect.ImmutableList;
 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.DescriptionEffectiveStatement;
 import org.opendaylight.yangtools.yang.model.api.stmt.DescriptionStatement;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
+import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
+import org.opendaylight.yangtools.yang.model.ri.stmt.EffectiveStatements;
+import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStringStatementSupport;
+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;
 
 public final class DescriptionStatementSupport
-        extends BaseStringStatementSupport<DescriptionStatement, DescriptionEffectiveStatement> {
+        extends AbstractStringStatementSupport<DescriptionStatement, DescriptionEffectiveStatement> {
     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
         YangStmtMapping.DESCRIPTION).build();
     private static final DescriptionStatementSupport INSTANCE = new DescriptionStatementSupport();
 
     private DescriptionStatementSupport() {
-        super(YangStmtMapping.DESCRIPTION);
+        super(YangStmtMapping.DESCRIPTION, StatementPolicy.contextIndependent());
     }
 
     public static DescriptionStatementSupport getInstance() {
@@ -31,32 +35,24 @@ public final class DescriptionStatementSupport
     }
 
     @Override
-    public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
-        return value;
+    protected SubstatementValidator getSubstatementValidator() {
+        return SUBSTATEMENT_VALIDATOR;
     }
 
     @Override
-    public DescriptionStatement createDeclared(final StmtContext<String, DescriptionStatement, ?> ctx) {
-        return new DescriptionStatementImpl(ctx);
+    protected DescriptionStatement createDeclared(final StmtContext<String, DescriptionStatement, ?> ctx,
+            final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+        return DeclaredStatements.createDescription(ctx.getRawArgument(), substatements);
     }
 
     @Override
-    protected SubstatementValidator getSubstatementValidator() {
-        return SUBSTATEMENT_VALIDATOR;
+    protected DescriptionStatement createEmptyDeclared(final StmtContext<String, DescriptionStatement, ?> ctx) {
+        return DeclaredStatements.createDescription(ctx.getRawArgument());
     }
 
     @Override
-    protected DescriptionEffectiveStatement createEffective(
-            final StmtContext<String, DescriptionStatement, DescriptionEffectiveStatement> ctx,
-            final DescriptionStatement declared,
+    protected DescriptionEffectiveStatement createEffective(final Current<String, DescriptionStatement> stmt,
             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
-        return new RegularDescriptionEffectiveStatement(declared, substatements);
-    }
-
-    @Override
-    protected DescriptionEffectiveStatement createEmptyEffective(
-            final StmtContext<String, DescriptionStatement, DescriptionEffectiveStatement> ctx,
-            final DescriptionStatement declared) {
-        return new EmptyDescriptionEffectiveStatement(declared);
+        return EffectiveStatements.createDescription(stmt.declared(), substatements);
     }
-}
\ No newline at end of file
+}