The Java Evolution of Eclipse Collections
Speaker: Kristen O’Leary
See the list of all blog posts from the conference
Eclipse Collections
- was once GS (Goldman Sachs) Collections
- Memory efficient collections framework
- Open sourced in 2012
Java 8
- 8.0 compatible with Java 8+
- Extend Java 8 Functional Interfaces
- New APIs – ex: reduceInPlace
Optional
- RichIteratable.detectWith() used to rutn null if no match
- Pre Java-8 could use detectIfNone() to create if doesn’t exist
- New method detectWithOptional() which returns Optional wrapper
Collectors
- Collectors2 has collectors
- Can collect into Bag, ImmutableSet, BiMap, Stack, etc
- Have full primitive collections library
- Have full set of multi-map (map with multiple values for same key ex: key to list/set)
- Have extra APIs like chunk() and zip()
Default methods
- RichIterable is common interface so default methods helpful.
- Used to add reduceInPlace() so don’t need to stream and create new collection
- Also useful for asLazy() or toImutabile() since Eclipse Collections doesn’t provide stream() there.
Primitive Collections
- Code generate the primitive classes so symmetry
- Showed impressive memry savings – Eclipse Collections and Trove equivalent. Much smaller than with autoboxing and faster too
- LazyIterable availalbe for all 8 primitive types. Just call asLazy(). A LazyIterabe can be reused unlike a stream.
Java 9
- Module system
- Internal API Encapsulation
- Need to change APIs that use reflection in order to build. Can’t call setAccessible(true) any more.
- There is a command line argument to ignore reflection errors. Don’t want to impose that on callers
I like that Kristen uses kata examples to show hw the APIs work.