SlideShare a Scribd company logo

The core libraries you always wanted - Google Guava

jPrime slides

1 of 47
Download to read offline
@mitemitreski
The core libraries you
always wanted
Google Guava
The core libraries you always wanted - Google Guava
What is Google Guava?
com.google.common.annotation
com.google.common.base
com.google.common.collect
com.google.common.io
com.google.common.net
com.google.common.primitives
com.google.common.util.concurrent
...
Code in slides
Apache 2 license
latest release is 18.0,
released August 25, 2014.
Guava facts
NULL it is
"Null sucks." - Doug Lea
"I call it my billion-dollar
mistake." - C. A. R. Hoare
Ad

Recommended

Google Guava for cleaner code
Google Guava for cleaner codeGoogle Guava for cleaner code
Google Guava for cleaner codeMite Mitreski
 
Google guava - almost everything you need to know
Google guava - almost everything you need to knowGoogle guava - almost everything you need to know
Google guava - almost everything you need to knowTomasz Dziurko
 
Google Guava - Core libraries for Java & Android
Google Guava - Core libraries for Java & AndroidGoogle Guava - Core libraries for Java & Android
Google Guava - Core libraries for Java & AndroidJordi Gerona
 
Clean code with google guava jee conf
Clean code with google guava jee confClean code with google guava jee conf
Clean code with google guava jee confIgor Anishchenko
 
Google guava overview
Google guava overviewGoogle guava overview
Google guava overviewSteve Min
 

More Related Content

What's hot

Google Guava & EMF @ GTUG Nantes
Google Guava & EMF @ GTUG NantesGoogle Guava & EMF @ GTUG Nantes
Google Guava & EMF @ GTUG Nantesmikaelbarbero
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsBaruch Sadogursky
 
Java 8 Puzzlers [as presented at OSCON 2016]
Java 8 Puzzlers [as presented at  OSCON 2016]Java 8 Puzzlers [as presented at  OSCON 2016]
Java 8 Puzzlers [as presented at OSCON 2016]Baruch Sadogursky
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.David Gómez García
 
Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101Ankur Gupta
 
Jquery 1.3 cheatsheet_v1
Jquery 1.3 cheatsheet_v1Jquery 1.3 cheatsheet_v1
Jquery 1.3 cheatsheet_v1Sultan Khan
 
Jquery 13 cheatsheet_v1
Jquery 13 cheatsheet_v1Jquery 13 cheatsheet_v1
Jquery 13 cheatsheet_v1ilesh raval
 
5-minute intro to property-based testing in Python with hypothesis
5-minute intro to property-based testing in Python with hypothesis5-minute intro to property-based testing in Python with hypothesis
5-minute intro to property-based testing in Python with hypothesisFranklin Chen
 
Collections Framework
Collections FrameworkCollections Framework
Collections FrameworkSunil OS
 
Java 8 new features or the ones you might actually use
Java 8 new features or the ones you might actually useJava 8 new features or the ones you might actually use
Java 8 new features or the ones you might actually useSharon Rozinsky
 
Stuff you didn't know about action script
Stuff you didn't know about action scriptStuff you didn't know about action script
Stuff you didn't know about action scriptChristophe Herreman
 
Kotlin collections
Kotlin collectionsKotlin collections
Kotlin collectionsMyeongin Woo
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheeltcurdt
 
Functional Programming In Java
Functional Programming In JavaFunctional Programming In Java
Functional Programming In JavaAndrei Solntsev
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance PythonIan Ozsvald
 
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with JavassistJEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with JavassistAnton Arhipov
 
Programmation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScriptProgrammation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScriptLoïc Knuchel
 

What's hot (20)

Google Guava & EMF @ GTUG Nantes
Google Guava & EMF @ GTUG NantesGoogle Guava & EMF @ GTUG Nantes
Google Guava & EMF @ GTUG Nantes
 
Java Generics
Java GenericsJava Generics
Java Generics
 
The Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 SeasonsThe Groovy Puzzlers – The Complete 01 and 02 Seasons
The Groovy Puzzlers – The Complete 01 and 02 Seasons
 
Java 8 Puzzlers [as presented at OSCON 2016]
Java 8 Puzzlers [as presented at  OSCON 2016]Java 8 Puzzlers [as presented at  OSCON 2016]
Java 8 Puzzlers [as presented at OSCON 2016]
 
Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.Java 8 Stream API. A different way to process collections.
Java 8 Stream API. A different way to process collections.
 
Python Performance 101
Python Performance 101Python Performance 101
Python Performance 101
 
Jquery 1.3 cheatsheet_v1
Jquery 1.3 cheatsheet_v1Jquery 1.3 cheatsheet_v1
Jquery 1.3 cheatsheet_v1
 
Jquery 13 cheatsheet_v1
Jquery 13 cheatsheet_v1Jquery 13 cheatsheet_v1
Jquery 13 cheatsheet_v1
 
5-minute intro to property-based testing in Python with hypothesis
5-minute intro to property-based testing in Python with hypothesis5-minute intro to property-based testing in Python with hypothesis
5-minute intro to property-based testing in Python with hypothesis
 
Collections Framework
Collections FrameworkCollections Framework
Collections Framework
 
Java 8 new features or the ones you might actually use
Java 8 new features or the ones you might actually useJava 8 new features or the ones you might actually use
Java 8 new features or the ones you might actually use
 
Stuff you didn't know about action script
Stuff you didn't know about action scriptStuff you didn't know about action script
Stuff you didn't know about action script
 
Kotlin collections
Kotlin collectionsKotlin collections
Kotlin collections
 
Apache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheelApache Commons - Don\'t re-invent the wheel
Apache Commons - Don\'t re-invent the wheel
 
Functional Programming In Java
Functional Programming In JavaFunctional Programming In Java
Functional Programming In Java
 
Euro python2011 High Performance Python
Euro python2011 High Performance PythonEuro python2011 High Performance Python
Euro python2011 High Performance Python
 
What is new in Java 8
What is new in Java 8What is new in Java 8
What is new in Java 8
 
JEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with JavassistJEEConf 2017 - Having fun with Javassist
JEEConf 2017 - Having fun with Javassist
 
Programmation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScriptProgrammation fonctionnelle en JavaScript
Programmation fonctionnelle en JavaScript
 
Functional programming in java
Functional programming in javaFunctional programming in java
Functional programming in java
 

Viewers also liked

Soil experiment
Soil experimentSoil experiment
Soil experimentnewham5-6
 
Curricularesprimerainf
CurricularesprimerainfCurricularesprimerainf
CurricularesprimerainfCarlos Soto
 
Dos and don'ts of job interview
Dos and don'ts of job interviewDos and don'ts of job interview
Dos and don'ts of job interviewPedro Daniel Cosme
 
Zillow Economic Update at NAREE
Zillow Economic Update at NAREEZillow Economic Update at NAREE
Zillow Economic Update at NAREECile Montgomery
 
Avvio webinar global marketing tips, techniques & tactics
Avvio webinar   global marketing tips, techniques & tacticsAvvio webinar   global marketing tips, techniques & tactics
Avvio webinar global marketing tips, techniques & tacticsAvvio
 
MM - University of Calgary - Nov. 17, 2011 - EN
MM - University of Calgary - Nov. 17, 2011 - ENMM - University of Calgary - Nov. 17, 2011 - EN
MM - University of Calgary - Nov. 17, 2011 - ENctc-cct
 
Hipoperfusao oculta
Hipoperfusao oculta Hipoperfusao oculta
Hipoperfusao oculta wruivo
 
Nei , teniamoli sotto controllo.
Nei , teniamoli sotto controllo.Nei , teniamoli sotto controllo.
Nei , teniamoli sotto controllo.Cagliostro Puntodue
 
Evolution, Humanity and Religion Where is the evidence for God?
Evolution, Humanity and Religion Where is the evidence for God?Evolution, Humanity and Religion Where is the evidence for God?
Evolution, Humanity and Religion Where is the evidence for God?William Hall
 
MOOCs - disruptive innovation for higher education(rev1)
MOOCs - disruptive innovation for higher education(rev1)MOOCs - disruptive innovation for higher education(rev1)
MOOCs - disruptive innovation for higher education(rev1)William Hall
 
Prijswinnaar #hetbestejebest-prijs week 3
Prijswinnaar #hetbestejebest-prijs week 3Prijswinnaar #hetbestejebest-prijs week 3
Prijswinnaar #hetbestejebest-prijs week 3Webredactie_Zwijsen
 
I Congreso Oportunidades Empresariales del Milenio. Presentación Gráfica
I Congreso Oportunidades Empresariales del Milenio. Presentación GráficaI Congreso Oportunidades Empresariales del Milenio. Presentación Gráfica
I Congreso Oportunidades Empresariales del Milenio. Presentación GráficaRobert Estanga
 
Turma m8 noturno 2011.1
Turma m8    noturno 2011.1Turma m8    noturno 2011.1
Turma m8 noturno 2011.1cepmaio
 
Rea e formação de professores
Rea e formação de professoresRea e formação de professores
Rea e formação de professoreskeriduxa
 
Kachniewska M., "Lider-menedżer-mistrz: wiedza i kompetencje"
Kachniewska M., "Lider-menedżer-mistrz: wiedza i kompetencje"Kachniewska M., "Lider-menedżer-mistrz: wiedza i kompetencje"
Kachniewska M., "Lider-menedżer-mistrz: wiedza i kompetencje"Magdalena Kachniewska
 

