完整future< list< carditem>>到单一对象

发布于 2025-01-25 04:35:06 字数 179 浏览 5 评论 0原文

我有一个API,可以返回

CardItem { CardType 卡片 卡尾 }

但是,我想迭代完整的future,并建立一个父子对象类,如果cardType = header是父。其余的卡片人是孩子。

就像

carditemro的单声道{ CardType =标题 卡片 卡尾 列表 }

i have an api that returns CompletableFuture

where CardItem{
cardType
cardStatus
cardDetails
}

but i'd like to iterate through the CompletableFuture and build a parent children object class where if cardType = Header is the parent. and the rest of the CardItems are children.

like Mono

where CardItemRO {
cardType= header
cardStatus
cardDetails
List
}

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

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

发布评论

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

评论(1

浮云落日 2025-02-01 04:35:06

您可以将完整的名单列表列表到单声道列表。然后使用磁通。

 Mono<List<CardItem>>  mapCompletableFutureToMono=listOfCompletableFuture.map { Mono.fromFuture(it) }.toList()

    Flux.fromIterable(mapCompletableFutureToMono).flatMap { it }.collectList().map{cardItem-> // do something}

You have map the list of completableFuture to List of Mono. then use Flux.fromIterable to iterate the list of Mono's

 Mono<List<CardItem>>  mapCompletableFutureToMono=listOfCompletableFuture.map { Mono.fromFuture(it) }.toList()

    Flux.fromIterable(mapCompletableFutureToMono).flatMap { it }.collectList().map{cardItem-> // do something}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文