Un-deprecate CopyableNode, AddedByUsesAware
[yangtools.git] / yang / yang-parser-rfc7950 / src / main / java / org / opendaylight / yangtools / yang / parser / rfc7950 / stmt / meta / ConfigStatementSupport.java
1 /*
2  * Copyright (c) 2017 Pantheon Technologies, s.r.o. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.yangtools.yang.parser.rfc7950.stmt.meta;
9
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.DeclaredStatement;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.stmt.ConfigEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
16 import org.opendaylight.yangtools.yang.model.ri.stmt.DeclaredStatements;
17 import org.opendaylight.yangtools.yang.model.ri.stmt.EffectiveStatements;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractBooleanStatementSupport;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
21
22 public final class ConfigStatementSupport
23         extends AbstractBooleanStatementSupport<ConfigStatement, ConfigEffectiveStatement> {
24     private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
25         YangStmtMapping.CONFIG).build();
26     private static final ConfigStatementSupport INSTANCE = new ConfigStatementSupport();
27
28     private ConfigStatementSupport() {
29         super(YangStmtMapping.CONFIG,
30             EffectiveStatements.createConfig(false), EffectiveStatements.createConfig(true),
31             // FIXME: This is not quite true. If we are instantiated in a context which ignores config, which should
32             //        really fizzle. This needs some more analysis.
33             StatementPolicy.contextIndependent());
34     }
35
36     public static ConfigStatementSupport getInstance() {
37         return INSTANCE;
38     }
39
40     @Override
41     protected SubstatementValidator getSubstatementValidator() {
42         return SUBSTATEMENT_VALIDATOR;
43     }
44
45     @Override
46     protected ConfigStatement createDeclared(final StmtContext<Boolean, ConfigStatement, ?> ctx,
47             final ImmutableList<? extends DeclaredStatement<?>> substatements) {
48         return DeclaredStatements.createConfig(ctx.getArgument(), substatements);
49     }
50
51     @Override
52     protected ConfigEffectiveStatement createEffective(final ConfigStatement declared,
53             final ImmutableList<? extends EffectiveStatement<?, ?>> substatements) {
54         return EffectiveStatements.createConfig(declared, substatements);
55     }
56
57     @Override
58     protected ConfigEffectiveStatement createEmptyEffective(final ConfigStatement declared) {
59         return EffectiveStatements.createConfig(declared);
60     }
61 }