We are only ever iterating here, lower the contract exposed through
here.
Change-Id: Ief041380c5341956e2cf91491bbc05d1c4f08ca7
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
import com.google.common.collect.ImmutableList;
import java.util.Collection;
import com.google.common.collect.ImmutableList;
import java.util.Collection;
+import java.util.Iterator;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;
- final Iterable<ReactorStmtCtx<?, ?, ?>> effectiveChildrenToComplete() {
- return effective;
+ final Iterator<ReactorStmtCtx<?, ?, ?>> effectiveChildrenToComplete() {
+ return effective.iterator();
import com.google.common.collect.Streams;
import java.util.ArrayList;
import java.util.Collection;
import com.google.common.collect.Streams;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
- Iterable<ReactorStmtCtx<?, ?, ?>> effectiveChildrenToComplete() {
+ Iterator<ReactorStmtCtx<?, ?, ?>> effectiveChildrenToComplete() {
// When we have not initialized, there are no statements to catch up: we will catch up when we are copying
// from prototype (which is already at ModelProcessingPhase.EFFECTIVE_MODEL).
if (substatements == null) {
// When we have not initialized, there are no statements to catch up: we will catch up when we are copying
// from prototype (which is already at ModelProcessingPhase.EFFECTIVE_MODEL).
if (substatements == null) {
- return ImmutableList.of();
+ return Collections.emptyIterator();
}
accessSubstatements();
if (substatements instanceof HashMap) {
}
accessSubstatements();
if (substatements instanceof HashMap) {
- return castMaterialized(substatements).values();
+ return castMaterialized(substatements).values().iterator();
- return castEffective(substatements);
+ return castEffective(substatements).iterator();
- abstract Iterable<ReactorStmtCtx<?, ?, ?>> effectiveChildrenToComplete();
+ abstract Iterator<ReactorStmtCtx<?, ?, ?>> effectiveChildrenToComplete();
// exposed for InferredStatementContext only
final void ensureCompletedPhase(final Mutable<?, ?, ?> stmt) {
// exposed for InferredStatementContext only
final void ensureCompletedPhase(final Mutable<?, ?, ?> stmt) {
for (final StatementContextBase<?, ?, ?> child : mutableDeclaredSubstatements()) {
finished &= child.tryToCompletePhase(targetOrder);
}
for (final StatementContextBase<?, ?, ?> child : mutableDeclaredSubstatements()) {
finished &= child.tryToCompletePhase(targetOrder);
}
- for (final ReactorStmtCtx<?, ?, ?> child : effectiveChildrenToComplete()) {
- finished &= child.tryToCompletePhase(targetOrder);
+ final var it = effectiveChildrenToComplete();
+ while (it.hasNext()) {
+ finished &= it.next().tryToCompletePhase(targetOrder);