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.ConfigEffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
17 import org.opendaylight.yangtools.yang.model.parser.api.YangParserConfiguration;
18 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatementDecorators;
19 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
20 import org.opendaylight.yangtools.yang.model.ri.stmt.EffectiveStatements;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractBooleanStatementSupport;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
24 public final class ConfigStatementSupport
25 extends AbstractBooleanStatementSupport<ConfigStatement, ConfigEffectiveStatement> {
26 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR =
27 SubstatementValidator.builder(YangStmtMapping.CONFIG).build();
29 public ConfigStatementSupport(final YangParserConfiguration config) {
30 super(YangStmtMapping.CONFIG,
31 EffectiveStatements.createConfig(false), EffectiveStatements.createConfig(true),
32 // FIXME: This is not quite true. If we are instantiated in a context which ignores config, which should
33 // really fizzle. This needs some more analysis.
34 StatementPolicy.contextIndependent(), config);
38 protected SubstatementValidator getSubstatementValidator() {
39 return SUBSTATEMENT_VALIDATOR;
43 protected ConfigStatement createDeclared(final Boolean argument,
44 final ImmutableList<? extends DeclaredStatement<?>> substatements) {
45 return DeclaredStatements.createConfig(argument, substatements);
49 protected ConfigStatement attachDeclarationReference(final ConfigStatement stmt,
50 final DeclarationReference reference) {
51 return DeclaredStatementDecorators.decorateConfig(stmt, reference);
55 protected ConfigEffectiveStatement createEffective(final ConfigStatement declared,
56 final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
57 return EffectiveStatements.createConfig(declared, substatements);
61 protected ConfigEffectiveStatement createEmptyEffective(final ConfigStatement declared) {
62 return EffectiveStatements.createConfig(declared);