-
Notifications
You must be signed in to change notification settings - Fork 0
Release21
- 21.0 was released on January 12, 2017.
- 21.0-rc2 was released on January 3, 2017.
- 21.0-rc1 was released on December 19, 2016.
(See ReleaseHistory.)
API documentation:
Guava | Guava (GWT) | |
---|---|---|
Maven Identifier | com.google.guava:guava:21.0 | com.google.guava:guava-gwt:21.0 |
Jar | guava-21.0.jar | guava-gwt-21.0.jar |
Javadoc | guava-21.0-javadoc.jar | guava-gwt-21.0-javadoc.jar |
Sources | guava-21.0-sources.jar | guava-gwt-21.0-sources.jar |
See UseGuavaInYourBuild for help integrating Guava into your build environment.
Important: Guava 21.0 requires Java 8. If you need Java 7 or Android compatibility, use Guava 20.0 for now. Guava 22.0 and on will introduce a Java 7/Android compatible backport of Guava that includes all of the latest changes that don't require Java 8. (As for Java 6, we don't plan to support it past 20.0.)
5+ issues are resolved in this release.
Full JDiff Report of changes since release 20.0.
-
Function
,Predicate
andSupplier
: changed to extend the newjava.util.function
interfaces with the same names. -
Optional
: addedtoJavaUtil
andfromJavaUtil
methods for easy conversion between Guava'sOptional
andjava.util.Optional
. -
Objects
: removed deprecatedfirstNonNull
andtoStringHelper
methods (both found onMoreObjects
since Guava 18.0).
New default methods on ConcurrentMap
that were added in Java 8 are now implemented and safe to use for Cache.asMap()
views.
Many APIs in collect now have better implementations of many of the default
methods added to Collection
and Map
types in Java 8.
-
Comparators
: With the addition of many useful methods to theComparator
type in Java 8,Ordering
now provides little benefit.Comparators
is a new location for methods onOrdering
that still don't have a good equivalent in the JDK. -
Streams
: Utility class for working withjava.util.stream.Stream
. Includes methods for creating streams (such asstream(Iterable)
,stream(Optional)
andconcat(Stream...)
) and methods that do things with streams (such asfindLast(Stream)
). -
MoreCollectors
: Factories forjava.util.stream.Collector
objects; note thatCollector
s for Guava's collection types are generally found on those types themselves rather than here. -
Interners.InternerBuilder
: Builder forInterner
instances, with options similar to those found onMapMaker
. Created withInterners.newBuilder()
.
-
MapConstraint
andMapConstraints
: deprecated since 19.0.
-
FluentIterable
: addedstream()
method. -
ForwardingBlockingDeque
: deprecated; moved toutil.concurrent
. -
Immutable*
types: added methods to all namedtoImmutable[Type]()
(e.g.ImmutableList.toImmutableList()
) which return aCollector
for collecting aStream
into an immutable collection/map object. As with most methods that createCollector
s, these are generally intended to be used as static imports. -
Multimap
: addedforEach(BiConsumer)
method. -
Multimaps
: addedtoMultimap
andflatteningToMultimap
methods returningCollector
objects that collect to aMultimap
. -
Multiset
: addedforEachEntry(ObjIntConsumer)
method. -
Maps
: addedtoImmutableEnumMap
methods returningCollector
objects that collect to anImmutableMap
withenum
keys. -
Sets
: addedtoImmutableEnumSet
method returning aCollector
that collects to anImmutableSet
ofenum
s. -
Tables
: addedtoTable
methods returningCollector
objects that collect to aTable
. -
RangeSet
: added defaultaddAll(Iterable<Range>)
,removeAll(Iterable<Range>)
andenclosesAll(Iterable<Range>)
methods. -
ImmutableRangeSet
: addedcopyOf(Iterable<Range>)
,unionOf(Iterable<Range>)
,union(RangeSet)
,intersection(RangeSet)
anddifference(RangeSet)
methods. -
TreeRangeSet
: addedcreate(Iterable<Range>)
method. - A number of rarely-used methods on concrete implementations of Guava collection types that aren't present on the interface they implement have been deprecated. These include:
ArrayListMultimap.trimToSize()
,TreeMultimap.keyComparator()
, andTreeBasedTable.row/columnComparator()
.
-
MoreFiles
: New class which contains methods similar to those inFiles
, but for use withjava.nio.file.Path
objects. - This includes
deleteRecursively
anddeleteDirectoryContents
methods which are secure against race conditions that Java previously had no way of dealing with provided that theFileSystem
supportsSecureDirectoryStream
(modern Linux versions do; Windows [NTFS at least] does not). For security, these will throw an exception ifSecureDirectoryStream
is not supported unlessRecursiveDeleteOption.ALLOW_INSECURE
is passed when calling the method.
- Most classes: added
constrainToRange([type] value, [type] min, [type] max)
methods which constrain the given value to the closed range defined by themin
andmax
values. They return the value itself if it's within the range, themin
if it's below the range and themax
if it's above the range.
-
ForwardingBlockingDeque
: added; moved fromcommon.collect
becauseBlockingDeque
is a concurrent type rather than a standard collection (it's defined injava.util.concurrent
). -
AtomicLongMap
: added a number of methods such asaccumulateAndGet(K, LongBinaryOperator)
that take advantage of new Java functional types. -
Monitor
: addednewGuard(BooleanSupplier)
. -
MoreExecutors
: removedsameThreadExecutor()
; deprecated since 18.0 in favor ofdirectExecutor()
(preferable) ornewDirectExecutorService()
.
- Introduction
- Basic Utilities
- Collections
- Graphs
- Caches
- Functional Idioms
- Concurrency
- Strings
- Networking
- Primitives
- Ranges
- I/O
- Hashing
- EventBus
- Math
- Reflection
- Releases
- Tips
- Glossary
- Mailing List
- Stack Overflow
- Footprint of JDK/Guava data structures