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 class ConfigStatementSupport extends
19 AbstractStatementSupport<Boolean, ConfigStatement, EffectiveStatement<Boolean, ConfigStatement>> {
20 private static final SubstatementValidator SUBSTATEMENT_VALIDATOR = SubstatementValidator.builder(
21 YangStmtMapping.CONFIG).build();
23 public ConfigStatementSupport() {
24 super(YangStmtMapping.CONFIG);
28 public Boolean parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
29 return ArgumentUtils.parseBoolean(ctx, value);
33 public ConfigStatement createDeclared(final StmtContext<Boolean, ConfigStatement, ?> ctx) {
34 final ConfigStatement ret = new ConfigStatementImpl(ctx);
36 if (EmptyConfigStatement.FALSE.equals(ret)) {
37 return EmptyConfigStatement.FALSE;
38 } else if (EmptyConfigStatement.TRUE.equals(ret)) {
39 return EmptyConfigStatement.TRUE;
46 public EffectiveStatement<Boolean, ConfigStatement> createEffective(
47 final StmtContext<Boolean, ConfigStatement, EffectiveStatement<Boolean, ConfigStatement>> ctx) {
48 final EffectiveStatement<Boolean, ConfigStatement> ret = new ConfigEffectiveStatementImpl(ctx);
49 final ConfigStatement declared = ret.getDeclared();
50 if (declared instanceof EmptyConfigStatement && ret.effectiveSubstatements().isEmpty()) {
51 return ((EmptyConfigStatement)declared).toEffective();
57 public String internArgument(final String rawArgument) {
58 return ArgumentUtils.internBoolean(rawArgument);
62 protected SubstatementValidator getSubstatementValidator() {
63 return SUBSTATEMENT_VALIDATOR;