java.lang.Object | |
↳ | com.atlassian.bitbucket.util.MoreCollectors |
Additional utility methods missing from Collectors. The implementation of these collectors, where possible, attempts to emulate the behavior of the standard Collectors factories.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a
Collector that accumulates elements into an immutable list. | |||||||||||
Returns a
Collector that accumulates elements into an immutable map whose keys and values
are the result of applying the provided mapping functions to the input elements. | |||||||||||
Returns a
Collector that accumulates elements into an immutable set. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Returns a Collector
that accumulates elements into an immutable list.
The Stream
being collected may contain null
elements and, when it does, the collected
list will also contain null
elements.
Collector
which collects elements into an immutable listReturns a Collector
that accumulates elements into an immutable map whose keys and values
are the result of applying the provided mapping functions to the input elements.
The Stream
being collected may contain null
elements, if the mapping functions handle
nulls
. However, like Collectors.toMap(Function, Function)
, this collector uses a
HashMap
to collect keys and values. Since its implementation is uses merge(K, V, BiFunction super V, ? super V, ? extends V>)
, the
valueMapper
may not produce null
values, even for null
inputs, or a
NullPointerException
will be thrown. The keyMapper
, on the other hand, may
return null
keys, but may not return duplicate keys or an IllegalStateException
will be thrown.
keyMapper | a mapping function to produce keys, which may return null |
---|---|
valueMapper | a mapping function to produce values, which may not return null |
Collector
which collects elements into an immutable mapReturns a Collector
that accumulates elements into an immutable set.
The Stream
being collected may contain null
elements and, when it does, the collected
set will also contain a null
element. Unlike Collectors.toSet()
, this collector attempts
to retain the traversal order of the stream's elements.
Collector
which collects elements into an immutable set