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)
27 private static final IfFeatureStatementSupport INSTANCE = new IfFeatureStatementSupport();
29 private IfFeatureStatementSupport() {
30 super(YangStmtMapping.IF_FEATURE);
33 public static IfFeatureStatementSupport getInstance() {
38 public Predicate<Set<QName>> parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
39 if (YangVersion.VERSION_1_1.equals(ctx.getRootVersion())) {
40 return IfFeaturePredicateVisitor.parseIfFeatureExpression(ctx, value);
43 final QName qname = StmtContextUtils.parseNodeIdentifier(ctx, value);
44 return setQNames -> setQNames.contains(qname);
48 public IfFeatureStatement createDeclared(final StmtContext<Predicate<Set<QName>>, IfFeatureStatement, ?> ctx) {
49 return new IfFeatureStatementImpl(ctx);
53 public EffectiveStatement<Predicate<Set<QName>>, IfFeatureStatement> createEffective(
54 final StmtContext<Predicate<Set<QName>>, IfFeatureStatement,
55 EffectiveStatement<Predicate<Set<QName>>, IfFeatureStatement>> ctx) {
56 return new IfFeatureEffectiveStatementImpl(ctx);
60 protected SubstatementValidator getSubstatementValidator() {
61 return SUBSTATEMENT_VALIDATOR;