SlideShare una empresa de Scribd logo
1 de 31
Modern Java: Java for Jedis
Episode I
Roan Brasil Monteiro
Speaker/Jedi
2
Roan Brasil
@roanbrasil
Senior Engineer
+ JCP-Member
+ Open Source Contributor
+ Book and blog writer
+ Teacher
Summary
3
Java
• Lambdas expressions
• Method references
• Functional interfaces
• Stream API
• Default methods
• Optional class
• Date/Time API
Lambdas Expressions : Definition
Java - Functionalities
4
● Representation of one anonymous function
Anonymous : We say anonymous because it doesn't have an explicit name like a method
would normally have; less to write and think about
Function : We say function, because a lambda isn't associate with particular class like
method is. But like a method, a lambda has a list of parameters, a body, a return type, and a
possible list of exceptions that can be thrown.
Passed around : A lambda expression can be passed as argument to a method or stored in
a variable.
Concise : You do not need to write a lot of boilerplate.
Credits -> Definition from the book Modern Java in Action
Lambdas Expressions : Before and Later
Java - Functionalities
5
● Before
● Later
Lambda is composed by 3 parts:
Definition from the book Modern Java in Action
Lambdas Expressions : Quiz
Java - Functionalities
6
What lambdas expressions are not corrected?
Quiz Lambda Syntax
1. () -> {}
2. () -> “Yoda”
3. () -> { return “Jedi”; }
4. (Integer i) -> return “Jedi” + i;
5. (String s) -> { “Star Wars”; }
Definition from the book Modern Java in Action
Lambdas Expressions : Quiz
Java - Functionalities
7
What lambdas expressions are not corrected?
Quiz Lambda Syntax
1. () -> {}
2. () -> “Yoda”
3. () -> { return “Jedi”; }
4. (Integer i) -> return “Jedi” + i;
5. (String s) -> { “Star Wars”; }
Definition from the book Modern Java in Action
Lambdas Expressions : Why?
Java - Functionalities
8
Syntax
Why ?
It is necessary use braces*
The “Star Wars” is an expression, it is not a statement. There are two ways to do that.
(Integer i) -> return “Roan” + i;
(Integer i) -> { return “Roan”+ i;}
(String s) -> { “Star Wars’;}
(String s) -> “Star Wars”
(String s) -> { return “Star Wars”; }
Exception method void
process(() -> System.out.println(“Roan"));
Definition from the book Modern Java in Action
Lambdas Expressions : Some examples
Java - Functionalities
9
Definition from the book Modern Java in Action
Lambdas Expressions: Quiz
Java - Functionalities
10
Quelles sont les expressions lambdas correctes ?
Quiz Lambda Syntax
execute(() -> {});
public void execute(Runnable r) {
r.run();
}
public Callable<String> fetch(){
return () -> “Joker Exemple ☺”;
}
Predicate<Apple> p = (Apple a) -> a.getWeight();
Definition from the book Modern Java in Action
Lambdas Expressions : Quiz
Java - Functionalities
11
Quelles sont les expressions lambdas correctes ?
Quiz Lambda Syntax
execute(() -> {});
public void execute(Runnable r) {
r.run();
}
public Callable<String> fetch(){
return () -> “Joker Exemple ☺”;
}
Predicate<Apple> p = (Apple a) -> a.getWeight();
(Apple a) -> a.getWeight(); a de signature (Apple) -> Integer e le Predicate<Apple> attends (Apple) -> boolean
Definition from the book Modern Java in Action
Functional Interfaces : Definition and Examples
Java - Functionalities
12
● Functional Interface are interfaces with just an abstract method without or with the annotation
@FunctionalInterface
Definition from the book Modern Java in Action
Functional Interfaces: More Example
Java - Functionalities
13
Definition from the book Modern Java in Action
Functional Interfaces : Examples
Java - Functionalities
14
Definition from the book Modern Java in Action
Functional Interfaces : Examples
Java - Functionalities
15
●
Predicate<Integer> IntPredicate
Performance
Boxing
Unboxing
Definition from the book Modern Java in Action
Functional Interfaces: Examples Table
Java - Functionalities
16
Definition from the book Modern Java in Action
Functional Interfaces: Quiz
Java - Functionalities
17
What are each functional interfaces below?
Quiz
1. T -> R
2. (int, int) -> int
3. T -> void
4. () -> T
5. (T, U) -> R
1. Function<T, R>
2. IntBinaryOperator
3. Consumer<T>
4. Supplier<T>
5. BiFunction<T, U, R>
Definition from the book Modern Java in Action
Functional Interfaces: Examples
Java - Functionalities
18
Definition from the book Modern Java in Action
● Example:
Method Reference
Java - Functionalities
19
Beneficiar de uma melhor leitura de código
Thanks for this operator « :: » (classe::méthode)
Define an abstract method from une functional interface
Definition from the book Modern Java in Action
Method Reference: Example
Java - Functionalities
20
Definition from the book Modern Java in Action
API Stream
Java - Functionalities
21
package java.util.stream
https://github.com/roanbrasil/clean-code-tdc/blob/master/src/main/java/com/tdc/cleancode/stream_api/StreamsExample.java
Definition from the book Modern Java in Action
Classe Optional: Déjà vu
Java - Functionalities
22
Classe Optional: Hadouken
Java - Functionalities
23
https://github.com/roanbrasil/clean-code-tdc/blob/master/src/main/java/com/tdc/cleancode/optional/before/BeforeOptional.java
Classe Optional: Hadouken
Java - Functionalities
24
https://github.com/roanbrasil/clean-code-tdc/blob/master/src/main/java/com/tdc/cleancode/optional/after/AfterOptional.java
● Some util methods, one of we use a lot :
Classe Optional
Java - Functionalities
25
Optional.of (objet non nullable) Optional.ofNullable (objet nullable)
isPresent() isEmpty()
orElse() orElseThrow()
get()
filter()
map() flatMap()
API Date/Time
Java - Functionalities
26
Start from 1900
It's not a date
It is point in a time with some
precision in millisecondes
The months starts with the
index 0 a 11
Timezone CET (Central Europe Time)
Use a library externe like
JodaTime
DateFormat no thread-safe
Date et Dateformat are
mutable
● There are few classes form new Api Date/Time, such as LocalDate, LocalDateTime, Instant, LocalTime, Duration and
Period.
● Example of code :
API Date/Time
Java - Functionalities
27
Definition from the book Modern Java in Action
● Exemple de code :
API Date/Time
Java - Functionalities
28
Definition from the book Modern Java in Action
● Example de code :
API Date/Time
Java - Functionalities
29
https://github.com/roanbrasil/clean-code-tdc/blob/master/src/main/java/com/tdc/cleancode/java_time_api/before/BeforeJava8JavaTimeApi.java
https://github.com/roanbrasil/clean-code-tdc/blob/master/src/main/java/com/tdc/cleancode/java_time_api/after/AfterJava8JavaTimeApi.java
● Create direct methods from interfaces with the key word « default »
● Exemple :
public interface Step {
void execute (Information information);
default String fallback(){
return "ERRO";
}
}
Default Methods
Java - Functionalities
30
Q & A:
31
@roanbrasil

Más contenido relacionado

La actualidad más candente

Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
Todor Kolev
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
Todor Kolev
 
Java findamentals2
Java findamentals2Java findamentals2
Java findamentals2
Todor Kolev
 

La actualidad más candente (20)

Method Handles in Java
Method Handles in JavaMethod Handles in Java
Method Handles in Java
 
Java Basics
Java BasicsJava Basics
Java Basics
 
Java SE 8 - New Features
Java SE 8 - New FeaturesJava SE 8 - New Features
Java SE 8 - New Features
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Functional programming with Java 8
Functional programming with Java 8Functional programming with Java 8
Functional programming with Java 8
 
Java findamentals1
Java findamentals1Java findamentals1
Java findamentals1
 
Java 14 features
Java 14 featuresJava 14 features
Java 14 features
 
Java For Automation
Java   For AutomationJava   For Automation
Java For Automation
 
Java SE 8 best practices
Java SE 8 best practicesJava SE 8 best practices
Java SE 8 best practices
 
Java 8 features
Java 8 featuresJava 8 features
Java 8 features
 
Java ce241
Java ce241Java ce241
Java ce241
 
Core java
Core javaCore java
Core java
 
New Features in JDK 8
New Features in JDK 8New Features in JDK 8
New Features in JDK 8
 
Core java concepts
Core java  conceptsCore java  concepts
Core java concepts
 
Java 8 lambdas expressions
Java 8 lambdas expressionsJava 8 lambdas expressions
Java 8 lambdas expressions
 
Lambdas in Java 8
Lambdas in Java 8Lambdas in Java 8
Lambdas in Java 8
 
Java SE 8 library design
Java SE 8 library designJava SE 8 library design
Java SE 8 library design
 
Java 8 Features
Java 8 FeaturesJava 8 Features
Java 8 Features
 
Java findamentals2
Java findamentals2Java findamentals2
Java findamentals2
 

Similar a Java moderno java para Jedis episodio I

Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
Nayden Gochev
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Nayden Gochev
 

Similar a Java moderno java para Jedis episodio I (20)

New features in jdk8 iti
New features in jdk8 itiNew features in jdk8 iti
New features in jdk8 iti
 
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
 
Software Uni Conf October 2014
Software Uni Conf October 2014Software Uni Conf October 2014
Software Uni Conf October 2014
 
Java8 features
Java8 featuresJava8 features
Java8 features
 
Functional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singhFunctional programming in java 8 by harmeet singh
Functional programming in java 8 by harmeet singh
 
Java8
Java8Java8
Java8
 
Developing android apps with java 8
Developing android apps with java 8Developing android apps with java 8
Developing android apps with java 8
 
Java 8 - An Overview
Java 8 - An OverviewJava 8 - An Overview
Java 8 - An Overview
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
 
Lambdas and Laughs
Lambdas and LaughsLambdas and Laughs
Lambdas and Laughs
 
Java 8 presentation
Java 8 presentationJava 8 presentation
Java 8 presentation
 
Java 8 Lambda
Java 8 LambdaJava 8 Lambda
Java 8 Lambda
 
Eclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 OverviewEclipse Day India 2015 - Java 8 Overview
Eclipse Day India 2015 - Java 8 Overview
 
Automatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to InterfacesAutomatic Migration of Legacy Java Method Implementations to Interfaces
Automatic Migration of Legacy Java Method Implementations to Interfaces
 
java150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptxjava150929145120-lva1-app6892 (2).pptx
java150929145120-lva1-app6892 (2).pptx
 
Colloquium Report
Colloquium ReportColloquium Report
Colloquium Report
 
Function different types of funtion
Function different types of funtionFunction different types of funtion
Function different types of funtion
 
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
Lecture from javaday.bg by Nayden Gochev/ Ivan Ivanov and Mitia Alexandrov
 
1_JavIntro
1_JavIntro1_JavIntro
1_JavIntro
 
Java basic concept
Java basic conceptJava basic concept
Java basic concept
 

Más de Roan Brasil Monteiro (7)

Improving your code design using Java
Improving your code design using JavaImproving your code design using Java
Improving your code design using Java
 
Jumping in Jakarta Open Source Project Everything nobody tells you
Jumping in Jakarta Open Source Project  Everything nobody tells youJumping in Jakarta Open Source Project  Everything nobody tells you
Jumping in Jakarta Open Source Project Everything nobody tells you
 
Saga pattern and event sourcing with kafka
Saga pattern and event sourcing with kafkaSaga pattern and event sourcing with kafka
Saga pattern and event sourcing with kafka
 
HTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIs
HTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIsHTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIs
HTTP / 1, HTTP / 2 and HTTP / 3: Past, present and the future of APIs
 
Clean code com features do java 8 a java 14
Clean code com features do java 8 a java 14Clean code com features do java 8 a java 14
Clean code com features do java 8 a java 14
 
Introduction to microservices Jornada Microservices
Introduction to microservices Jornada MicroservicesIntroduction to microservices Jornada Microservices
Introduction to microservices Jornada Microservices
 
Creating an api from design to security.
Creating an api from design to security.Creating an api from design to security.
Creating an api from design to security.
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 

Java moderno java para Jedis episodio I

  • 1. Modern Java: Java for Jedis Episode I Roan Brasil Monteiro
  • 2. Speaker/Jedi 2 Roan Brasil @roanbrasil Senior Engineer + JCP-Member + Open Source Contributor + Book and blog writer + Teacher
  • 3. Summary 3 Java • Lambdas expressions • Method references • Functional interfaces • Stream API • Default methods • Optional class • Date/Time API
  • 4. Lambdas Expressions : Definition Java - Functionalities 4 ● Representation of one anonymous function Anonymous : We say anonymous because it doesn't have an explicit name like a method would normally have; less to write and think about Function : We say function, because a lambda isn't associate with particular class like method is. But like a method, a lambda has a list of parameters, a body, a return type, and a possible list of exceptions that can be thrown. Passed around : A lambda expression can be passed as argument to a method or stored in a variable. Concise : You do not need to write a lot of boilerplate. Credits -> Definition from the book Modern Java in Action
  • 5. Lambdas Expressions : Before and Later Java - Functionalities 5 ● Before ● Later Lambda is composed by 3 parts: Definition from the book Modern Java in Action
  • 6. Lambdas Expressions : Quiz Java - Functionalities 6 What lambdas expressions are not corrected? Quiz Lambda Syntax 1. () -> {} 2. () -> “Yoda” 3. () -> { return “Jedi”; } 4. (Integer i) -> return “Jedi” + i; 5. (String s) -> { “Star Wars”; } Definition from the book Modern Java in Action
  • 7. Lambdas Expressions : Quiz Java - Functionalities 7 What lambdas expressions are not corrected? Quiz Lambda Syntax 1. () -> {} 2. () -> “Yoda” 3. () -> { return “Jedi”; } 4. (Integer i) -> return “Jedi” + i; 5. (String s) -> { “Star Wars”; } Definition from the book Modern Java in Action
  • 8. Lambdas Expressions : Why? Java - Functionalities 8 Syntax Why ? It is necessary use braces* The “Star Wars” is an expression, it is not a statement. There are two ways to do that. (Integer i) -> return “Roan” + i; (Integer i) -> { return “Roan”+ i;} (String s) -> { “Star Wars’;} (String s) -> “Star Wars” (String s) -> { return “Star Wars”; } Exception method void process(() -> System.out.println(“Roan")); Definition from the book Modern Java in Action
  • 9. Lambdas Expressions : Some examples Java - Functionalities 9 Definition from the book Modern Java in Action
  • 10. Lambdas Expressions: Quiz Java - Functionalities 10 Quelles sont les expressions lambdas correctes ? Quiz Lambda Syntax execute(() -> {}); public void execute(Runnable r) { r.run(); } public Callable<String> fetch(){ return () -> “Joker Exemple ☺”; } Predicate<Apple> p = (Apple a) -> a.getWeight(); Definition from the book Modern Java in Action
  • 11. Lambdas Expressions : Quiz Java - Functionalities 11 Quelles sont les expressions lambdas correctes ? Quiz Lambda Syntax execute(() -> {}); public void execute(Runnable r) { r.run(); } public Callable<String> fetch(){ return () -> “Joker Exemple ☺”; } Predicate<Apple> p = (Apple a) -> a.getWeight(); (Apple a) -> a.getWeight(); a de signature (Apple) -> Integer e le Predicate<Apple> attends (Apple) -> boolean Definition from the book Modern Java in Action
  • 12. Functional Interfaces : Definition and Examples Java - Functionalities 12 ● Functional Interface are interfaces with just an abstract method without or with the annotation @FunctionalInterface Definition from the book Modern Java in Action
  • 13. Functional Interfaces: More Example Java - Functionalities 13 Definition from the book Modern Java in Action
  • 14. Functional Interfaces : Examples Java - Functionalities 14 Definition from the book Modern Java in Action
  • 15. Functional Interfaces : Examples Java - Functionalities 15 ● Predicate<Integer> IntPredicate Performance Boxing Unboxing Definition from the book Modern Java in Action
  • 16. Functional Interfaces: Examples Table Java - Functionalities 16 Definition from the book Modern Java in Action
  • 17. Functional Interfaces: Quiz Java - Functionalities 17 What are each functional interfaces below? Quiz 1. T -> R 2. (int, int) -> int 3. T -> void 4. () -> T 5. (T, U) -> R 1. Function<T, R> 2. IntBinaryOperator 3. Consumer<T> 4. Supplier<T> 5. BiFunction<T, U, R> Definition from the book Modern Java in Action
  • 18. Functional Interfaces: Examples Java - Functionalities 18 Definition from the book Modern Java in Action
  • 19. ● Example: Method Reference Java - Functionalities 19 Beneficiar de uma melhor leitura de código Thanks for this operator « :: » (classe::méthode) Define an abstract method from une functional interface Definition from the book Modern Java in Action
  • 20. Method Reference: Example Java - Functionalities 20 Definition from the book Modern Java in Action
  • 21. API Stream Java - Functionalities 21 package java.util.stream https://github.com/roanbrasil/clean-code-tdc/blob/master/src/main/java/com/tdc/cleancode/stream_api/StreamsExample.java Definition from the book Modern Java in Action
  • 22. Classe Optional: Déjà vu Java - Functionalities 22
  • 23. Classe Optional: Hadouken Java - Functionalities 23 https://github.com/roanbrasil/clean-code-tdc/blob/master/src/main/java/com/tdc/cleancode/optional/before/BeforeOptional.java
  • 24. Classe Optional: Hadouken Java - Functionalities 24 https://github.com/roanbrasil/clean-code-tdc/blob/master/src/main/java/com/tdc/cleancode/optional/after/AfterOptional.java
  • 25. ● Some util methods, one of we use a lot : Classe Optional Java - Functionalities 25 Optional.of (objet non nullable) Optional.ofNullable (objet nullable) isPresent() isEmpty() orElse() orElseThrow() get() filter() map() flatMap()
  • 26. API Date/Time Java - Functionalities 26 Start from 1900 It's not a date It is point in a time with some precision in millisecondes The months starts with the index 0 a 11 Timezone CET (Central Europe Time) Use a library externe like JodaTime DateFormat no thread-safe Date et Dateformat are mutable
  • 27. ● There are few classes form new Api Date/Time, such as LocalDate, LocalDateTime, Instant, LocalTime, Duration and Period. ● Example of code : API Date/Time Java - Functionalities 27 Definition from the book Modern Java in Action
  • 28. ● Exemple de code : API Date/Time Java - Functionalities 28 Definition from the book Modern Java in Action
  • 29. ● Example de code : API Date/Time Java - Functionalities 29 https://github.com/roanbrasil/clean-code-tdc/blob/master/src/main/java/com/tdc/cleancode/java_time_api/before/BeforeJava8JavaTimeApi.java https://github.com/roanbrasil/clean-code-tdc/blob/master/src/main/java/com/tdc/cleancode/java_time_api/after/AfterJava8JavaTimeApi.java
  • 30. ● Create direct methods from interfaces with the key word « default » ● Exemple : public interface Step { void execute (Information information); default String fallback(){ return "ERRO"; } } Default Methods Java - Functionalities 30