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.parser.spi.meta.CopyHistory;
20 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
25 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
28 * A replica of a different statement. It does not allow modification, but produces an effective statement from a
31 final class ReplicaStatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
32 extends ReactorStmtCtx<A, D, E> {
33 private final StatementContextBase<?, ?, ?> parent;
34 private final ReactorStmtCtx<A, D, E> source;
36 ReplicaStatementContext(final StatementContextBase<?, ?, ?> parent, final ReactorStmtCtx<A, D, E> source) {
38 this.parent = requireNonNull(parent);
39 this.source = requireNonNull(source);
40 if (source.isSupportedToBuildEffective()) {
47 return source.buildEffective();
51 ReactorStmtCtx<A, D, E> unmodifiedEffectiveSource() {
52 return source.unmodifiedEffectiveSource();
56 public EffectiveConfig effectiveConfig() {
57 return source.effectiveConfig();
62 return source.declared();
67 return source.argument();
71 public StatementSourceReference sourceReference() {
72 return source.sourceReference();
76 public String rawArgument() {
77 return source.rawArgument();
81 public Optional<StmtContext<A, D, E>> getOriginalCtx() {
82 return source.getOriginalCtx();
86 public Collection<? extends StatementContextBase<?, ?, ?>> mutableDeclaredSubstatements() {
87 return source.mutableDeclaredSubstatements();
91 public Collection<? extends Mutable<?, ?, ?>> mutableEffectiveSubstatements() {
92 return source.mutableEffectiveSubstatements();
96 byte executionOrder() {
97 return source.executionOrder();
101 public CopyHistory history() {
102 return source.history();
106 public Collection<? extends StmtContext<?, ?, ?>> getEffectOfStatement() {
111 ReplicaStatementContext<A, D, E> replicaAsChildOf(final StatementContextBase<?, ?, ?> newParent) {
112 return source.replicaAsChildOf(newParent);
116 public Optional<? extends Mutable<?, ?, ?>> copyAsChildOf(final Mutable<?, ?, ?> newParent, final CopyType type,
117 final QNameModule targetModule) {
118 return source.copyAsChildOf(newParent, type, targetModule);
122 ReactorStmtCtx<?, ?, ?> asEffectiveChildOf(final StatementContextBase<?, ?, ?> newParent, final CopyType type,
123 final QNameModule targetModule) {
124 final ReactorStmtCtx<?, ?, ?> ret = source.asEffectiveChildOf(newParent, type, targetModule);
125 return ret == null ? null : this;
129 StatementDefinitionContext<A, D, E> definition() {
130 return source.definition();
134 void markNoParentRef() {
139 int sweepSubstatements() {
140 if (haveSourceReference()) {
147 public <K, V, T extends K, U extends V, N extends ParserNamespace<K, V>> void addToNs(final Class<@NonNull N> type,
148 final T key, final U value) {
149 throw new UnsupportedOperationException();
153 public Optional<StmtContext<A, D, E>> getPreviousCopyCtx() {
154 throw new UnsupportedOperationException();
158 public <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(final Class<@NonNull N> namespace,
159 final KT key, final StmtContext<?, ?, ?> stmt) {
160 throw new UnsupportedOperationException();
164 public void addAsEffectOfStatement(final Collection<? extends StmtContext<?, ?, ?>> ctxs) {
165 throw new UnsupportedOperationException();
169 public Mutable<?, ?, ?> childCopyOf(final StmtContext<?, ?, ?> stmt, final CopyType type,
170 final QNameModule targetModule) {
171 throw new UnsupportedOperationException();
175 boolean doTryToCompletePhase(final byte executionOrder) {
176 throw new UnsupportedOperationException();
180 * KEEP THINGS ORGANIZED!
182 * below methods exist in the same form in InferredStatementContext/SubstatementContext. If any adjustment is made
183 * here, make sure it is properly updated there.
186 public StatementContextBase<?, ?, ?> getParentContext() {
191 public StorageNodeType getStorageNodeType() {
192 return StorageNodeType.STATEMENT_LOCAL;
196 public StatementContextBase<?, ?, ?> getParentNamespaceStorage() {
201 public RootStatementContext<?, ?, ?> getRoot() {
202 return parent.getRoot();
206 protected boolean isIgnoringIfFeatures() {
207 return isIgnoringIfFeatures(parent);
211 protected boolean isIgnoringConfig() {
212 return isIgnoringConfig(parent);
216 protected boolean isParentSupportedByFeatures() {
217 return parent.isSupportedByFeatures();