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.extension;
10 import java.util.Optional;
11 import org.opendaylight.yangtools.yang.common.QName;
12 import org.opendaylight.yangtools.yang.model.api.meta.ArgumentDefinition;
13 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
14 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedEffectiveStatement;
15 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
16 import org.opendaylight.yangtools.yang.parser.spi.meta.AbstractStatementSupport;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
21 final class UnrecognizedStatementSupport
22 extends AbstractStatementSupport<String, UnrecognizedStatement, UnrecognizedEffectiveStatement> {
23 UnrecognizedStatementSupport(final StatementDefinition publicDefinition) {
24 super(publicDefinition);
28 public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
33 public UnrecognizedStatement createDeclared(final StmtContext<String, UnrecognizedStatement, ?> ctx) {
34 return new UnrecognizedStatementImpl(ctx);
38 public UnrecognizedEffectiveStatement createEffective(
39 final StmtContext<String, UnrecognizedStatement, UnrecognizedEffectiveStatement> ctx) {
40 return new UnrecognizedEffectiveStatementImpl(ctx);
44 protected SubstatementValidator getSubstatementValidator() {
49 public Optional<StatementSupport<?, ?, ?>> getUnknownStatementDefinitionOf(
50 final StatementDefinition yangStmtDef) {
51 final QName baseQName = getStatementName();
52 final QName statementName = QName.create(baseQName, yangStmtDef.getStatementName().getLocalName());
54 final ModelDefinedStatementDefinition def;
55 final Optional<ArgumentDefinition> optArgDef = yangStmtDef.getArgumentDefinition();
56 if (optArgDef.isPresent()) {
57 final ArgumentDefinition argDef = optArgDef.get();
58 def = new ModelDefinedStatementDefinition(statementName, argDef.getArgumentName(), argDef.isYinElement());
60 def = new ModelDefinedStatementDefinition(statementName);
62 return Optional.of(new ModelDefinedStatementSupport(def));