Sho SHIMIZU
Committed by Gerrit Code Review

Move method to IntentProcessPhase

Change-Id: Id9e898d983f3b041dbb376070ef31e36318b40c3
......@@ -298,7 +298,7 @@ public class IntentManager
List<CompletableFuture<IntentData>> futures = operations.stream()
.map(x -> CompletableFuture.completedFuture(x)
.thenApply(IntentManager.this::createInitialPhase)
.thenApplyAsync(IntentManager.this::process, workerExecutor)
.thenApplyAsync(IntentProcessPhase::process, workerExecutor)
.thenApply(FinalIntentProcessPhase::data)
.exceptionally(e -> {
//FIXME
......@@ -329,17 +329,6 @@ public class IntentManager
return newInitialPhase(processor, data, current);
}
private FinalIntentProcessPhase process(IntentProcessPhase initial) {
Optional<IntentProcessPhase> currentPhase = Optional.of(initial);
IntentProcessPhase previousPhase = initial;
while (currentPhase.isPresent()) {
previousPhase = currentPhase.get();
currentPhase = previousPhase.execute();
}
return (FinalIntentProcessPhase) previousPhase;
}
private class InternalIntentProcessor implements IntentProcessor {
@Override
public List<Intent> compile(Intent intent, List<Intent> previousInstallables) {
......
......@@ -58,6 +58,17 @@ public interface IntentProcessPhase {
}
}
static FinalIntentProcessPhase process(IntentProcessPhase initial) {
Optional<IntentProcessPhase> currentPhase = Optional.of(initial);
IntentProcessPhase previousPhase = initial;
while (currentPhase.isPresent()) {
previousPhase = currentPhase.get();
currentPhase = previousPhase.execute();
}
return (FinalIntentProcessPhase) previousPhase;
}
static void transferErrorCount(IntentData data, Optional<IntentData> stored) {
stored.ifPresent(storedData -> {
if (Objects.equals(data.intent(), storedData.intent()) &&
......