Optional | Either | CompletableFuture | |
---|---|---|---|
Create success value | Optional.of | Either.right | CompletableFuture.completedFuture |
Create failure value | Optional.empty | Either.left | f = new CompletableFuture(); f.completeExceptionally; return f |
Apply function to success case | .map | .map | .thenApply |
Apply a function to success case that may also fail | .flatMap | .flatMap | .thenCompose |
Handle both failure & sucess cases at once | .map().orElse() | .fold | .handle |
Last active
August 16, 2017 03:35
-
-
Save LeifW/00a4cde32232516fd1a0f827707f7b32 to your computer and use it in GitHub Desktop.
Optional / Either / CompletableFuture similarities
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment