我有这个当前逻辑:
string
在IntelliJ中empty
部分突出显示并显示以下错误提示:
List<String> priceUnitCodes = ofNullable(product.getProductPrices())
.map(ProductPrices::getProductPrices)
.flatMap(productPrices -> productPrices.stream()) // << error highlight
.map(ProductPrice::getPriceBase)
.map(PriceBase::getPriceUnit)
.map(UniversalType::getcode)
.collect(Collectors.toList());
我知道flatMap
和no instance(s) of type variable(s) U exist so that Stream<ProductPrice> conforms to Optional<? extends U>
是两个不同的东西,但是我想知道是否有一种方法可以将它们结合起来,以便我可以将Optionals
与Stream
一起使用之后。