Add Guava requires
[yangtools.git] / yang / yang-parser-reactor / src / main / java / org / opendaylight / yangtools / yang / parser / stmt / reactor / ReplicaStatementContext.java
index 071b73b37ae87469b9afa029bc716df3177f79f1..9e69fa29afdbf2e3ac955ff7f749e3659b005add 100644 (file)
@@ -9,15 +9,20 @@ package org.opendaylight.yangtools.yang.parser.stmt.reactor;
 
 import static java.util.Objects.requireNonNull;
 
-import com.google.common.collect.ImmutableList;
 import java.util.Collection;
+import java.util.List;
 import java.util.Optional;
-import java.util.stream.Stream;
+import org.eclipse.jdt.annotation.NonNull;
+import org.opendaylight.yangtools.yang.common.QNameModule;
 import org.opendaylight.yangtools.yang.model.api.SchemaPath;
 import org.opendaylight.yangtools.yang.model.api.meta.DeclaredStatement;
 import org.opendaylight.yangtools.yang.model.api.meta.EffectiveStatement;
-import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
+import org.opendaylight.yangtools.yang.parser.spi.meta.CopyHistory;
+import org.opendaylight.yangtools.yang.parser.spi.meta.CopyType;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ModelProcessingPhase;
 import org.opendaylight.yangtools.yang.parser.spi.meta.NamespaceBehaviour.StorageNodeType;
+import org.opendaylight.yangtools.yang.parser.spi.meta.ParserNamespace;
+import org.opendaylight.yangtools.yang.parser.spi.meta.StatementNamespace;
 import org.opendaylight.yangtools.yang.parser.spi.meta.StmtContext;
 import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReference;
 
@@ -26,19 +31,18 @@ import org.opendaylight.yangtools.yang.parser.spi.source.StatementSourceReferenc
  * designated source.
  */
 final class ReplicaStatementContext<A, D extends DeclaredStatement<A>, E extends EffectiveStatement<A, D>>
-        extends StatementContextBase<A, D, E> {
+        extends ReactorStmtCtx<A, D, E> {
     private final StatementContextBase<?, ?, ?> parent;
-    private final StatementContextBase<A, D, E> source;
+    private final ReactorStmtCtx<A, D, E> source;
 
-    ReplicaStatementContext(final StatementContextBase<?, ?, ?> parent, final StatementContextBase<A, D, E> source) {
+    ReplicaStatementContext(final StatementContextBase<?, ?, ?> parent, final ReactorStmtCtx<A, D, E> source) {
         super(source);
         this.parent = requireNonNull(parent);
         this.source = requireNonNull(source);
         if (source.isSupportedToBuildEffective()) {
             source.incRef();
+            // FIXME: is this call really needed? it is inherited from source
             setFullyDefined();
-        } else {
-            setIsSupportedToBuildEffective(false);
         }
     }
 
@@ -48,7 +52,7 @@ final class ReplicaStatementContext<A, D extends DeclaredStatement<A>, E extends
     }
 
     @Override
-    public boolean effectiveConfig() {
+    public EffectiveConfig effectiveConfig() {
         return source.effectiveConfig();
     }
 
@@ -88,61 +92,85 @@ final class ReplicaStatementContext<A, D extends DeclaredStatement<A>, E extends
     }
 
     @Override
-    boolean hasEmptySubstatements() {
-        return source.hasEmptySubstatements();
+    public ModelProcessingPhase getCompletedPhase() {
+        return source.getCompletedPhase();
     }
 
     @Override
-    Iterable<StatementContextBase<?, ?, ?>> effectiveChildrenToComplete() {
-        return ImmutableList.of();
+    public CopyHistory history() {
+        return source.history();
     }
 
     @Override
-    int sweepSubstatements() {
-        if (fullyDefined()) {
-            source.decRef();
-        }
-        return 0;
+    public Collection<? extends StmtContext<?, ?, ?>> getEffectOfStatement() {
+        return List.of();
     }
 
     @Override
-    public Optional<StmtContext<A, D, E>> getPreviousCopyCtx() {
-        throw new UnsupportedOperationException();
+    ReplicaStatementContext<A, D, E> replicaAsChildOf(final StatementContextBase<?, ?, ?> newParent) {
+        return source.replicaAsChildOf(newParent);
     }
 
     @Override
-    public void removeStatementFromEffectiveSubstatements(final StatementDefinition statementDef) {
-        throw new UnsupportedOperationException();
+    public Optional<? extends Mutable<?, ?, ?>> copyAsChildOf(final Mutable<?, ?, ?> newParent, final CopyType type,
+            final QNameModule targetModule) {
+        return source.copyAsChildOf(newParent, type, targetModule);
     }
 
     @Override
-    public void removeStatementFromEffectiveSubstatements(final StatementDefinition statementDef,
-            final String statementArg) {
-        throw new UnsupportedOperationException();
+    ReactorStmtCtx<?, ?, ?> asEffectiveChildOf(final StatementContextBase<?, ?, ?> newParent, final CopyType type,
+            final QNameModule targetModule) {
+        final ReactorStmtCtx<?, ?, ?> ret = source.asEffectiveChildOf(newParent, type, targetModule);
+        return ret == null ? null : this;
     }
 
     @Override
-    public void addEffectiveSubstatement(final Mutable<?, ?, ?> substatement) {
+    StatementDefinitionContext<A, D, E> definition() {
+        return source.definition();
+    }
+
+    @Override
+    void markNoParentRef() {
+        // No-op
+    }
+
+    @Override
+    int sweepSubstatements() {
+        if (fullyDefined()) {
+            source.decRef();
+        }
+        return 0;
+    }
+
+    @Override
+    public <K, V, T extends K, U extends V, N extends ParserNamespace<K, V>> void addToNs(final Class<@NonNull N> type,
+            final T key, final U value) {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    void addEffectiveSubstatementsImpl(final Collection<? extends Mutable<?, ?, ?>> statements) {
+    public Optional<StmtContext<A, D, E>> getPreviousCopyCtx() {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    Stream<? extends StmtContext<?, ?, ?>> streamDeclared() {
+    public <K, KT extends K, N extends StatementNamespace<K, ?, ?>> void addContext(final Class<@NonNull N> namespace,
+            final KT key, final StmtContext<?, ?, ?> stmt) {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    Stream<? extends StmtContext<?, ?, ?>> streamEffective() {
+    public void addAsEffectOfStatement(final Collection<? extends StmtContext<?, ?, ?>> ctxs) {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    StatementContextBase<A, D, E> reparent(final StatementContextBase<?, ?, ?> newParent) {
+    public Mutable<?, ?, ?> childCopyOf(final StmtContext<?, ?, ?> stmt, final CopyType type,
+            final QNameModule targetModule) {
+        throw new UnsupportedOperationException();
+    }
+
+    @Override boolean doTryToCompletePhase(final ModelProcessingPhase phase) {
         throw new UnsupportedOperationException();
     }
 
@@ -154,7 +182,7 @@ final class ReplicaStatementContext<A, D extends DeclaredStatement<A>, E extends
      */
     @Override
     @Deprecated
-    public Optional<SchemaPath> schemaPath() {
+    public SchemaPath schemaPath() {
         return substatementGetSchemaPath();
     }