2 * Copyright (c) 2020 PANTHEON.tech, 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.stmt.reactor;
10 import static java.util.Objects.requireNonNull;
12 import java.util.Collection;
13 import java.util.List;
14 import java.util.Optional;
15 import java.util.stream.Stream;
16 import org.opendaylight.yangtools.yang.common.QNameModule;
17 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
18 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
19 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyHistory;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementFactory;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
26 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
27 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
28 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
31 * A replica of a different statement. It does not allow modification, but produces an effective statement from a
34 final class ReplicaStatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
35 extends ReactorStmtCtx<A, D, E> {
36 private final StatementContextBase<?, ?, ?> parent;
37 private final ReactorStmtCtx<A, D, E> source;
39 ReplicaStatementContext(final StatementContextBase<?, ?, ?> parent, final ReactorStmtCtx<A, D, E> source) {
41 this.parent = requireNonNull(parent);
42 this.source = requireNonNull(source);
43 if (source.isSupportedToBuildEffective()) {
50 return source.buildEffective();
54 E createInferredEffective(final StatementFactory<A, D, E> factory, final InferredStatementContext<A, D, E> ctx,
55 final Stream<? extends StmtContext<?, ?, ?>> declared,
56 final Stream<? extends StmtContext<?, ?, ?>> effective) {
57 return source.createInferredEffective(factory, ctx, declared, effective);
61 ReactorStmtCtx<A, D, E> unmodifiedEffectiveSource() {
62 return source.unmodifiedEffectiveSource();
66 public EffectiveConfig effectiveConfig() {
67 return source.effectiveConfig();
72 return source.declared();
77 return source.argument();
81 public StatementSourceReference sourceReference() {
82 return source.sourceReference();
86 public String rawArgument() {
87 return source.rawArgument();
91 public Optional<StmtContext<A, D, E>> getOriginalCtx() {
92 return source.getOriginalCtx();
96 public Collection<? extends StatementContextBase<?, ?, ?>> mutableDeclaredSubstatements() {
97 return source.mutableDeclaredSubstatements();
101 public Collection<? extends Mutable<?, ?, ?>> mutableEffectiveSubstatements() {
102 return source.mutableEffectiveSubstatements();
106 byte executionOrder() {
107 return source.executionOrder();
111 public CopyHistory history() {
112 return source.history();
116 public Collection<? extends StmtContext<?, ?, ?>> getEffectOfStatement() {
121 ReplicaStatementContext<A, D, E> replicaAsChildOf(final StatementContextBase<?, ?, ?> newParent) {
122 return source.replicaAsChildOf(newParent);
126 public Optional<? extends Mutable<?, ?, ?>> copyAsChildOf(final Mutable<?, ?, ?> newParent, final CopyType type,
127 final QNameModule targetModule) {
128 return source.copyAsChildOf(newParent, type, targetModule);
132 ReactorStmtCtx<?, ?, ?> asEffectiveChildOf(final StatementContextBase<?, ?, ?> newParent, final CopyType type,
133 final QNameModule targetModule) {
134 final ReactorStmtCtx<?, ?, ?> ret = source.asEffectiveChildOf(newParent, type, targetModule);
135 return ret == null ? null : this;
139 StatementDefinitionContext<A, D, E> definition() {
140 return source.definition();
144 void markNoParentRef() {
149 int sweepSubstatements() {
150 if (haveSourceReference()) {
158 public <K, V, T extends K, U extends V> void addToNs(final ParserNamespace<K, V> type, final T key, final U value) {
159 throw new UnsupportedOperationException();
164 public Optional<StmtContext<A, D, E>> getPreviousCopyCtx() {
165 throw new UnsupportedOperationException();
170 public <K, KT extends K, Y extends DeclaredStatement<?>, Z extends EffectiveStatement<?, Y>> void addContext(
171 final StatementNamespace<K, Y, Z> namespace, final KT key, final StmtContext<?, Y, Z> stmt) {
172 throw new UnsupportedOperationException();
177 public void addAsEffectOfStatement(final Collection<? extends StmtContext<?, ?, ?>> ctxs) {
178 throw new UnsupportedOperationException();
183 public Mutable<?, ?, ?> childCopyOf(final StmtContext<?, ?, ?> stmt, final CopyType type,
184 final QNameModule targetModule) {
185 throw new UnsupportedOperationException();
190 boolean doTryToCompletePhase(final byte executionOrder) {
191 throw new UnsupportedOperationException();
196 public <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<X, Y>>
197 Mutable<X, Y, Z> createUndeclaredSubstatement(final StatementSupport<X, Y, Z> support, final X arg) {
198 throw new UnsupportedOperationException();
203 public void addEffectiveSubstatement(final Mutable<?, ?, ?> substatement) {
204 throw new UnsupportedOperationException();
209 public void addEffectiveSubstatements(final Collection<? extends Mutable<?, ?, ?>> statements) {
210 throw new UnsupportedOperationException();
215 public void removeStatementFromEffectiveSubstatements(final StatementDefinition statementDef) {
216 throw new UnsupportedOperationException();
221 public void removeStatementFromEffectiveSubstatements(final StatementDefinition statementDef,
222 final String statementArg) {
223 throw new UnsupportedOperationException();
228 public boolean hasImplicitParentSupport() {
229 throw new UnsupportedOperationException();
234 public StmtContext<?, ?, ?> wrapWithImplicit(final StmtContext<?, ?, ?> original) {
235 throw new UnsupportedOperationException();
239 * KEEP THINGS ORGANIZED!
241 * below methods exist in the same form in InferredStatementContext/SubstatementContext. If any adjustment is made
242 * here, make sure it is properly updated there.
245 public StatementContextBase<?, ?, ?> getParentContext() {
250 public StorageNodeType getStorageNodeType() {
251 return StorageNodeType.STATEMENT_LOCAL;
255 public StatementContextBase<?, ?, ?> getParentNamespaceStorage() {
260 public RootStatementContext<?, ?, ?> getRoot() {
261 return parent.getRoot();
265 protected boolean isIgnoringIfFeatures() {
266 return isIgnoringIfFeatures(parent);
270 protected boolean isIgnoringConfig() {
271 return isIgnoringConfig(parent);
275 protected boolean isParentSupportedByFeatures() {
276 return parent.isSupportedByFeatures();