apache / apache/pekko

Add Flow#collectNonNull operator

Open
#2,178 30 comments 0 reactions 1 assignee Claimed by @He-Pin View on GitHub
t:stream
Dominant language
Scala
Stars
1.6k
Forks
211
Avg merge
1d 6h
Merged PRs (30d)
89

Description

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

```java
return doGetObservableFluxChatResponse(this.request)
.mapNotNull(ChatClientResponse::chatResponse)
.map(r -> Optional.ofNullable(r.getResult())
.map(Generation::getOutput)
.map(AbstractMessage::getText)
.orElse(""))
.filter(StringUtils::hasLength);
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.