У меня есть функция ниже
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 жалуется на оператор return, который:
Required type: Mono <CarAndShip>
Provided: Mono <Object> no
instance(s) of type variable(s) R exist so that CarAndShip conforms to Mono<? extends R>
Как ввести приведение к требуемому типу возврата CarAndShip
?
CarAndShip
класс? Почему бы просто не вернутьMono<Tuple2<Car, Ship>>
? - person xtratic   schedule 19.01.2021