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 com.google.common.collect.ImmutableList;
13 import java.util.Collection;
14 import java.util.Optional;
15 import java.util.stream.Stream;
16 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
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.NamespaceBehaviour.StorageNodeType;
21 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
22 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
25 * A replica of a different statement. It does not allow modification, but produces an effective statement from a
28 final class ReplicaStatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
29 extends StatementContextBase<A, D, E> {
30 private final StatementContextBase<?, ?, ?> parent;
31 private final StatementContextBase<A, D, E> source;
33 ReplicaStatementContext(final StatementContextBase<?, ?, ?> parent, final StatementContextBase<A, D, E> source) {
35 this.parent = requireNonNull(parent);
36 this.source = requireNonNull(source);
37 if (source.isSupportedToBuildEffective()) {
41 setIsSupportedToBuildEffective(false);
47 return source.buildEffective();
51 public boolean effectiveConfig() {
52 return source.effectiveConfig();
57 return source.declared();
62 return source.argument();
66 public StatementSourceReference sourceReference() {
67 return source.sourceReference();
71 public String rawArgument() {
72 return source.rawArgument();
76 public Optional<StmtContext<A, D, E>> getOriginalCtx() {
77 return source.getOriginalCtx();
81 public Collection<? extends StatementContextBase<?, ?, ?>> mutableDeclaredSubstatements() {
82 return source.mutableDeclaredSubstatements();
86 public Collection<? extends Mutable<?, ?, ?>> mutableEffectiveSubstatements() {
87 return source.mutableEffectiveSubstatements();
91 boolean hasEmptySubstatements() {
92 return source.hasEmptySubstatements();
96 Iterable<StatementContextBase<?, ?, ?>> effectiveChildrenToComplete() {
97 return ImmutableList.of();
101 int sweepSubstatements() {
102 if (fullyDefined()) {
109 public Optional<StmtContext<A, D, E>> getPreviousCopyCtx() {
110 throw new UnsupportedOperationException();
114 public void removeStatementFromEffectiveSubstatements(final StatementDefinition statementDef) {
115 throw new UnsupportedOperationException();
119 public void removeStatementFromEffectiveSubstatements(final StatementDefinition statementDef,
120 final String statementArg) {
121 throw new UnsupportedOperationException();
125 public void addEffectiveSubstatement(final Mutable<?, ?, ?> substatement) {
126 throw new UnsupportedOperationException();
130 void addEffectiveSubstatementsImpl(final Collection<? extends Mutable<?, ?, ?>> statements) {
131 throw new UnsupportedOperationException();
135 Stream<? extends StmtContext<?, ?, ?>> streamDeclared() {
136 throw new UnsupportedOperationException();
140 Stream<? extends StmtContext<?, ?, ?>> streamEffective() {
141 throw new UnsupportedOperationException();
145 StatementContextBase<A, D, E> reparent(final StatementContextBase<?, ?, ?> newParent) {
146 throw new UnsupportedOperationException();
150 * KEEP THINGS ORGANIZED!
152 * below methods exist in the same form in InferredStatementContext/SubstatementContext. If any adjustment is made
153 * here, make sure it is properly updated there.
157 public Optional<SchemaPath> schemaPath() {
158 return substatementGetSchemaPath();
162 public StatementContextBase<?, ?, ?> getParentContext() {
167 public StorageNodeType getStorageNodeType() {
168 return StorageNodeType.STATEMENT_LOCAL;
172 public StatementContextBase<?, ?, ?> getParentNamespaceStorage() {
177 public RootStatementContext<?, ?, ?> getRoot() {
178 return parent.getRoot();
182 protected boolean isIgnoringIfFeatures() {
183 return isIgnoringIfFeatures(parent);
187 protected boolean isIgnoringConfig() {
188 return isIgnoringConfig(parent);
192 protected boolean isParentSupportedByFeatures() {
193 return parent.isSupportedByFeatures();