I have a list of cars and each id of car can have multiple color values, i want to combine them such that each color object will have set of color options..
but i have this exception:
GroupedFlux allows only one Subscriber Suppressed: java.lang.Exception: #block terminated with an error
How can i achieve what i want? Can you please help me out?
I have a list of cars and each id of car can have multiple color values, i want to combine them such that each color object will have set of color options..
but i have this exception:
GroupedFlux allows only one Subscriber Suppressed: java.lang.Exception: #block terminated with an error
How can i achieve what i want? Can you please help me out?
Flux.fromIterable(carItems)
.groupBy { it.id }
.flatMap { mapToCar(it) }
private fun mapToCar(cars: GroupedFlux): Flux {
return cars.take(1).map {
Car(
id = it.id,
colors = mapToColors(cars)
)
}
}
private fun mapToColors(cars: Flux): Set {
return cars.map {
CarColor(
color = it.color
)
}.collect(Collectors.toSet())
.map { it.toImmutable() }
.block() ?: emptySet()
}