O'Reilly logo

Java 9 Cookbook by Nick Samoylov, Mohamed Sanaulla

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

Getting ready

In the previous chapter, while creating a lambda-friendly API, we ended up with the following API method:

public interface Traffic {  void speedAfterStart(double timeSec,     int trafficUnitsNumber, SpeedModel speedModel,     BiPredicate<TrafficUnit, Double> limitTraffic,         BiConsumer<TrafficUnit, Double> printResult); }

The specified number of TrafficUnit instances were produced inside the speedAfterStart() method. They were limited by the limitTrafficAndSpeed function and processed according to the speedModel function inside the speedAfterStart() method. The results were shown on the device and in the format specified by the printResults function.  

It is a very flexible design that allows you to have quite a range of experimentation ...

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