This is my code:
Optional<Application> application = this.applicationDao.findById(id);
where, Application class is:
public class Application {
private String code;
private Collection<ApplicationQuote> quotes;
}
I need to create an stream from return Optional<Application> like this:
(app, quote-1) > (app, quote-2) > ... > (app, quote-n)
Where each quote-n is inside returned Optional<Application>.quotes.
I hope I've explained so well.
Up to now, I've been able to write this code, but I don't feel confortable with that:
Optional<Application> application = this.applicationDao.findById(id);
application.map(app -> Pair.of(app, Optional.ofNullable(app.getQuotes())))
.filter(quote -> quote.getValue().isPresent())
.map(quote -> quote.getValue().get().stream().map(q -> Pair.of(quote.getKey(), q)));