Skip to content

Instantly share code, notes, and snippets.

@ova2
Created July 27, 2021 19:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ova2/553ade71d6003fd15cc48d7a7967a776 to your computer and use it in GitHub Desktop.
Save ova2/553ade71d6003fd15cc48d7a7967a776 to your computer and use it in GitHub Desktop.
private static class CacheMonoValue<VALUE> {
private Mono<VALUE> mono;
private Signal<VALUE> signal;
CacheMonoValue(Mono<VALUE> mono) {
this.mono = mono;
}
CacheMonoValue(Signal<VALUE> signal) {
this.signal = signal;
}
Mono<VALUE> toMono() {
if (mono != null) {
return mono;
}
return Mono.justOrEmpty(signal).dematerialize();
}
Optional<VALUE> getValue() {
if (signal == null) {
return Optional.empty();
}
return Optional.ofNullable(signal.get());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment