I have the below function
public Mono<CarAndShip> getCarAndShip(Long id) {
Mono<Car> carMono = carService.getCar(id).subscribeOn(Schedulers.elastic());
Mono<Ship> shipMono = shipService.getShip(id).subscribeOn(Schedulers.elastic());
return Mono.zip(carMono, shipMono)
.flatMap(zipMono -> {
return new CarAndShip(zipMono.getT1(), zipMono.getT2());
});
IntelliJ complains at the return statement that:
Required type: Mono <CarAndShip>
Provided: Mono <Object> no
instance(s) of type variable(s) R exist so that CarAndShip conforms to Mono<? extends R>
How do I type cast to the required CarAndShip return type?
CarAndShipclass look like? Why not just returnMono<Tuple2<Car, Ship>>? - xtratic