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.config;
10 import org.opendaylight.yangtools.yang.model.api.YangStmtMapping;
11 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
12 import org.opendaylight.yangtools.yang.model.api.stmt.ConfigStatement;
13 import org.opendaylight.yangtools.yang.parser.rfc7950.stmt.ArgumentUtils;
14 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
15 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
18 public final class ConfigStatementSupport extends
19 AbstractStatementSupport<Boolean, ConfigStatement, EffectiveStatement<Boolean, ConfigStatement>> {
20 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
21 YangStmtMapping.CONFIG).build();
22 private static final ConfigStatementSupport INSTANCE = new ConfigStatementSupport();
24 private ConfigStatementSupport() {
25 super(YangStmtMapping.CONFIG);
28 public static ConfigStatementSupport getInstance() {
33 public Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
34 return ArgumentUtils.parseBoolean(ctx, value);
38 public ConfigStatement createDeclared(final StmtContext<Boolean, ConfigStatement, ?> ctx) {
39 final ConfigStatement ret = new ConfigStatementImpl(ctx);
41 if (EmptyConfigStatement.FALSE.equals(ret)) {
42 return EmptyConfigStatement.FALSE;
43 } else if (EmptyConfigStatement.TRUE.equals(ret)) {
44 return EmptyConfigStatement.TRUE;
51 public EffectiveStatement<Boolean, ConfigStatement> createEffective(
52 final StmtContext<Boolean, ConfigStatement, EffectiveStatement<Boolean, ConfigStatement>> ctx) {
53 final EffectiveStatement<Boolean, ConfigStatement> ret = new ConfigEffectiveStatementImpl(ctx);
54 final ConfigStatement declared = ret.getDeclared();
55 if (declared instanceof EmptyConfigStatement && ret.effectiveSubstatements().isEmpty()) {
56 return ((EmptyConfigStatement)declared).toEffective();
62 public String internArgument(final String rawArgument) {
63 return ArgumentUtils.internBoolean(rawArgument);
67 protected SubstatementValidator getSubstatementValidator() {
68 return SUBSTATEMENT_VALIDATOR;