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.IfFeatureStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContextUtils;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
22 public final class IfFeatureStatementSupport extends AbstractStatementSupport<Predicate<Set<QName>>, IfFeatureStatement,
23 EffectiveStatement<Predicate<Set<QName>>, IfFeatureStatement>> {
24 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
25 YangStmtMapping.IF_FEATURE)
28 public IfFeatureStatementSupport() {
29 super(YangStmtMapping.IF_FEATURE);
33 public Predicate<Set<QName>> parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
34 if (YangVersion.VERSION_1_1.equals(ctx.getRootVersion())) {
35 return IfFeaturePredicateVisitor.parseIfFeatureExpression(ctx, value);
38 final QName qname = StmtContextUtils.qnameFromArgument(ctx, value);
39 return setQNames -> setQNames.contains(qname);
43 public IfFeatureStatement createDeclared(final StmtContext<Predicate<Set<QName>>, IfFeatureStatement, ?> ctx) {
44 return new IfFeatureStatementImpl(ctx);
48 public EffectiveStatement<Predicate<Set<QName>>, IfFeatureStatement> createEffective(
49 final StmtContext<Predicate<Set<QName>>, IfFeatureStatement,
50 EffectiveStatement<Predicate<Set<QName>>, IfFeatureStatement>> ctx) {
51 return new IfFeatureEffectiveStatementImpl(ctx);
55 protected SubstatementValidator getSubstatementValidator() {
56 return SUBSTATEMENT_VALIDATOR;