Lambdas, streams and Optional
Functional Java: the lambda syntax and the functional interface it fits, Function, Consumer, Supplier and Predicate, and the method references that replace them. Streams follow, from map and filter to collect, with the terminal operations, the collectors and the numeric streams, then flatMap, distinct and takeWhile. Optional gets a lesson and a second one on its traps, parallel streams are measured against a sequential one, and streams are set against the loops they replace. The part ends with a sales report capstone and composing functions with andThen and compose.
082
Lambdas
the syntax, a functional interface, effectively final captures, a lambda as an argument
Open
083
The functional interfaces
Function, Consumer, Supplier, Predicate, BiFunction, UnaryOperator
Open
084
Method references
:: static, bound, unbound and constructor references, a chain of them
Open
085
Streams
stream(), map, filter, collect, a pipeline against the same loop
Open
086
Terminal operations
count, findFirst, anyMatch, allMatch, reduce, forEach
Open
087
Collectors
toList, toSet, joining, groupingBy, partitioningBy, counting
Open
088
Numeric streams
IntStream.range, sum, average, summaryStatistics, boxed
Open
089
Optional
of, ofNullable, empty, map, orElse, ifPresent, orElseThrow
Open
090
flatMap and the rest
flatMap, distinct, sorted, limit, skip, takeWhile
Open
091
Parallel streams
parallelStream, a measured comparison, when it pays and when it does not
Open
092
Streams against loops
side effects, a stream reused, a checked exception inside a lambda, readability
Open
093
Capstone: a sales report
records, a stream pipeline, groupingBy, a formatted table
Open
094
Optional in practice
a field of Optional, get() without a check, orElse against orElseGet
Open
095
Composing functions
andThen, compose, a predicate chain, a small pipeline built from parts
Open