Viewers also liked (20)

Sump pump
Sump pumpSump pump
Sump pump
 
Soil experiment
Soil experimentSoil experiment
Soil experiment
 
Curricularesprimerainf
CurricularesprimerainfCurricularesprimerainf
Curricularesprimerainf
 
Dos and don'ts of job interview
Dos and don'ts of job interviewDos and don'ts of job interview
Dos and don'ts of job interview
 
Zillow Economic Update at NAREE
Zillow Economic Update at NAREEZillow Economic Update at NAREE
Zillow Economic Update at NAREE
 
Avvio webinar global marketing tips, techniques & tactics
Avvio webinar   global marketing tips, techniques & tacticsAvvio webinar   global marketing tips, techniques & tactics
Avvio webinar global marketing tips, techniques & tactics
 
김민경
김민경김민경
김민경
 
MM - University of Calgary - Nov. 17, 2011 - EN
MM - University of Calgary - Nov. 17, 2011 - ENMM - University of Calgary - Nov. 17, 2011 - EN
MM - University of Calgary - Nov. 17, 2011 - EN
 
Mediatorパターン
MediatorパターンMediatorパターン
Mediatorパターン
 
Hipoperfusao oculta
Hipoperfusao oculta Hipoperfusao oculta
Hipoperfusao oculta
 
Promotional Bag Ideas by Sinoway
Promotional Bag Ideas by SinowayPromotional Bag Ideas by Sinoway
Promotional Bag Ideas by Sinoway
 
Nei , teniamoli sotto controllo.
Nei , teniamoli sotto controllo.Nei , teniamoli sotto controllo.
Nei , teniamoli sotto controllo.
 
Evolution, Humanity and Religion Where is the evidence for God?
Evolution, Humanity and Religion Where is the evidence for God?Evolution, Humanity and Religion Where is the evidence for God?
Evolution, Humanity and Religion Where is the evidence for God?
 
MOOCs - disruptive innovation for higher education(rev1)
MOOCs - disruptive innovation for higher education(rev1)MOOCs - disruptive innovation for higher education(rev1)
MOOCs - disruptive innovation for higher education(rev1)
 
City hall
City hallCity hall
City hall
 
Prijswinnaar #hetbestejebest-prijs week 3
Prijswinnaar #hetbestejebest-prijs week 3Prijswinnaar #hetbestejebest-prijs week 3
Prijswinnaar #hetbestejebest-prijs week 3
 
I Congreso Oportunidades Empresariales del Milenio. Presentación Gráfica
I Congreso Oportunidades Empresariales del Milenio. Presentación GráficaI Congreso Oportunidades Empresariales del Milenio. Presentación Gráfica
I Congreso Oportunidades Empresariales del Milenio. Presentación Gráfica
 
Turma m8 noturno 2011.1
Turma m8    noturno 2011.1Turma m8    noturno 2011.1
Turma m8 noturno 2011.1
 
Rea e formação de professores
Rea e formação de professoresRea e formação de professores
Rea e formação de professores
 
Kachniewska M., "Lider-menedżer-mistrz: wiedza i kompetencje"
Kachniewska M., "Lider-menedżer-mistrz: wiedza i kompetencje"Kachniewska M., "Lider-menedżer-mistrz: wiedza i kompetencje"
Kachniewska M., "Lider-menedżer-mistrz: wiedza i kompetencje"
 

Similar to The core libraries you always wanted - Google Guava

Guava Overview. Part 1 @ Bucharest JUG #1
Guava Overview. Part 1 @ Bucharest JUG #1 Guava Overview. Part 1 @ Bucharest JUG #1
Guava Overview. Part 1 @ Bucharest JUG #1 Andrei Savu
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good TestsTomek Kaczanowski
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good TestsTomek Kaczanowski
 
Java best practices
Java best practicesJava best practices
Java best practicesRay Toal
 
AJUG April 2011 Cascading example
AJUG April 2011 Cascading exampleAJUG April 2011 Cascading example
AJUG April 2011 Cascading exampleChristopher Curtin
 
[Quality Meetup] Piotr Wittchen - Fixing a billion dollar mistake
[Quality Meetup] Piotr Wittchen - Fixing a billion dollar mistake[Quality Meetup] Piotr Wittchen - Fixing a billion dollar mistake
[Quality Meetup] Piotr Wittchen - Fixing a billion dollar mistakeFuture Processing
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first stepsRenato Primavera
 
Beauty and the beast - Haskell on JVM
Beauty and the beast  - Haskell on JVMBeauty and the beast  - Haskell on JVM
Beauty and the beast - Haskell on JVMJarek Ratajski
 
Google collections api an introduction
Google collections api   an introductionGoogle collections api   an introduction
Google collections api an introductiongosain20
 
05 pig user defined functions (udfs)
05 pig user defined functions (udfs)05 pig user defined functions (udfs)
05 pig user defined functions (udfs)Subhas Kumar Ghosh
 
GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?Patrick Lam
 
Testing Java Code Effectively
Testing Java Code EffectivelyTesting Java Code Effectively
Testing Java Code EffectivelyAndres Almiray
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unitliminescence
 
Java Boilerplate Busters
Java Boilerplate BustersJava Boilerplate Busters
Java Boilerplate BustersHamletDRC
 

Similar to The core libraries you always wanted - Google Guava (20)

Guava Overview. Part 1 @ Bucharest JUG #1
Guava Overview. Part 1 @ Bucharest JUG #1 Guava Overview. Part 1 @ Bucharest JUG #1
Guava Overview. Part 1 @ Bucharest JUG #1
 
2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests2012 JDays Bad Tests Good Tests
2012 JDays Bad Tests Good Tests
 
33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests33rd Degree 2013, Bad Tests, Good Tests
33rd Degree 2013, Bad Tests, Good Tests
 
Java best practices
Java best practicesJava best practices
Java best practices
 
Amazon elastic map reduce
Amazon elastic map reduceAmazon elastic map reduce
Amazon elastic map reduce
 
AJUG April 2011 Cascading example
AJUG April 2011 Cascading exampleAJUG April 2011 Cascading example
AJUG April 2011 Cascading example
 
[Quality Meetup] Piotr Wittchen - Fixing a billion dollar mistake
[Quality Meetup] Piotr Wittchen - Fixing a billion dollar mistake[Quality Meetup] Piotr Wittchen - Fixing a billion dollar mistake
[Quality Meetup] Piotr Wittchen - Fixing a billion dollar mistake
 
Eta
EtaEta
Eta
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first steps
 
Beauty and the beast - Haskell on JVM
Beauty and the beast  - Haskell on JVMBeauty and the beast  - Haskell on JVM
Beauty and the beast - Haskell on JVM
 
JUnit Pioneer
JUnit PioneerJUnit Pioneer
JUnit Pioneer
 
Google collections api an introduction
Google collections api   an introductionGoogle collections api   an introduction
Google collections api an introduction
 
ppopoff
ppopoffppopoff
ppopoff
 
05 pig user defined functions (udfs)
05 pig user defined functions (udfs)05 pig user defined functions (udfs)
05 pig user defined functions (udfs)
 
Java 5 Features
Java 5 FeaturesJava 5 Features
Java 5 Features
 
GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?GTAC 2014: What lurks in test suites?
GTAC 2014: What lurks in test suites?
 
Testing Java Code Effectively
Testing Java Code EffectivelyTesting Java Code Effectively
Testing Java Code Effectively
 
Pragmatic unittestingwithj unit
Pragmatic unittestingwithj unitPragmatic unittestingwithj unit
Pragmatic unittestingwithj unit
 
Kpi driven-java-development-fn conf
Kpi driven-java-development-fn confKpi driven-java-development-fn conf
Kpi driven-java-development-fn conf
 
Java Boilerplate Busters
Java Boilerplate BustersJava Boilerplate Busters
Java Boilerplate Busters
 

More from Mite Mitreski

Getting all the 99.99(9) you always wanted
Getting all the 99.99(9) you always wanted Getting all the 99.99(9) you always wanted
Getting all the 99.99(9) you always wanted Mite Mitreski
 
Micro service pitfalls voxxed days istanbul 2015
Micro service pitfalls voxxed days istanbul 2015Micro service pitfalls voxxed days istanbul 2015
Micro service pitfalls voxxed days istanbul 2015Mite Mitreski
 
Devoxx 2014 : Sparky guide to bug free JavaScirpt
Devoxx 2014 : Sparky guide to bug free JavaScirptDevoxx 2014 : Sparky guide to bug free JavaScirpt
Devoxx 2014 : Sparky guide to bug free JavaScirptMite Mitreski
 
Microservice pitfalls
Microservice pitfalls Microservice pitfalls
Microservice pitfalls Mite Mitreski
 
Java2day 2013 : Modern workflows for javascript integration
Java2day 2013 : Modern workflows for javascript integrationJava2day 2013 : Modern workflows for javascript integration
Java2day 2013 : Modern workflows for javascript integrationMite Mitreski
 
Eclipse 10 years Party
Eclipse 10 years PartyEclipse 10 years Party
Eclipse 10 years PartyMite Mitreski
 

More from Mite Mitreski (8)

Getting all the 99.99(9) you always wanted
Getting all the 99.99(9) you always wanted Getting all the 99.99(9) you always wanted
Getting all the 99.99(9) you always wanted
 
Micro service pitfalls voxxed days istanbul 2015
Micro service pitfalls voxxed days istanbul 2015Micro service pitfalls voxxed days istanbul 2015
Micro service pitfalls voxxed days istanbul 2015
 
Devoxx 2014 : Sparky guide to bug free JavaScirpt
Devoxx 2014 : Sparky guide to bug free JavaScirptDevoxx 2014 : Sparky guide to bug free JavaScirpt
Devoxx 2014 : Sparky guide to bug free JavaScirpt
 
Microservice pitfalls
Microservice pitfalls Microservice pitfalls
Microservice pitfalls
 
Unix for developers
Unix for developersUnix for developers
Unix for developers
 
State of the lambda
State of the lambdaState of the lambda
State of the lambda
 
Java2day 2013 : Modern workflows for javascript integration
Java2day 2013 : Modern workflows for javascript integrationJava2day 2013 : Modern workflows for javascript integration
Java2day 2013 : Modern workflows for javascript integration
 
Eclipse 10 years Party
Eclipse 10 years PartyEclipse 10 years Party
Eclipse 10 years Party
 

Recently uploaded

1.2 Ingredients Used for Sandwiches 1.3 Culinary Terms.pptx
1.2 Ingredients Used for Sandwiches 1.3 Culinary Terms.pptx1.2 Ingredients Used for Sandwiches 1.3 Culinary Terms.pptx
1.2 Ingredients Used for Sandwiches 1.3 Culinary Terms.pptxNinia
 
Instructional Supervision - By Dr. Cherinet Aytenfsu Weldearegay.pdf
Instructional Supervision - By Dr. Cherinet Aytenfsu Weldearegay.pdfInstructional Supervision - By Dr. Cherinet Aytenfsu Weldearegay.pdf
Instructional Supervision - By Dr. Cherinet Aytenfsu Weldearegay.pdfaytenfsuc
 
Supporting Resilient Prosperity in the Caribbean
Supporting Resilient Prosperity in the CaribbeanSupporting Resilient Prosperity in the Caribbean
Supporting Resilient Prosperity in the CaribbeanCaribbean Development Bank
 
Partnerships for Resilient Prosperity in the Caribbean
Partnerships for Resilient Prosperity in the CaribbeanPartnerships for Resilient Prosperity in the Caribbean
Partnerships for Resilient Prosperity in the CaribbeanCaribbean Development Bank
 
DAY 05 Book of Revelation 2-18-24 PPT.pptx
DAY 05 Book of Revelation 2-18-24 PPT.pptxDAY 05 Book of Revelation 2-18-24 PPT.pptx
DAY 05 Book of Revelation 2-18-24 PPT.pptxFamilyWorshipCenterD
 
Teams Nation 2024 - #Copilot & Teams or Just Premium.pptx
Teams Nation 2024 - #Copilot & Teams or Just Premium.pptxTeams Nation 2024 - #Copilot & Teams or Just Premium.pptx
Teams Nation 2024 - #Copilot & Teams or Just Premium.pptxKai Stenberg
 
AWS RDS Data API and CloudTrail. Who drop the table_.pdf
AWS RDS Data API and CloudTrail. Who drop the table_.pdfAWS RDS Data API and CloudTrail. Who drop the table_.pdf
AWS RDS Data API and CloudTrail. Who drop the table_.pdfVladimir Samoylov
 
ONLINE RESORT BOOKING SYSTEM WEBSITE 1.pptx
ONLINE RESORT BOOKING SYSTEM WEBSITE 1.pptxONLINE RESORT BOOKING SYSTEM WEBSITE 1.pptx
ONLINE RESORT BOOKING SYSTEM WEBSITE 1.pptxDivyaPatel621561
 
Space expansion: cultural considerations, long term perspectives, and spiritu...
Space expansion: cultural considerations, long term perspectives, and spiritu...Space expansion: cultural considerations, long term perspectives, and spiritu...
Space expansion: cultural considerations, long term perspectives, and spiritu...Giulio Prisco
 
Chapter 20 Firms in IGCSE economics presentation
Chapter 20  Firms in IGCSE  economics presentationChapter 20  Firms in IGCSE  economics presentation
Chapter 20 Firms in IGCSE economics presentationSamandarbekNumonov
 
VAWC-RA-9262 Anti Violence Against Women and THeir Children
VAWC-RA-9262 Anti Violence Against Women and THeir ChildrenVAWC-RA-9262 Anti Violence Against Women and THeir Children
VAWC-RA-9262 Anti Violence Against Women and THeir Childrendilgpitogo2023
 
KKrish - DOVE Leadership Program Concept
KKrish - DOVE Leadership Program ConceptKKrish - DOVE Leadership Program Concept
KKrish - DOVE Leadership Program ConceptKarthik Krishna
 
