2 * Copyright (c) 2015 Cisco Systems, Inc. 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.Collection;
11 import java.util.Optional;
12 import java.util.stream.Stream;
13 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
14 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
15 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedEffectiveStatement;
16 import org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement;
17 import org.opendaylight.yangtools.yang.parser.spi.meta.EffectiveStmtCtx.Current;
18 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
19 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.SubstatementValidator;
23 * StatementSupport for statements defined via YANG extensions. This is implemented by piggy-backing
24 * to a {@link UnrecognizedStatementSupport}.
26 * @author Robert Varga
28 final class ModelDefinedStatementSupport
29 extends StatementSupport<String, UnrecognizedStatement, UnrecognizedEffectiveStatement> {
30 private final UnrecognizedStatementSupport definition;
32 ModelDefinedStatementSupport(final ModelDefinedStatementDefinition publicDefinition) {
33 super(publicDefinition, StatementPolicy.legacyDeclaredCopy());
34 this.definition = new UnrecognizedStatementSupport(publicDefinition);
38 public UnrecognizedStatement createDeclared(final StmtContext<String, UnrecognizedStatement, ?> ctx) {
39 return definition.createDeclared(ctx);
43 public UnrecognizedEffectiveStatement createEffective(final Current<String, UnrecognizedStatement> stmt,
44 final Stream<? extends StmtContext<?, ?, ?>> declaredSubstatements,
45 final Stream<? extends StmtContext<?, ?, ?>> effectiveSubstatements) {
46 return definition.createEffective(stmt, declaredSubstatements, effectiveSubstatements);
50 public UnrecognizedEffectiveStatement createEffective(final Current<String, UnrecognizedStatement> stmt,
51 final Collection<? extends EffectiveStatement<?, ?>> substatements) {
52 return definition.createEffective(stmt, substatements);
56 public String parseArgumentValue(final StmtContext<?, ?, ?> ctx, final String value) {
57 return definition.parseArgumentValue(ctx, value);
61 protected SubstatementValidator getSubstatementValidator() {
66 public Optional<StatementSupport<?, ?, ?>> getUnknownStatementDefinitionOf(final StatementDefinition yangStmtDef) {
67 return definition.getUnknownStatementDefinitionOf(yangStmtDef);