Sho SHIMIZU
Committed by Gerrit Code Review

Refactor: Extract two methods from submitIntentData()

Change-Id: I2c75039bed836ec3695bee1c8a7664bea8779d9e
...@@ -294,18 +294,24 @@ public class IntentManager ...@@ -294,18 +294,24 @@ public class IntentManager
294 } 294 }
295 295
296 private CompletableFuture<FinalIntentProcessPhase> submitIntentData(IntentData data) { 296 private CompletableFuture<FinalIntentProcessPhase> submitIntentData(IntentData data) {
297 + IntentProcessPhase initial = createInitialPhase(data);
298 + return CompletableFuture.supplyAsync(() -> process(initial), workerExecutor);
299 + }
300 +
301 + private IntentProcessPhase createInitialPhase(IntentData data) {
297 IntentData current = store.getIntentData(data.key()); 302 IntentData current = store.getIntentData(data.key());
298 - IntentProcessPhase initial = newInitialPhase(processor, data, current); 303 + return newInitialPhase(processor, data, current);
299 - return CompletableFuture.supplyAsync(() -> { 304 + }
300 - Optional<IntentProcessPhase> currentPhase = Optional.of(initial); 305 +
301 - IntentProcessPhase previousPhase = initial; 306 + private FinalIntentProcessPhase process(IntentProcessPhase initial) {
302 - 307 + Optional<IntentProcessPhase> currentPhase = Optional.of(initial);
303 - while (currentPhase.isPresent()) { 308 + IntentProcessPhase previousPhase = initial;
304 - previousPhase = currentPhase.get(); 309 +
305 - currentPhase = previousPhase.execute(); 310 + while (currentPhase.isPresent()) {
306 - } 311 + previousPhase = currentPhase.get();
307 - return (FinalIntentProcessPhase) previousPhase; 312 + currentPhase = previousPhase.execute();
308 - }, workerExecutor); 313 + }
314 + return (FinalIntentProcessPhase) previousPhase;
309 } 315 }
310 316
311 private class InternalBatchDelegate implements IntentBatchDelegate { 317 private class InternalBatchDelegate implements IntentBatchDelegate {
......