Sho SHIMIZU
Committed by Gerrit Code Review

Move method to IntentProcessPhase

Change-Id: Id9e898d983f3b041dbb376070ef31e36318b40c3
...@@ -298,7 +298,7 @@ public class IntentManager ...@@ -298,7 +298,7 @@ public class IntentManager
298 List<CompletableFuture<IntentData>> futures = operations.stream() 298 List<CompletableFuture<IntentData>> futures = operations.stream()
299 .map(x -> CompletableFuture.completedFuture(x) 299 .map(x -> CompletableFuture.completedFuture(x)
300 .thenApply(IntentManager.this::createInitialPhase) 300 .thenApply(IntentManager.this::createInitialPhase)
301 - .thenApplyAsync(IntentManager.this::process, workerExecutor) 301 + .thenApplyAsync(IntentProcessPhase::process, workerExecutor)
302 .thenApply(FinalIntentProcessPhase::data) 302 .thenApply(FinalIntentProcessPhase::data)
303 .exceptionally(e -> { 303 .exceptionally(e -> {
304 //FIXME 304 //FIXME
...@@ -329,17 +329,6 @@ public class IntentManager ...@@ -329,17 +329,6 @@ public class IntentManager
329 return newInitialPhase(processor, data, current); 329 return newInitialPhase(processor, data, current);
330 } 330 }
331 331
332 - private FinalIntentProcessPhase process(IntentProcessPhase initial) {
333 - Optional<IntentProcessPhase> currentPhase = Optional.of(initial);
334 - IntentProcessPhase previousPhase = initial;
335 -
336 - while (currentPhase.isPresent()) {
337 - previousPhase = currentPhase.get();
338 - currentPhase = previousPhase.execute();
339 - }
340 - return (FinalIntentProcessPhase) previousPhase;
341 - }
342 -
343 private class InternalIntentProcessor implements IntentProcessor { 332 private class InternalIntentProcessor implements IntentProcessor {
344 @Override 333 @Override
345 public List<Intent> compile(Intent intent, List<Intent> previousInstallables) { 334 public List<Intent> compile(Intent intent, List<Intent> previousInstallables) {
......
...@@ -58,6 +58,17 @@ public interface IntentProcessPhase { ...@@ -58,6 +58,17 @@ public interface IntentProcessPhase {
58 } 58 }
59 } 59 }
60 60
61 + static FinalIntentProcessPhase process(IntentProcessPhase initial) {
62 + Optional<IntentProcessPhase> currentPhase = Optional.of(initial);
63 + IntentProcessPhase previousPhase = initial;
64 +
65 + while (currentPhase.isPresent()) {
66 + previousPhase = currentPhase.get();
67 + currentPhase = previousPhase.execute();
68 + }
69 + return (FinalIntentProcessPhase) previousPhase;
70 + }
71 +
61 static void transferErrorCount(IntentData data, Optional<IntentData> stored) { 72 static void transferErrorCount(IntentData data, Optional<IntentData> stored) {
62 stored.ifPresent(storedData -> { 73 stored.ifPresent(storedData -> {
63 if (Objects.equals(data.intent(), storedData.intent()) && 74 if (Objects.equals(data.intent(), storedData.intent()) &&
......