|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.atlassian.jira.util.collect.MapBuilder<K,V>
K - the key typeV - the value typepublic class MapBuilder<K,V>
Utility for easily creating Maps of all standard types.
| Method Summary | ||
|---|---|---|
MapBuilder<K,V> |
add(K key,
V value)
Add a key/value. |
|
MapBuilder<K,V> |
addAll(Map<? extends K,? extends V> map)
Add all the entries contained in the map. |
|
MapBuilder<K,V> |
addIfValueNotNull(K key,
V value)
Add a key/value only if the value is not null. |
|
static
|
build(K key,
V value)
Returns an immutable Map containing the given key-value pair. |
|
static
|
build(K key1,
V value1,
K key2,
V value2)
Returns an immutable Map containing the given key-value pairs. |
|
static
|
build(K key1,
V value1,
K key2,
V value2,
K key3,
V value3)
Returns an immutable Map containing the given key-value pairs. |
|
static
|
build(K key1,
V value1,
K key2,
V value2,
K key3,
V value3,
K key4,
V value4)
Returns an immutable Map containing the given key-value pairs. |
|
static
|
emptyMap()
Static factory method for creating an empty map. |
|
static
|
newBuilder()
Static factory method for creating a fresh MapBuilder. |
|
static
|
newBuilder(K key,
V value)
Static factory method for creating a fresh MapBuilder and adding the given key/value pair. |
|
static
|
newBuilder(K key1,
V value1,
K key2,
V value2)
Static factory method for creating a fresh MapBuilder and adding the given key/value pairs. |
|
static
|
newBuilder(K key1,
V value1,
K key2,
V value2,
K key3,
V value3)
Static factory method for creating a fresh MapBuilder and adding the given key/value pairs. |
|
static
|
newBuilder(K key1,
V value1,
K key2,
V value2,
K key3,
V value3,
K key4,
V value4)
Static factory method for creating a fresh MapBuilder and adding the given key/value pairs. |
|
static
|
newBuilder(Map<? extends K,? extends V> map)
Static factory method for creating a fresh MapBuilder based on the contents of a source Map. |
|
static
|
singletonMap(K key,
V value)
Static factory method for creating an immutable Map with a single entry. |
|
Map<K,V> |
toFastMap()
If speed is of the essence, this will return the fastest thread-safe immutable map known. |
|
SortedMap<K,V> |
toFastSortedMap()
If speed is of the essence, this will return the fastest thread-safe immutable sorted map known. |
|
SortedMap<K,V> |
toFastSortedMap(Comparator<K> comparator)
If speed is of the essence, this will return the fastest thread-safe immutable sorted map known. |
|
HashMap<K,V> |
toHashMap()
|
|
Map<K,V> |
toImmutableMap()
Deprecated. use toMap() instead. |
|
LinkedHashMap<K,V> |
toLinkedHashMap()
|
|
Map<K,V> |
toListOrderedMap()
|
|
Map<K,V> |
toMap()
|
|
Map<K,V> |
toMutableMap()
|
|
SortedMap<K,V> |
toSortedMap()
|
|
SortedMap<K,V> |
toSortedMap(Comparator<K> comparator)
|
|
TreeMap<K,V> |
toTreeMap()
|
|
TreeMap<K,V> |
toTreeMap(Comparator<K> comparator)
|
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <K,V> Map<K,V> emptyMap()
K - the key typeV - the value type
public static <K,V> MapBuilder<K,V> newBuilder()
MapBuilder.
K - the key typeV - the value type
MapBuilder
public static <K,V> MapBuilder<K,V> newBuilder(K key,
V value)
MapBuilder and adding the given key/value pair.
K - the key typeV - the value typekey - the keyvalue - the value
MapBuilder
public static <K,V> MapBuilder<K,V> newBuilder(K key1,
V value1,
K key2,
V value2)
MapBuilder and adding the given key/value pairs.
K - the key typeV - the value typekey1 - the keyvalue1 - the valuekey2 - the keyvalue2 - the value
MapBuilder with the specified elements
public static <K,V> MapBuilder<K,V> newBuilder(K key1,
V value1,
K key2,
V value2,
K key3,
V value3)
MapBuilder and adding the given key/value pairs.
K - the key typeV - the value typekey1 - the keyvalue1 - the valuekey2 - the keyvalue2 - the valuekey3 - the keyvalue3 - the value
MapBuilder with the specified elements
public static <K,V> MapBuilder<K,V> newBuilder(K key1,
V value1,
K key2,
V value2,
K key3,
V value3,
K key4,
V value4)
MapBuilder and adding the given key/value pairs.
K - the key typeV - the value typekey1 - the keyvalue1 - the valuekey2 - the keyvalue2 - the valuekey3 - the keyvalue3 - the valuekey4 - the keyvalue4 - the value
MapBuilder with the specified elements
public static <K,V> MapBuilder<K,V> newBuilder(@Nullable
Map<? extends K,? extends V> map)
MapBuilder based on the contents of a source Map.
K - the key typeV - the value typemap - the source map, may be null
MapBuilder
public static <K,V> Map<K,V> singletonMap(K key,
V value)
Map with a single entry.
K - the key typeV - the value typekey - the keyvalue - the value
MapBuilder
public static <K,V> Map<K,V> build(K key,
V value)
K - the key typeV - the value typekey - The Keyvalue - The Value
public static <K,V> Map<K,V> build(K key1,
V value1,
K key2,
V value2)
K - the key typeV - the value typekey1 - The Keyvalue1 - The Valuekey2 - The Keyvalue2 - The Value
public static <K,V> Map<K,V> build(K key1,
@Nullable
V value1,
K key2,
@Nullable
V value2,
K key3,
@Nullable
V value3)
K - the key typeV - the value typekey1 - The Keyvalue1 - The Valuekey2 - The Keyvalue2 - The Valuekey3 - The Keyvalue3 - The Value
public static <K,V> Map<K,V> build(K key1,
V value1,
K key2,
V value2,
K key3,
V value3,
K key4,
V value4)
K - the key typeV - the value typekey1 - The Keyvalue1 - The Valuekey2 - The Keyvalue2 - The Valuekey3 - The Keyvalue3 - The Valuekey4 - The Keyvalue4 - The Value
public MapBuilder<K,V> add(@Nullable
K key,
@Nullable
V value)
Map implementations do not allow null
keys or values.
key - the keyvalue - the value
public MapBuilder<K,V> addIfValueNotNull(K key,
@Nullable
V value)
Map
implementations do not allow null keys.
key - the keyvalue - the value
public MapBuilder<K,V> addAll(@Nullable
Map<? extends K,? extends V> map)
map - the map to add
public Map<K,V> toMap()
Map where the entries are in no defined order.public HashMap<K,V> toHashMap()
HashMap where the entries are in no defined order.public LinkedHashMap<K,V> toLinkedHashMap()
LinkedHashMap where the entries are in the same order as they were added.public Map<K,V> toListOrderedMap()
Map where the entries are in the same order as they were added.public SortedMap<K,V> toSortedMap()
SortedMap where the entries are in the natural order of the keys.
Note that the key type must implement Comparable.public SortedMap<K,V> toSortedMap(Comparator<K> comparator)
comparator - used to sort the keys.
SortedMap where the entries are in the order defined by the
supplied Comparator.public TreeMap<K,V> toTreeMap()
TreeMap where the entries are in the natural order of the keys.
Note that the key type must implement Comparable.public TreeMap<K,V> toTreeMap(Comparator<K> comparator)
comparator - used to sort the keys.
TreeMap where the entries are in the order defined by the
supplied Comparator.public Map<K,V> toMutableMap()
Map where the entries are in no defined order.public Map<K,V> toFastMap()
NullPointerException - if there are any nulls in this builder.public SortedMap<K,V> toFastSortedMap()
NullPointerException - if there are any nulls in this builder.
ClassCastException - if the keys in this builder do not implement Comparable.public SortedMap<K,V> toFastSortedMap(Comparator<K> comparator)
comparator - for sorting the map
NullPointerException - if there are any nulls in this builder.@Deprecated public Map<K,V> toImmutableMap()
toMap() instead.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||