This operator is been used in Spring ai, and I think it's actually useful than a map to Optional/Option and a then filter/collect
return doGetObservableFluxChatResponse(this.request)
.mapNotNull(ChatClientResponse::chatResponse)
.map(r -> Optional.ofNullable(r.getResult())
.map(Generation::getOutput)
.map(AbstractMessage::getText)
.orElse(""))
.filter(StringUtils::hasLength);
This operator is been used in Spring ai, and I think it's actually useful than a map to Optional/Option and a then filter/collect