Java Magazine, Jan/Feb 2018
ORACLE COM JAVAMAGAZINE JANUARY FEBRUARY 2018 27 reactive programming By composing another stage on the location stage created above collect the list of forecasts as in one big completion stage final CompletionStage List Forecast forecastCS locationCS thenCompose locations Create a stage for retrieving forecasts as a list of completion stages List CompletionStage Forecast forecastList Stream locations and process each location individually locations stream map location Create a stage for fetching the temperature value just for one city given by its name final CompletionStage Temperature tempCS temperatureTarget resolveTemplate city location getName request rx get Temperature class Then create a completable future that contains an instance of forecast with location and temperature values return CompletableFuture completedFuture new Forecast location thenCombine tempCS
You must have JavaScript enabled to view digital editions.