Skip to content

Conversation

@eye-dee
Copy link

@eye-dee eye-dee commented Jul 25, 2017

No description provided.


// TODO get Optional<first name> from optPerson
final Optional<String> optFirstName = null;
final Optional<String> optFirstName = optPerson.flatMap(p -> Optional.of(p.getFirstName()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use map


// TODO Get Stream<first name> from streamPerson
final Stream<String> streamFirstName = null;
final Stream<String> streamFirstName = streamPerson.flatMap(p -> Stream.of(person.getFirstName()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use map


// TODO Get CompletableFuture<first name> from futurePerson
final CompletableFuture<String> futureFirstName = null;
final CompletableFuture<String> futureFirstName = futurePerson.thenCompose(p -> CompletableFuture.completedFuture(p.getFirstName()));

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use thenApply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants