Google Guava
Google Guava
Margus Martsepp
History
Java collections was created in 1997
3 big ideas:
· interfaces (define collections)
· implementations (concrete or abstract)
· algorithms (to manipulate collections)
Basic idea around this framework:
Extensible - people can build on it
Overview
1. Utilities - {static constructors,functional -
{predicates, transform}}
2. Objects {equal, coalesce, ComparisonChain}
3. Immutable - {why, how, collections}
Utilities - static constructors
Create a list of 2 elements
Utilities - functional - predicates
Apply predicates on collections/iterables
Functional language equivalent
Utilities - functional - transform
Create a transformed view of a collection
Object - {equals, coalesce}
Equals (null safe)
Coalesce
Objects.firstNonNull(obj, default)
Object - ComparisonChain
CompareTo method:
Immutable - why
Why?
· + Your life is easy (no trust problems)
· + Free thread safety
· + Can be...