O'Reilly logo

Java 11 Cookbook by Mohamed Sanaulla, Nick Samoylov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

Let's recall how a user called the lambda-friendly API:

double timeSec = 10.0;int trafficUnitsNumber = 10;SpeedModel speedModel = (t, wp, hp) -> ...;BiConsumer<TrafficUnit, Double> printResults = (tu, sp) -> ...;BiPredicate<TrafficUnit, Double> limitSpeed = (tu, sp) -> ...;Traffic api = new TrafficImpl(Month.APRIL, DayOfWeek.FRIDAY, 17,                               "USA", "Denver", "Main103S");api.speedAfterStart(timeSec, trafficUnitsNumber, speedModel,                     limitSpeed, printResults);

As we have already noticed, such an API may not cover all the possible ways the model can evolve, but it is a good starting point that allows us to construct the stream and the pipeline of operations with more transparency and flexibility of experimentation.

Now, let's look ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required