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 org.eclipse.jdt.annotation.NonNull;
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.StatementNamespace;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
26 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
27 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
30 * A replica of a different statement. It does not allow modification, but produces an effective statement from a
33 final class ReplicaStatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
34 extends ReactorStmtCtx<A, D, E> {
35 private final StatementContextBase<?, ?, ?> parent;
36 private final ReactorStmtCtx<A, D, E> source;
38 ReplicaStatementContext(final StatementContextBase<?, ?, ?> parent, final ReactorStmtCtx<A, D, E> source) {
40 this.parent = requireNonNull(parent);
41 this.source = requireNonNull(source);
42 if (source.isSupportedToBuildEffective()) {
49 return source.buildEffective();
53 ReactorStmtCtx<A, D, E> unmodifiedEffectiveSource() {
54 return source.unmodifiedEffectiveSource();
58 public EffectiveConfig effectiveConfig() {
59 return source.effectiveConfig();
64 return source.declared();
69 return source.argument();
73 public StatementSourceReference sourceReference() {
74 return source.sourceReference();
78 public String rawArgument() {
79 return source.rawArgument();
83 public Optional<StmtContext<A, D, E>> getOriginalCtx() {
84 return source.getOriginalCtx();
88 public Collection<? extends StatementContextBase<?, ?, ?>> mutableDeclaredSubstatements() {
89 return source.mutableDeclaredSubstatements();
93 public Collection<? extends Mutable<?, ?, ?>> mutableEffectiveSubstatements() {
94 return source.mutableEffectiveSubstatements();
98 byte executionOrder() {
99 return source.executionOrder();
103 public CopyHistory history() {
104 return source.history();
108 public Collection<? extends StmtContext<?, ?, ?>> getEffectOfStatement() {
113 ReplicaStatementContext<A, D, E> replicaAsChildOf(final StatementContextBase<?, ?, ?> newParent) {
114 return source.replicaAsChildOf(newParent);
118 public Optional<? extends Mutable<?, ?, ?>> copyAsChildOf(final Mutable<?, ?, ?> newParent, final CopyType type,
119 final QNameModule targetModule) {
120 return source.copyAsChildOf(newParent, type, targetModule);
124 ReactorStmtCtx<?, ?, ?> asEffectiveChildOf(final StatementContextBase<?, ?, ?> newParent, final CopyType type,
125 final QNameModule targetModule) {
126 final ReactorStmtCtx<?, ?, ?> ret = source.asEffectiveChildOf(newParent, type, targetModule);
127 return ret == null ? null : this;
131 StatementDefinitionContext<A, D, E> definition() {
132 return source.definition();
136 void markNoParentRef() {
141 int sweepSubstatements() {
142 if (haveSourceReference()) {
149 public <K, V, T extends K, U extends V, N extends ParserNamespace<K, V>> void addToNs(final Class<@NonNull N> type,
150 final T key, final U value) {
151 throw new UnsupportedOperationException();
155 public Optional<StmtContext<A, D, E>> getPreviousCopyCtx() {
156 throw new UnsupportedOperationException();
160 public <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(final Class<@NonNull N> namespace,
161 final KT key, final StmtContext<?, ?, ?> stmt) {
162 throw new UnsupportedOperationException();
166 public void addAsEffectOfStatement(final Collection<? extends StmtContext<?, ?, ?>> ctxs) {
167 throw new UnsupportedOperationException();
171 public Mutable<?, ?, ?> childCopyOf(final StmtContext<?, ?, ?> stmt, final CopyType type,
172 final QNameModule targetModule) {
173 throw new UnsupportedOperationException();
177 boolean doTryToCompletePhase(final byte executionOrder) {
178 throw new UnsupportedOperationException();
182 public <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<X, Y>>
183 Mutable<X, Y, Z> addEffectiveSubstatement(final StatementSupport<X, Y, Z> support, final X arg) {
184 throw new UnsupportedOperationException();
188 public void addEffectiveSubstatement(final Mutable<?, ?, ?> substatement) {
189 throw new UnsupportedOperationException();
193 public void addEffectiveSubstatements(final Collection<? extends Mutable<?, ?, ?>> statements) {
194 throw new UnsupportedOperationException();
198 public void removeStatementFromEffectiveSubstatements(final StatementDefinition statementDef) {
199 throw new UnsupportedOperationException();
203 public void removeStatementFromEffectiveSubstatements(final StatementDefinition statementDef,
204 final String statementArg) {
205 throw new UnsupportedOperationException();
209 public boolean hasImplicitParentSupport() {
210 throw new UnsupportedOperationException();
214 public StmtContext<?, ?, ?> wrapWithImplicit(final StmtContext<?, ?, ?> original) {
215 throw new UnsupportedOperationException();
219 * KEEP THINGS ORGANIZED!
221 * below methods exist in the same form in InferredStatementContext/SubstatementContext. If any adjustment is made
222 * here, make sure it is properly updated there.
225 public StatementContextBase<?, ?, ?> getParentContext() {
230 public StorageNodeType getStorageNodeType() {
231 return StorageNodeType.STATEMENT_LOCAL;
235 public StatementContextBase<?, ?, ?> getParentNamespaceStorage() {
240 public RootStatementContext<?, ?, ?> getRoot() {
241 return parent.getRoot();
245 protected boolean isIgnoringIfFeatures() {
246 return isIgnoringIfFeatures(parent);
250 protected boolean isIgnoringConfig() {
251 return isIgnoringConfig(parent);
255 protected boolean isParentSupportedByFeatures() {
256 return parent.isSupportedByFeatures();