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.meta;
10 import com.google.common.collect.ImmutableList;
11 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
12 import org.opendaylight.yangtools.yang.model.api.meta.DeclarationReference;
13 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
14 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.PresenceEffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.PresenceStatement;
17 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatementDecorators;
18 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
19 import org.opendaylight.yangtools.yang.model.ri.stmt.EffectiveStatements;
20 import org.opendaylight.yangtools.yang.parser.api.YangParserConfiguration;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStringStatementSupport;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
26 public final class PresenceStatementSupport
27 extends AbstractStringStatementSupport<PresenceStatement, PresenceEffectiveStatement> {
28 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
29 SubstatementValidator.builder(YangStmtMapping.PRESENCE).build();
31 public PresenceStatementSupport(final YangParserConfiguration config) {
32 super(YangStmtMapping.PRESENCE, StatementPolicy.contextIndependent(), config);
36 protected SubstatementValidator getSubstatementValidator() {
37 return SUBSTATEMENT_VALIDATOR;
41 protected PresenceStatement createDeclared(final StmtContext<String, PresenceStatement, ?> ctx,
42 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
43 return DeclaredStatements.createPresence(ctx.getRawArgument(), substatements);
47 protected PresenceStatement attachDeclarationReference(final PresenceStatement stmt,
48 final DeclarationReference reference) {
49 return DeclaredStatementDecorators.decoratePresence(stmt, reference);
53 protected PresenceEffectiveStatement createEffective(final Current<String, PresenceStatement> stmt,
54 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
55 return EffectiveStatements.createPresence(stmt.declared(), substatements);