Sonuç olarak ya kendi sonucumu ya da parametre olarak verilen CompletionStage nesnesinin sonucunu döner. Açıklaması şöyle
ÖrnekThe applyToEither method creates a new stage, that upon completion transforms the first result of the previous two stages by the given Function.
Şöyle yaparı
CompletionStage<String> stage1 = supplyAsync(() -> sleepAndGet(1, "parallel1"));CompletionStage<String> stage2 = supplyAsync(() -> sleepAndGet(2, "parallel2"));CompletionStage<String> stage = stage1.applyToEither(stage2, s -> s.toUpperCase());assertEquals("PARALLEL1", stage.toCompletableFuture().get());
Hiç yorum yok:
Yorum Gönder