java.lang.Object | |
↳ | com.atlassian.jira.util.collect.MapBuilder<K, V> |
Utility for easily creating Maps of all standard types. If your map does not need to
contain null
as either a key or a value, then builder()
should be preferred.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
map |
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
prefer
newBuilder() for inferred generic arguments. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Add a key/value.
| |||||||||||
Add all the entries contained in the map.
| |||||||||||
Add a key/value only if the value is not
null . | |||||||||||
Returns an immutable Map containing the given key-value pairs.
| |||||||||||
Returns an immutable Map containing the given key-value pairs.
| |||||||||||
Returns an immutable Map containing the given key-value pairs.
| |||||||||||
Returns an immutable Map containing the given key-value pair.
| |||||||||||
Static factory method for creating an empty map.
| |||||||||||
Static factory method for creating a fresh
MapBuilder based on the contents of a source Map. | |||||||||||
Static factory method for creating a fresh
MapBuilder . | |||||||||||
Static factory method for creating a fresh
MapBuilder and adding the given key/value pairs. | |||||||||||
Static factory method for creating a fresh
MapBuilder and adding the given key/value pair. | |||||||||||
Static factory method for creating a fresh
MapBuilder and adding the given key/value pairs. | |||||||||||
Static factory method for creating a fresh
MapBuilder and adding the given key/value pairs. | |||||||||||
Static factory method for creating an immutable
Map with a single entry. | |||||||||||
This method is deprecated.
Use ImmutableMap directly instead. Since v6.1.
| |||||||||||
This method is deprecated.
Use ImmutableSortedMap directly instead. Since v6.1.
| |||||||||||
This method is deprecated.
Use ImmutableSortedMap directly instead. Since v6.1.
| |||||||||||
Returns a mutable
HashMap where the entries are in no defined order. | |||||||||||
This method is deprecated.
use
toMap() instead, or consider using ImmutableMap if
if the map does not need to accept null s.
| |||||||||||
Returns a mutable
LinkedHashMap where the entries are in the same order as they were added. | |||||||||||
Returns an immutable
Map where the entries are in the same order as they were added. | |||||||||||
Returns an immutable
Map where the entries are in no defined order. | |||||||||||
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
|
Add a key/value. Allows null
s. Prefer builder()
if
that is not needed.
key | the key |
---|---|
value | the value |
Add all the entries contained in the map. Accepts a null map and does nothing.
map | the map to add |
---|
Add a key/value only if the value is not null
. If the intent is to
produce an immutable map that does not contain null
values, then
ImmutableMap
should be preferred. This method should only be useful
when intending to call toMutableMap()
.
key | the key |
---|---|
value | the value |
Returns an immutable Map containing the given key-value pairs.
Prefer of(Object, Object, Object, Object, Object, Object, Object, Object)
if none of the keys or values will ever need to be null
.
key1 | The Key |
---|---|
value1 | The Value |
key2 | The Key |
value2 | The Value |
key3 | The Key |
value3 | The Value |
key4 | The Key |
value4 | The Value |
Returns an immutable Map containing the given key-value pairs.
Prefer of(Object, Object, Object, Object, Object, Object)
if none of
the keys or values will ever need to be null
.
key1 | The Key |
---|---|
value1 | The Value |
key2 | The Key |
value2 | The Value |
key3 | The Key |
value3 | The Value |
Returns an immutable Map containing the given key-value pairs.
Prefer of(Object, Object, Object, Object)
if none of
the keys or values will ever need to be null
.
key1 | The Key |
---|---|
value1 | The Value |
key2 | The Key |
value2 | The Value |
Returns an immutable Map containing the given key-value pair.
Prefer of(Object, Object)
if neither key
nor
value
will ever need to be null
.
key | The Key |
---|---|
value | The Value |
Static factory method for creating an empty map. This is exactly equivalent to
Collections.emptyMap()
and is provided only for completeness.
Static factory method for creating a fresh MapBuilder
based on the contents of a source Map.
map | the source map, may be null |
---|
MapBuilder
, populated with the values from map
, if one is provided
Static factory method for creating a fresh MapBuilder
.
MapBuilder
Static factory method for creating a fresh MapBuilder
and adding the given key/value pairs.
key1 | the key |
---|---|
value1 | the value |
key2 | the key |
value2 | the value |
MapBuilder
with the specified elements
Static factory method for creating a fresh MapBuilder
and adding the given key/value pair.
key | the key |
---|---|
value | the value |
MapBuilder
Static factory method for creating a fresh MapBuilder
and adding the given key/value pairs.
key1 | the key |
---|---|
value1 | the value |
key2 | the key |
value2 | the value |
key3 | the key |
value3 | the value |
MapBuilder
with the specified elements
Static factory method for creating a fresh MapBuilder
and adding the given key/value pairs.
key1 | the key |
---|---|
value1 | the value |
key2 | the key |
value2 | the value |
key3 | the key |
value3 | the value |
key4 | the key |
value4 | the value |
MapBuilder
with the specified elements
Static factory method for creating an immutable Map
with a single entry. This is
exactly equivalent to Collections.singletonMap(key, value)
and is only provided
for completeness.
key | the key |
---|---|
value | the value |
MapBuilder
This method is deprecated.
Use ImmutableMap directly instead. Since v6.1.
This returns a guava ImmutableMap
, which does not accept null
s.
Please use that class directly, instead.
NullPointerException | if there are any null s in this builder. |
---|
This method is deprecated.
Use ImmutableSortedMap directly instead. Since v6.1.
This returns a guava ImmutableSortedMap
, which does not accept null
s.
Please use that class directly, instead.
NullPointerException | if there are any null s in this builder. |
---|---|
ClassCastException | if the keys in this builder do not implement Comparable . |
This method is deprecated.
Use ImmutableSortedMap directly instead. Since v6.1.
This returns a guava ImmutableSortedMap
, which does not accept null
s.
Please use that class directly, instead.
comparator | for sorting the map |
---|
NullPointerException | if there are any null s in this builder. |
---|---|
ClassCastException | if the keys in this builder do not implement Comparable . |
This method is deprecated.
use toMap()
instead, or consider using ImmutableMap if
if the map does not need to accept null
s.
Returns an immutable map backed by a HashMap, which will accept null
s. If that
ability is not needed, then ImmutableMap is preferred.
Returns a mutable LinkedHashMap
where the entries are in the same order as they were added.
LinkedHashMap
where the entries are in the same order as they were added.
SortedMap
where the entries are in the natural order of the keys.
Note that the key type must implement Comparable
.
comparator | used to sort the keys. |
---|
SortedMap
where the entries are in the order defined by the
supplied Comparator
.
comparator | used to sort the keys. |
---|
TreeMap
where the entries are in the order defined by the
supplied Comparator
.
TreeMap
where the entries are in the natural order of the keys.
Note that the key type must implement Comparable
.