Present and Future Requisites for Prosperity in the Caribbean
Present and Future Requisites for Prosperity in the CaribbeanPresent and Future Requisites for Prosperity in the Caribbean
Present and Future Requisites for Prosperity in the CaribbeanCaribbean Development Bank
 

Recently uploaded (14)

1.2 Ingredients Used for Sandwiches 1.3 Culinary Terms.pptx
1.2 Ingredients Used for Sandwiches 1.3 Culinary Terms.pptx1.2 Ingredients Used for Sandwiches 1.3 Culinary Terms.pptx
1.2 Ingredients Used for Sandwiches 1.3 Culinary Terms.pptx
 
Instructional Supervision - By Dr. Cherinet Aytenfsu Weldearegay.pdf
Instructional Supervision - By Dr. Cherinet Aytenfsu Weldearegay.pdfInstructional Supervision - By Dr. Cherinet Aytenfsu Weldearegay.pdf
Instructional Supervision - By Dr. Cherinet Aytenfsu Weldearegay.pdf
 
Supporting Resilient Prosperity in the Caribbean
Supporting Resilient Prosperity in the CaribbeanSupporting Resilient Prosperity in the Caribbean
Supporting Resilient Prosperity in the Caribbean
 
Partnerships for Resilient Prosperity in the Caribbean
Partnerships for Resilient Prosperity in the CaribbeanPartnerships for Resilient Prosperity in the Caribbean
Partnerships for Resilient Prosperity in the Caribbean
 
DAY 05 Book of Revelation 2-18-24 PPT.pptx
DAY 05 Book of Revelation 2-18-24 PPT.pptxDAY 05 Book of Revelation 2-18-24 PPT.pptx
DAY 05 Book of Revelation 2-18-24 PPT.pptx
 
Teams Nation 2024 - #Copilot & Teams or Just Premium.pptx
Teams Nation 2024 - #Copilot & Teams or Just Premium.pptxTeams Nation 2024 - #Copilot & Teams or Just Premium.pptx
Teams Nation 2024 - #Copilot & Teams or Just Premium.pptx
 
AWS RDS Data API and CloudTrail. Who drop the table_.pdf
AWS RDS Data API and CloudTrail. Who drop the table_.pdfAWS RDS Data API and CloudTrail. Who drop the table_.pdf
AWS RDS Data API and CloudTrail. Who drop the table_.pdf
 
ONLINE RESORT BOOKING SYSTEM WEBSITE 1.pptx
ONLINE RESORT BOOKING SYSTEM WEBSITE 1.pptxONLINE RESORT BOOKING SYSTEM WEBSITE 1.pptx
ONLINE RESORT BOOKING SYSTEM WEBSITE 1.pptx
 
Space expansion: cultural considerations, long term perspectives, and spiritu...
Space expansion: cultural considerations, long term perspectives, and spiritu...Space expansion: cultural considerations, long term perspectives, and spiritu...
Space expansion: cultural considerations, long term perspectives, and spiritu...
 
Auditorium Session 1 - Connection - Inclusion
Auditorium Session 1 - Connection - InclusionAuditorium Session 1 - Connection - Inclusion
Auditorium Session 1 - Connection - Inclusion
 
Chapter 20 Firms in IGCSE economics presentation
Chapter 20  Firms in IGCSE  economics presentationChapter 20  Firms in IGCSE  economics presentation
Chapter 20 Firms in IGCSE economics presentation
 
VAWC-RA-9262 Anti Violence Against Women and THeir Children
VAWC-RA-9262 Anti Violence Against Women and THeir ChildrenVAWC-RA-9262 Anti Violence Against Women and THeir Children
VAWC-RA-9262 Anti Violence Against Women and THeir Children
 
KKrish - DOVE Leadership Program Concept
KKrish - DOVE Leadership Program ConceptKKrish - DOVE Leadership Program Concept
KKrish - DOVE Leadership Program Concept
 
Present and Future Requisites for Prosperity in the Caribbean
Present and Future Requisites for Prosperity in the CaribbeanPresent and Future Requisites for Prosperity in the Caribbean
Present and Future Requisites for Prosperity in the Caribbean
 

