I want to have a Mono that calls another async method that returns an Optional type to:
- have a value if the
Optionalis not empty, - is
MonoEmptyif theOptionalvalue is empty.
Here's what I do right now:
Mono.fromCallable(() -> someApi.asyncCall())
.filter(Optional::isPresent)
.map(Optional::get)
Obviously, this is not ideal since it uses two operators after the callable completed. If possible, I'd like to have the Mono.empty() or mono value from inside fromCallable.
What is the best way to achieve what I want?