转换Flux< map< k,v>>进入列表< v>

发布于 2025-02-04 19:05:54 字数 93 浏览 3 评论 0原文

我想知道如何在弹簧反应堆中转换flux< map< k,v> list< v>

I'm wondering how in spring reactor to convert a Flux<Map<K, V> into a List<V>.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

谷夏 2025-02-11 19:05:55

通常,对于磁​​通实例,您可以这样做:

List<Object> myList = flux.collectSortedList().block();

In general, for a Flux instance you can do:

List<Object> myList = flux.collectSortedList().block();
凉世弥音 2025-02-11 19:05:55

a flux&lt; map&lt; k,v&gt;&gt;可以发射任何数量的地图(0..infinity values)。

final List<V> values = flux
    .flatMapIterable(Map::values) // extract a concatenated list of all values
                                  // it transforms List<Collection<V>> into Collection<V>
                                  // but keeps it wrapped in a Flux instance
    .collectList() // transforms Flux<T> into Mono<List<T>>
    .block(); // blocks indefinitely, until the value is available and returns the value

A Flux<Map<K, V>> can emit any number of maps (0..infinity values).

final List<V> values = flux
    .flatMapIterable(Map::values) // extract a concatenated list of all values
                                  // it transforms List<Collection<V>> into Collection<V>
                                  // but keeps it wrapped in a Flux instance
    .collectList() // transforms Flux<T> into Mono<List<T>>
    .block(); // blocks indefinitely, until the value is available and returns the value
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文