*/
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.spi.meta.AbstractStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.BaseStringStatementSupport;
+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 AbstractStatementSupport<String, DescriptionStatement,
- EffectiveStatement<String, DescriptionStatement>> {
+public final class DescriptionStatementSupport
+ extends BaseStringStatementSupport<DescriptionStatement, DescriptionEffectiveStatement> {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
YangStmtMapping.DESCRIPTION).build();
+ private static final DescriptionStatementSupport INSTANCE = new DescriptionStatementSupport();
- public DescriptionStatementSupport() {
- super(YangStmtMapping.DESCRIPTION);
+ private DescriptionStatementSupport() {
+ super(YangStmtMapping.DESCRIPTION, StatementPolicy.contextIndependent());
+ }
+
+ public static DescriptionStatementSupport getInstance() {
+ return INSTANCE;
}
@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 new RegularDescriptionStatement(ctx.getRawArgument(), substatements);
}
@Override
- public EffectiveStatement<String, DescriptionStatement> createEffective(
- final StmtContext<String, DescriptionStatement, EffectiveStatement<String, DescriptionStatement>> ctx) {
- return new DescriptionEffectiveStatementImpl(ctx);
+ protected DescriptionStatement createEmptyDeclared(final StmtContext<String, DescriptionStatement, ?> ctx) {
+ return new EmptyDescriptionStatement(ctx.getRawArgument());
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
- return SUBSTATEMENT_VALIDATOR;
+ protected DescriptionEffectiveStatement createEffective(final Current<String, DescriptionStatement> stmt,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return substatements.isEmpty() ? new EmptyDescriptionEffectiveStatement(stmt.declared())
+ : new RegularDescriptionEffectiveStatement(stmt.declared(), substatements);
}
-}
\ No newline at end of file
+}