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.eclipse.jdt.annotation.NonNull;
17 import org.opendaylight.yangtools.yang.common.QNameModule;
18 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
19 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
20 import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyHistory;
22 import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
23 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
24 import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
25 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementFactory;
26 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
27 import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
28 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
29 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
32 * A replica of a different statement. It does not allow modification, but produces an effective statement from a
35 final class ReplicaStatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
36 extends ReactorStmtCtx<A, D, E> {
37 private final StatementContextBase<?, ?, ?> parent;
38 private final ReactorStmtCtx<A, D, E> source;
40 ReplicaStatementContext(final StatementContextBase<?, ?, ?> parent, final ReactorStmtCtx<A, D, E> source) {
42 this.parent = requireNonNull(parent);
43 this.source = requireNonNull(source);
44 if (source.isSupportedToBuildEffective()) {
51 return source.buildEffective();
55 E createInferredEffective(final StatementFactory<A, D, E> factory, final InferredStatementContext<A, D, E> ctx,
56 final Stream<? extends ReactorStmtCtx<?, ?, ?>> declared,
57 final Stream<? extends ReactorStmtCtx<?, ?, ?>> effective) {
58 return source.createInferredEffective(factory, ctx, declared, effective);
62 ReactorStmtCtx<A, D, E> unmodifiedEffectiveSource() {
63 return source.unmodifiedEffectiveSource();
67 public EffectiveConfig effectiveConfig() {
68 return source.effectiveConfig();
73 return source.declared();
78 return source.argument();
82 public StatementSourceReference sourceReference() {
83 return source.sourceReference();
87 public String rawArgument() {
88 return source.rawArgument();
92 public Optional<StmtContext<A, D, E>> getOriginalCtx() {
93 return source.getOriginalCtx();
97 public Collection<? extends StatementContextBase<?, ?, ?>> mutableDeclaredSubstatements() {
98 return source.mutableDeclaredSubstatements();
102 public Collection<? extends Mutable<?, ?, ?>> mutableEffectiveSubstatements() {
103 return source.mutableEffectiveSubstatements();
107 byte executionOrder() {
108 return source.executionOrder();
112 public CopyHistory history() {
113 return source.history();
117 public Collection<? extends StmtContext<?, ?, ?>> getEffectOfStatement() {
122 ReplicaStatementContext<A, D, E> replicaAsChildOf(final StatementContextBase<?, ?, ?> newParent) {
123 return source.replicaAsChildOf(newParent);
127 public Optional<? extends Mutable<?, ?, ?>> copyAsChildOf(final Mutable<?, ?, ?> newParent, final CopyType type,
128 final QNameModule targetModule) {
129 return source.copyAsChildOf(newParent, type, targetModule);
133 ReactorStmtCtx<?, ?, ?> asEffectiveChildOf(final StatementContextBase<?, ?, ?> newParent, final CopyType type,
134 final QNameModule targetModule) {
135 final ReactorStmtCtx<?, ?, ?> ret = source.asEffectiveChildOf(newParent, type, targetModule);
136 return ret == null ? null : this;
140 StatementDefinitionContext<A, D, E> definition() {
141 return source.definition();
145 void markNoParentRef() {
150 int sweepSubstatements() {
151 if (haveSourceReference()) {
159 public <K, V, T extends K, U extends V, N extends ParserNamespace<K, V>> void addToNs(final Class<@NonNull N> type,
160 final T key, final U value) {
161 throw new UnsupportedOperationException();
166 public Optional<StmtContext<A, D, E>> getPreviousCopyCtx() {
167 throw new UnsupportedOperationException();
172 public <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(final Class<@NonNull N> namespace,
173 final KT key, final StmtContext<?, ?, ?> stmt) {
174 throw new UnsupportedOperationException();
179 public void addAsEffectOfStatement(final Collection<? extends StmtContext<?, ?, ?>> ctxs) {
180 throw new UnsupportedOperationException();
185 public Mutable<?, ?, ?> childCopyOf(final StmtContext<?, ?, ?> stmt, final CopyType type,
186 final QNameModule targetModule) {
187 throw new UnsupportedOperationException();
192 boolean doTryToCompletePhase(final byte executionOrder) {
193 throw new UnsupportedOperationException();
198 public <X, Y extends DeclaredStatement<X>, Z extends EffectiveStatement<X, Y>>
199 Mutable<X, Y, Z> createUndeclaredSubstatement(final StatementSupport<X, Y, Z> support, final X arg) {
200 throw new UnsupportedOperationException();
205 public void addEffectiveSubstatement(final Mutable<?, ?, ?> substatement) {
206 throw new UnsupportedOperationException();
211 public void addEffectiveSubstatements(final Collection<? extends Mutable<?, ?, ?>> statements) {
212 throw new UnsupportedOperationException();
217 public void removeStatementFromEffectiveSubstatements(final StatementDefinition statementDef) {
218 throw new UnsupportedOperationException();
223 public void removeStatementFromEffectiveSubstatements(final StatementDefinition statementDef,
224 final String statementArg) {
225 throw new UnsupportedOperationException();
230 public boolean hasImplicitParentSupport() {
231 throw new UnsupportedOperationException();
236 public StmtContext<?, ?, ?> wrapWithImplicit(final StmtContext<?, ?, ?> original) {
237 throw new UnsupportedOperationException();
241 * KEEP THINGS ORGANIZED!
243 * below methods exist in the same form in InferredStatementContext/SubstatementContext. If any adjustment is made
244 * here, make sure it is properly updated there.
247 public StatementContextBase<?, ?, ?> getParentContext() {
252 public StorageNodeType getStorageNodeType() {
253 return StorageNodeType.STATEMENT_LOCAL;
257 public StatementContextBase<?, ?, ?> getParentNamespaceStorage() {
262 public RootStatementContext<?, ?, ?> getRoot() {
263 return parent.getRoot();
267 protected boolean isIgnoringIfFeatures() {
268 return isIgnoringIfFeatures(parent);
272 protected boolean isIgnoringConfig() {
273 return isIgnoringConfig(parent);
277 protected boolean isParentSupportedByFeatures() {
278 return parent.isSupportedByFeatures();