June 2018
Intermediate to advanced
280 pages
7h 46m
English
The chain of responsibility can be implemented as a list of handlers (functions), each one performing a specific action. The following example code makes use of closure and a stream of functions that all apply, one after another, on the given text:
jshell> String text = "Text";text ==> "Text"jshell> Stream.<Function<String, String>>of(String::toLowerCase, x -> LocalDateTime.now().toString() + " " + x).map(f -> f.apply(text)).collect(Collectors.toList())$55 ==> [text, 2017-08-10T08:41:28.243310800 Text]
Read now
Unlock full access