I've coded that:
Optional.ofNullable(this.cache.get(id))
.orElseGet(this.referenceService.get(id));
The problem is that this.referenceService.get
returns an Optional
.
So, I'm getting this compilation message:
The method
orElseGet(Supplier<? extends Reference>)
in the typeOptional<Reference>
is not applicable for the arguments (Optional<Reference>
)
Any ideas?