K
- The key type.V
- The value type.public final class AMap<K,V> extends LinkedHashMap<K,V>
LinkedHashMap
.
Provides various convenience methods for creating and populating a map with minimal code.
AbstractMap.SimpleEntry<K,V>, AbstractMap.SimpleImmutableEntry<K,V>
Constructor and Description |
---|
AMap()
Constructor.
|
AMap(Map<K,V> copy)
Copy constructor.
|
Modifier and Type | Method and Description |
---|---|
AMap<K,V> |
a(K k,
V v)
Add.
|
AMap<K,V> |
aa(Map<K,V> c)
Add all.
|
String |
asString()
Convert to Simplified JSON.
|
String |
asString(WriterSerializer ws)
Convert to a string using the specified serializer.
|
static <K,V> AMap<K,V> |
nullable(Map<K,V> c)
Creates a copy of the collection if it's not
|
static <K,V> AMap<K,V> |
of()
Creates an empty map.
|
static <K,V> AMap<K,V> |
of(K key,
V value)
Creates a map with one entry.
|
static <K,V> AMap<K,V> |
of(K k1,
V v1,
K k2,
V v2) |
static <K,V> AMap<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3) |
static <K,V> AMap<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4) |
static <K,V> AMap<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5) |
static <K,V> AMap<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5,
K k6,
V v6) |
static <K,V> AMap<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5,
K k6,
V v6,
K k7,
V v7) |
static <K,V> AMap<K,V> |
of(K k1,
V v1,
K k2,
V v2,
K k3,
V v3,
K k4,
V v4,
K k5,
V v5,
K k6,
V v6,
K k7,
V v7,
K k8,
V v8) |
static <K,V> AMap<K,V> |
of(Map<K,V> copy)
Creates a new map initialized with the specified contents.
|
static <K,V> AMap<K,V> |
ofPairs(Object... parameters)
Creates a map out of a list of key/value pairs.
|
String |
toString()
Convert to Simplified JSON.
|
Map<K,V> |
unmodifiable()
Returns an unmodifiable view of this map.
|
static <K,V> Map<K,V> |
unmodifiable(Map<K,V> copy)
Creates an unmodifiable copy of the specified map.
|
clear, containsValue, entrySet, forEach, get, getOrDefault, keySet, removeEldestEntry, replaceAll, values
clone, compute, computeIfAbsent, computeIfPresent, containsKey, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
equals, hashCode
finalize, getClass, notify, notifyAll, wait, wait, wait
compute, computeIfAbsent, computeIfPresent, containsKey, equals, hashCode, isEmpty, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, size
public AMap()
public static <K,V> AMap<K,V> of(K key, V value)
key
- Entry key.value
- Entry value.public static <K,V> AMap<K,V> ofPairs(Object... parameters)
K
- The key type.V
- The value type.parameters
- The parameters.
public static <K,V> AMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6)
public static <K,V> AMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7)
public static <K,V> AMap<K,V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5, K k6, V v6, K k7, V v7, K k8, V v8)
public static <K,V> AMap<K,V> of(Map<K,V> copy)
copy
- Initialize with these contents. Can be public static <K,V> Map<K,V> unmodifiable(Map<K,V> copy)
copy
- The map to copy.public static <K,V> AMap<K,V> nullable(Map<K,V> c)
c
- The initial values.public AMap<K,V> a(K k, V v)
Adds an entry to this map.
k
- The key.v
- The value.public AMap<K,V> aa(Map<K,V> c)
Appends all the entries in the specified map to this map.
c
- The map to copy.public Map<K,V> unmodifiable()
public String asString(WriterSerializer ws)
ws
- The serializer to use to serialize this collection.public String asString()
Copyright © 2016–2020 The Apache Software Foundation. All rights reserved.