Java 8 supports lambdas. It's API also comes with Streams support.
But Knowing some concepts on Functional Programming may help you get a lot more from what this new version of Java has to offer.
4. @ignasi35
about me
@ignasi35
1) problem solver, Garbage Collector, mostly
scala, java 8, agile for tech teams
2) kayaker
3) under construction
4) all things JVM
5. @ignasi35
FP in Java 8
Pure Functions
no side effects
if not used, remove it
fixed in — fixed out
36. @ignasi35
XXIst Century DateTime
• Clock
• LocalDate
• a date
• no TimeZone
• birth date, end of war, man on moon,…
• LocalDateTime
• Duration vs Period
• ZonedDateTime
92. @ignasi35
Maybe (aka Optional)
filter: applies predicate and Returns input or None
map: converts content
fold: returns Some(content) or Some(default)
flatMap: see list
get: returns content or throws Exception
getOrElse: returns content or defaultValue
97. @ignasi35
Future (aka CF, aka
CompletableFuture)
!
[FAIL] Does not use map, flatMap, filter.
!
[PASS] CF implemented ADT
!
[FAIL] Because Supplier, Consumer, Function,
Bifuction, … CF’s API sucks.
98. @ignasi35
Future
filter: creates new future applying Predicate
map: converts content if success. New Future
fold: n/a
flatMap: see list
andThen: chains this Future’s content into a Consumer
onSuccess/onFailure: callbacks
recover: equivalent to map() but applied only on Fail
119. @ignasi35
Moar resources
https://github.com/rocketscience-projects/javaslang
by https://twitter.com/danieldietrich
thanks @thomasdarimont for the tip
!
https://github.com/functionaljava/functionaljava
by http://www.functionaljava.org/ (runs in Java7)