June 2018
Intermediate to advanced
280 pages
7h 46m
English
The best example is the usage of the map function that performs an adaptation from the old interface to the new interface. We are going to reuse the example from Chapter 4, Structural Patterns, with a small twist; the map simulates the adapter code:
jshell> class PS2Device {};| created class PS2Devicejshell> class USBDevice {};| created class USBDevicejshell> Optional.of(new PS2Device()).stream().map(x -> new USBDevice()).findFirst().get()$39 ==> USBDevice@15bb6bea
Read now
Unlock full access