The core libraries you always wanted - Google Guava

  • 1. @mitemitreski The core libraries you always wanted Google Guava
  • 3. What is Google Guava? com.google.common.annotation com.google.common.base com.google.common.collect com.google.common.io com.google.common.net com.google.common.primitives com.google.common.util.concurrent ...
  • 5. Apache 2 license latest release is 18.0, released August 25, 2014. Guava facts
  • 6. NULL it is "Null sucks." - Doug Lea "I call it my billion-dollar mistake." - C. A. R. Hoare
  • 7. Null is ambiguous if ( x != null && x.someM()!=null && ) { // work with x.someM() } Boolean isAwesome ; // can be NULL, TRUE, FALSE Assert.notNull(x); Assert.notNull(x.someM()); // work with x.someM()
  • 8. import com.google.common.base.* @Test public void optionalExample() { Optional<Integer> possible = Optional.of(3); // Make optional of given type possible.isPresent(); // evaluate to true if nonNull possible.or(10); // evaluate to possible's value or default possible.get(); // evaluate to 3 }
  • 9. import com.google.common.base.* public void testNeverNullWithoutGuava() { Integer defaultId = null; Integer id = theUnknowMan.getId() != null ? theUnknowMan.getId() : defaultId; assertNotNull(id); } public void firstNotNull() { Integer a = Objects.firstNonNull(null, 3); // will evaluate to 3 Integer b = Objects.firstNonNull(9, 3); // //will evaluate to 9 assertEquals(Integer.valueOf(3), a); assertEquals(Integer.valueOf(9), b); }
  • 10. import static com.google.common.base.Preconditions.*; private Customer theUnknowMan = new Customer(); @Test(expected = IllegalArgumentException.class) public void somePreconditions() { checkNotNull(theUnknowMan.getId()); // Will throw NPE checkState(!theUnknowMan.isSick()); // Will throw IllegalStateException checkArgument(theUnknowMan.getAddress() != null, "We couldn't find the description for customer with id %s", theUnknowMan. getId()); }
  • 11. JSR-305 Annotations for software defect detection @Nullable @NotNull 1. javax.validation.constraints.NotNull - EE6 2. edu.umd.cs.findbugs.annotations.NonNull – Findbugs, Sonar 3. javax.annotation.Nonnull – JSR-305 4. com.intellij.annotations.NotNull - IntelliJIDEA The Executive Committee voted to list this JSR as dormant in May 2012.
  • 12. But JDK 8 has java.util.Optional … and java.util.Objects … and guava has com.google.common.base.MoreObjects
  • 13. import static com.google.common.base.Preconditions.*; private Customer theUnknowMan = new Customer(); @Test(expected = IllegalArgumentException.class) public void somePreconditions() { checkNotNull(theUnknowMan.getId()); // Will throw NPE checkState(!theUnknowMan.isSick()); // Will throw IllegalStateException checkArgument(theUnknowMan.getAddress() != null, "We couldn't find the description for customer with id %s", theUnknowMan. getId()); } JDK8+ just use java.util. Objects + Optional
  • 15. @Beta annotated API is subject to change any time @Deprecated annotated API is removed in 18+ months after depreciation Serialization compatibility is NOT guaranteed
  • 16. Guava's "fluent" Comparator class. Ordering<Customer> ordering = Ordering .natural() .nullsFirst().onResultOf( new Function<Customer, Comparable>() { @Override public Comparable apply(Customer customer) { return customer.getName(); } } );
  • 18. Character Matchers Use a predefined constant (examples) • CharMatcher.WHITESPACE (tracks Unicode defn.) • CharMatcher.JAVA_DIGIT • CharMatcher.ASCII • CharMatcher.ANY Use a factory method (examples) • CharMatcher.is('x') • CharMatcher.isNot('_') • CharMatcher.oneOf("aeiou").negate() • CharMatcher.inRange('a', 'z').or(inRange('A','Z'))
  • 19. Character Matchers String noControl = CharMatcher.JAVA_ISO_CONTROL.removeFrom(string); String theDigits = CharMatcher.DIGIT.retainFrom(string); String lowerAndDigit = CharMatcher.or(CharMatcher.JAVA_DIGIT, CharMatcher.JAVA_LOWER_CASE).retainFrom(string);
  • 20. import com.google.common.cache.*; Cache<Integer, Customer> cache = CacheBuilder.newBuilder() .maximumSize(10000) .build();
  • 21. Eviction Cache<Integer, Customer> cache = CacheBuilder.newBuilder() .expireAfterWrite(2, TimeUnit.MINUTES) .build(); Cache<Integer, Customer> cache = CacheBuilder.newBuilder() .expireAfterAccess(2,TimeUnit.MINUTES) .build();
  • 22. Eviction Cache<Integer, Customer> cache = CacheBuilder.newBuilder() .weigher(new Weigher<Integer, Customer>() { @Override public int weigh(Integer key, Customer value) { return value.getName().length(); } }).maximumWeight(20) //0 all good 21 evict something .build();
  • 23. import com.google.common.cache.*; Cache<Integer, Customer> cache = CacheBuilder.newBuilder() .weakKeys() .maximumSize(10000) .expireAfterWrite(10, TimeUnit.MINUTES) .build();
  • 24. It’s all about the numbers Cache<Integer, Customer> cache = CacheBuilder.newBuilder() .recordStats() .build(); CacheStats stats = cache.stats(); stats.hitRate(); stats.averageLoadPenalty(); stats.missCount(); stats.missRate();
  • 25. Map != Cache ● Map.get causes a type-safety hole ● Map.get is a read operation and users don't expect it to also write ● Map.equals is not symmetric on a self-populating Map
  • 26. com.google.common.collect.*; • Immutable Collections • Multimaps, Multisets, BiMaps... aka Google- Collections • Comparator-related utilities • Stuff similar to Apache commons collections • Some functional programming support (filter/transform/etc.)
  • 28. BiMap ● BiMap<K, V> is Map<K,V> with unique values ● Operations: all Map, inverse(), values() as Set ● Throws an IllegalArgumentException if you attempt to map a key to an already-present value
  • 29. Functions and Predicates Function<String, Integer> lengthFunction = new Function<String, Integer>() { public Integer apply(String string) { return string.length(); } }; Predicate<String> allCaps = new Predicate<String>() { public boolean apply(String string) { return CharMatcher.JAVA_UPPER_CASE.matchesAllOf(string); } };
  • 30. Functions and Predicates Function<String, Integer> lengthFunction = String::length; Predicate<String> allCaps = CharMatcher.JAVA_UPPER_CASE::matchesAllOf;
  • 31. Functional aka Single Abstract Method interfaces - SAM
  • 32. Functionality Guava JDK 8 Predicate apply(T input) test(T input) Combining predicates Predicates.and/or/not Predicate.and/or/negate Supplier Suplier.get Supplier.get Joiner/StringJoiner Joiner.join() StringJoiner.add() SettableFuture/CompletableFutu re SettableFuture.set(T input) CompletableFuture.complete(T input) Optional Optional.of/ofNullable/empty Optional.of/fromNullable/absent
  • 33. Filter collections SortedMap<String, String> map = new TreeMap<>(); map.put("1", "one"); map.put("2", "two"); map.put("3", null); map.put("4", "four"); SortedMap<String, String> filtered = Maps.filterValues(map, Predicates.notNull()); assertThat(filtered.size(), is(3)); // null entry for "3" is gone!
  • 36. Java 8 - aggregate operations http://docs.oracle.com/javase/tutorial/collections/streams/index.html roster .stream() .filter(e -> e.getGender() == Person.Sex.MALE) .forEach(e -> System.out.println(e.getName());
  • 37. Java 8 - aggregate operations http://docs.oracle.com/javase/tutorial/collections/streams/index.html double average = roster .stream() .filter(p -> p.getGender() == Person.Sex.MALE) .mapToInt(Person::getAge) .average() .getAsDouble();
  • 38. Collection goodies // oldway Map<String, Map<Long, List<String>>> mapOld = new HashMap<String, Map<Long, List<String>>>(); // the guava way Map<String, Map<Long, List<String>>> map = Maps.newHashMap(); // list ImmutableList<String> of = ImmutableList.of("a", "b", "c"); // Same one for map ImmutableMap<String, String> theMap = ImmutableMap.of("key1", "value1", "key2", "value2"); //list of ints List<Integer> theList = Ints.asList(1, 2, 3, 4, 522, 5, 6);
  • 39. Load resources Resources.getResource("com/tfnico/examples/guava/BaseTest.class"); // instead of this: String location = "com/tfnico/examples/guava/BaseTest.class"; URL resource2 = this.getClass().getClassLoader().getResource(location); Preconditions.checkArgument(resource2 != null, "resource %s not found", location);
  • 40. Hashing HashFunction hf = Hashing.md5(); Customer c = new Customer(); // into is a primitive sink Funnel<? super Customer> customerFunnel = (from, into) -> { into.putString(from.getName(),Charsets.UTF_8); into.putInt(from.getId()); }; HashCode hc = hf.newHasher() .putLong(2) .putString("Mite", Charsets.UTF_8) .putObject(c, customerFunnel) .hash();
  • 41. Bloom filter BloomFilter<Customer> awesomeCusumers = BloomFilter.create(customerFunnel, 500, 0.01); List<Customer> friendsList = Lists.newArrayList( new Customer(), new Customer()); for(Customer friend : friendsList) { awesomeCusumers.put(friend); } Customer thatStrangeGuy = new Customer(); if (awesomeCusumers.mightContain(thatStrangeGuy)) { //that strange guy is not a cusumer and we have reachet this line //probablility 0.01 }
  • 43. When to use Guava? ● Temporary collections ● Mutable collections ● String Utils ● Check if (x==null) ● Always ?
  • 44. Why use a Guava? "I could just write that myself." But… These things are much easier to mess up than it seems •With a library, other people will make your code faster and better for You
  • 45. Major stuff I did not mentioned EventBus IO Reflection Math Ranges
  • 47. BG-JUG and JugMK community