我最近更新到 Eclipse Neon 并且我现有的代码停止编译。似乎编译器无法进行类型推断,并使我进行不必要的显式转换。我有这个示例代码:
public class ProductManager {
//Mocked: originaly a Bean
com.google.common.util.concurrent.ListeningExecutorService executor;
public Stream<Result<Product, ItineraryDTO>> getItineraries(Set<Product> productsSet) {
// Asynchronously get itinerary for every flight
Stream<ListenableFuture<Result<Product, ItineraryDTO>>> futures =
productsSet.stream().map(Result.asyncCall(product ->
this.executor.submit(() -> this.getItinerary(product)
)));
// Wait and get results for every submitted task
Stream<Result<Product, ItineraryDTO>> results = Result.waitAndGet(futures);
return results;
}
private ItineraryDTO getItinerary(Product flight) {
// Mocked: originaly get itinerary from a REST service
return new ItineraryDTO();
}
}
该asyncCall
方法具有以下签名:
public static <T, U> Function<T, ListenableFuture<Result<T, U>>> asyncCall(
Function<T, ListenableFuture<U>> asyncMethod);
Eclipse 建议我必须转换结果流。这是一个 Eclipse 错误还是我做错了什么?