2 * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.if_feature;
11 import java.util.function.Predicate;
12 import org.opendaylight.yangtools.yang.common.QName;
13 import org.opendaylight.yangtools.yang.common.YangVersion;
14 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
15 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureExpr;
17 import org.opendaylight.yangtools.yang.model.api.stmt.IfFeatureStatement;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
23 public final class IfFeatureStatementSupport extends AbstractStatementSupport<Predicate<Set<QName>>, IfFeatureStatement,
24 EffectiveStatement<Predicate<Set<QName>>, IfFeatureStatement>> {
25 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
26 YangStmtMapping.IF_FEATURE)
28 private static final IfFeatureStatementSupport INSTANCE = new IfFeatureStatementSupport();
30 private IfFeatureStatementSupport() {
31 super(YangStmtMapping.IF_FEATURE);
34 public static IfFeatureStatementSupport getInstance() {
39 public Predicate<Set<QName>> parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
40 if (YangVersion.VERSION_1_1.equals(ctx.getRootVersion())) {
41 return IfFeaturePredicateVisitor.parseIfFeatureExpression(ctx, value);
43 return IfFeatureExpr.isPresent(StmtContextUtils.parseNodeIdentifier(ctx, value));
47 public IfFeatureStatement createDeclared(final StmtContext<Predicate<Set<QName>>, IfFeatureStatement, ?> ctx) {
48 return new IfFeatureStatementImpl(ctx);
52 public EffectiveStatement<Predicate<Set<QName>>, IfFeatureStatement> createEffective(
53 final StmtContext<Predicate<Set<QName>>, IfFeatureStatement,
54 EffectiveStatement<Predicate<Set<QName>>, IfFeatureStatement>> ctx) {
55 return new IfFeatureEffectiveStatementImpl(ctx);
59 protected SubstatementValidator getSubstatementValidator() {
60 return SUBSTATEMENT_VALIDATOR;