*/
package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.reference;
+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.ReferenceEffectiveStatement;
import org.opendaylight.yangtools.yang.model.api.stmt.ReferenceStatement;
-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 ReferenceStatementSupport extends AbstractStatementSupport<String, ReferenceStatement,
- EffectiveStatement<String, ReferenceStatement>> {
+public final class ReferenceStatementSupport
+ extends BaseStringStatementSupport<ReferenceStatement, ReferenceEffectiveStatement> {
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
YangStmtMapping.REFERENCE)
.build();
}
@Override
- public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
- return value;
+ protected SubstatementValidator getSubstatementValidator() {
+ return SUBSTATEMENT_VALIDATOR;
}
@Override
- public ReferenceStatement createDeclared(final StmtContext<String, ReferenceStatement, ?> ctx) {
- return new ReferenceStatementImpl(ctx);
+ protected ReferenceStatement createDeclared(final StmtContext<String, ReferenceStatement, ?> ctx,
+ final ImmutableList<? extends DeclaredStatement<?>> substatements) {
+ return new RegularReferenceStatement(ctx.getRawArgument(), substatements);
}
@Override
- public EffectiveStatement<String, ReferenceStatement> createEffective(
- final StmtContext<String, ReferenceStatement, EffectiveStatement<String, ReferenceStatement>> ctx) {
- return new ReferenceEffectiveStatementImpl(ctx);
+ protected ReferenceStatement createEmptyDeclared(final StmtContext<String, ReferenceStatement, ?> ctx) {
+ return new EmptyReferenceStatement(ctx.getRawArgument());
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
- return SUBSTATEMENT_VALIDATOR;
+ protected ReferenceEffectiveStatement createEffective(final Current<String, ReferenceStatement> stmt,
+ final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
+ return substatements.isEmpty() ? new EmptyReferenceEffectiveStatement(stmt.declared())
+ : new RegularReferenceEffectiveStatement(stmt.declared(), substatements);
}
-}
\ No newline at end of file
+}