Committed by
Gerrit Code Review
Refactor: Extract two methods from submitIntentData()
Change-Id: I2c75039bed836ec3695bee1c8a7664bea8779d9e
Showing
1 changed file
with
9 additions
and
3 deletions
| ... | @@ -294,9 +294,16 @@ public class IntentManager | ... | @@ -294,9 +294,16 @@ 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 | + } |
| 305 | + | ||
| 306 | + private FinalIntentProcessPhase process(IntentProcessPhase initial) { | ||
| 300 | Optional<IntentProcessPhase> currentPhase = Optional.of(initial); | 307 | Optional<IntentProcessPhase> currentPhase = Optional.of(initial); |
| 301 | IntentProcessPhase previousPhase = initial; | 308 | IntentProcessPhase previousPhase = initial; |
| 302 | 309 | ||
| ... | @@ -305,7 +312,6 @@ public class IntentManager | ... | @@ -305,7 +312,6 @@ public class IntentManager |
| 305 | currentPhase = previousPhase.execute(); | 312 | currentPhase = previousPhase.execute(); |
| 306 | } | 313 | } |
| 307 | return (FinalIntentProcessPhase) previousPhase; | 314 | return (FinalIntentProcessPhase) previousPhase; |
| 308 | - }, workerExecutor); | ||
| 309 | } | 315 | } |
| 310 | 316 | ||
| 311 | private class InternalBatchDelegate implements IntentBatchDelegate { | 317 | private class InternalBatchDelegate implements IntentBatchDelegate { | ... | ... |
-
Please register or login to post a comment