import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.grouping.GroupingStatementRFC7950Support;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.identity.IdentityStatementRFC6020Support;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.identity.IdentityStatementRFC7950Support;
-import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.if_feature.IfFeatureStatementSupport;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.if_feature.IfFeatureStatementRFC6020Support;
+import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.if_feature.IfFeatureStatementRFC7950Support;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.import_.ImportStatementRFC6020Support;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.import_.ImportStatementRFC7950Support;
import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.include.IncludeStatementRFC6020Support;
.addSupport(AnyxmlStatementSupport.getInstance())
.addVersionSpecificSupport(VERSION_1_1, AnydataStatementSupport.getInstance())
.addSupport(FeatureNamespace.BEHAVIOUR)
- .addSupport(IfFeatureStatementSupport.getInstance())
+ .addVersionSpecificSupport(VERSION_1, IfFeatureStatementRFC6020Support.getInstance())
+ .addVersionSpecificSupport(VERSION_1_1, IfFeatureStatementRFC7950Support.getInstance())
.addSupport(UsesStatementSupport.getInstance())
.addSupport(GroupingNamespace.BEHAVIOUR)
.addSupport(ErrorMessageStatementSupport.getInstance())
import java.util.Map;
import java.util.Set;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.YangVersion;
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.parser.spi.meta.ModelProcessingPhase;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext.Mutable;
-import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public final class IfFeatureStatementSupport
+abstract class AbstractIfFeatureStatementSupport
extends BaseStatementSupport<IfFeatureExpr, IfFeatureStatement, IfFeatureEffectiveStatement> {
- private static final Logger LOG = LoggerFactory.getLogger(IfFeatureStatementSupport.class);
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractIfFeatureStatementSupport.class);
private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
YangStmtMapping.IF_FEATURE)
.build();
- private static final IfFeatureStatementSupport INSTANCE = new IfFeatureStatementSupport();
- private IfFeatureStatementSupport() {
+ AbstractIfFeatureStatementSupport() {
super(YangStmtMapping.IF_FEATURE, CopyPolicy.CONTEXT_INDEPENDENT);
}
- public static IfFeatureStatementSupport getInstance() {
- return INSTANCE;
- }
-
- @Override
- public IfFeatureExpr parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
- if (YangVersion.VERSION_1_1.equals(ctx.getRootVersion())) {
- return IfFeaturePredicateVisitor.parseIfFeatureExpression(ctx, value);
- }
- return IfFeatureExpr.isPresent(StmtContextUtils.parseNodeIdentifier(ctx, value));
- }
-
@Override
- public void onFullDefinitionDeclared(
+ public final void onFullDefinitionDeclared(
final Mutable<IfFeatureExpr, IfFeatureStatement, IfFeatureEffectiveStatement> stmt) {
super.onFullDefinitionDeclared(stmt);
}
@Override
- protected SubstatementValidator getSubstatementValidator() {
+ protected final SubstatementValidator getSubstatementValidator() {
return SUBSTATEMENT_VALIDATOR;
}
@Override
- protected IfFeatureStatement createDeclared(final StmtContext<IfFeatureExpr, IfFeatureStatement, ?> ctx,
+ protected final IfFeatureStatement createDeclared(final StmtContext<IfFeatureExpr, IfFeatureStatement, ?> ctx,
final ImmutableList<? extends DeclaredStatement<?>> substatements) {
return new RegularIfFeatureStatement(ctx.coerceRawStatementArgument(), ctx.coerceStatementArgument(),
substatements);
}
@Override
- protected IfFeatureStatement createEmptyDeclared(final StmtContext<IfFeatureExpr, IfFeatureStatement, ?> ctx) {
+ protected final IfFeatureStatement createEmptyDeclared(
+ final StmtContext<IfFeatureExpr, IfFeatureStatement, ?> ctx) {
return new EmptyIfFeatureStatement(ctx.coerceRawStatementArgument(), ctx.coerceStatementArgument());
}
@Override
- protected IfFeatureEffectiveStatement createEffective(final Current<IfFeatureExpr, IfFeatureStatement> stmt,
+ protected final IfFeatureEffectiveStatement createEffective(final Current<IfFeatureExpr, IfFeatureStatement> stmt,
final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
return substatements.isEmpty() ? new EmptyIfFeatureEffectiveStatement(stmt.declared())
: new RegularIfFeatureEffectiveStatement(stmt.declared(), substatements);
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.if_feature;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureExpr;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
+
+public final class IfFeatureStatementRFC6020Support extends AbstractIfFeatureStatementSupport {
+ private static final IfFeatureStatementRFC6020Support INSTANCE = new IfFeatureStatementRFC6020Support();
+
+ private IfFeatureStatementRFC6020Support() {
+ // Hidden on purpose
+ }
+
+ public static IfFeatureStatementRFC6020Support getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public IfFeatureExpr parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+ return IfFeatureExpr.isPresent(StmtContextUtils.parseNodeIdentifier(ctx, value));
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2020 PANTHEON.tech, s.r.o. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.if_feature;
+
+import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureExpr;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
+
+public final class IfFeatureStatementRFC7950Support extends AbstractIfFeatureStatementSupport {
+ private static final IfFeatureStatementRFC7950Support INSTANCE = new IfFeatureStatementRFC7950Support();
+
+ private IfFeatureStatementRFC7950Support() {
+ // Hidden on purpose
+ }
+
+ public static IfFeatureStatementRFC7950Support getInstance() {
+ return INSTANCE;
+ }
+
+ @Override
+ public IfFeatureExpr parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
+ return IfFeaturePredicateVisitor.parseIfFeatureExpression(ctx, value);
+ }
+}