public class PaymentsMap
extends java.util.LinkedHashMap<java.lang.String,java.lang.Object>
put("a[3].k1", 1)
is permitted while put("a[3]", 1)
results
in an IllegalArgumentException
.
Examples:
PaymentsMap map = new PaymentsMap(); map.put("card.number", "5555555555554444"); map.put("card.cvc", "123"); map.put("card.expMonth", 5); map.put("card.expYear", 15); map.put("currency", "USD"); map.put("amount", 1234);There is also an set() method which is similar to put() but returns the map providing a fluent map builder.
PaymentsMap map = new PaymentsMap() .set("card.number", "5555555555554444") .set("card.cvc", "123") .set("card.expMonth", 5) .set("card.expYear", 15) .set("currency", "USD") .set("amount", 1234);Both of these examples construct a PaymentsMap containing the keys 'currency', 'amount' and 'card'. The value for the 'card' key is a map containing the key 'number', 'cvc', 'expMonth' and 'expYear'.
Constructor and Description |
---|
PaymentsMap()
Constructs an empty map with the default capacity and load factor.
|
PaymentsMap(int initialCapacity)
Constructs an empty map with the specified capacity and default load factor.
|
PaymentsMap(int initialCapacity,
float loadFactor)
Constructs an empty map with the specified capacity and load factor.
|
PaymentsMap(java.util.Map<java.lang.String,java.lang.Object> map)
Constructs a map with the same mappings as in the specifed map.
|
PaymentsMap(java.lang.String jsonMapString)
Consturcts a map based of the speficied JSON string.
|
PaymentsMap(java.lang.String keyPath,
java.lang.Object value)
Constructs a map with an initial mapping of keyPath to value.
|
Modifier and Type | Method and Description |
---|---|
boolean |
containsKey(java.lang.Object keyPath)
Returns true if there is a value associated with the specified key path.
|
java.lang.Object |
get(java.lang.Object keyPath)
Returns the value associated with the specified key path or null if there is no associated value.
|
static java.util.Map<java.lang.String,java.lang.Object> |
normalize(java.util.Map<java.lang.String,java.lang.Object> m)
Returns an identical copy of the map except values which JSONValue.toJSONString() would render as
unquoted strings are converted to string values.
|
java.lang.Object |
put(java.lang.String keyPath,
java.lang.Object value)
Associates the specified value to the specified key path.
|
java.lang.Object |
remove(java.lang.Object keyPath)
Removes the value associated with the specified key path from the map.
|
PaymentsMap |
set(java.lang.String keyPath,
java.lang.Object value)
Associates the specified value to the specified key path and returns a reference to
this map.
|
clear, containsValue, entrySet, forEach, getOrDefault, keySet, removeEldestEntry, replaceAll, values
clone, compute, computeIfAbsent, computeIfPresent, isEmpty, merge, putAll, putIfAbsent, remove, replace, replace, size
public PaymentsMap(int initialCapacity, float loadFactor)
initialCapacity
- the initial capacityloadFactor
- the load factorpublic PaymentsMap(int initialCapacity)
initialCapacity
- the initial capacitypublic PaymentsMap()
public PaymentsMap(java.util.Map<java.lang.String,java.lang.Object> map)
map
- the map whose mappings are to be placed in this mappublic PaymentsMap(java.lang.String jsonMapString)
jsonMapString
- the JSON string used to construct the mappublic PaymentsMap(java.lang.String keyPath, java.lang.Object value)
keyPath
- key path with which the specified value is to be associated.value
- value to be associated with the specified key path.public java.lang.Object put(java.lang.String keyPath, java.lang.Object value)
put
in interface java.util.Map<java.lang.String,java.lang.Object>
put
in class java.util.HashMap<java.lang.String,java.lang.Object>
keyPath
- key path to which the specified value is to be associated.value
- the value which is to be associated with the specified key path.java.lang.IllegalArgumentException
- if part of the key path does not match the expected type.java.lang.IndexOutOfBoundsException
- if using an array index in the key path is out of bounds.public PaymentsMap set(java.lang.String keyPath, java.lang.Object value)
keyPath
- key path to which the specified value is to be associated.value
- the value which is to be associated with the specified key path.java.lang.IllegalArgumentException
- if part of the key path does not match the expected type.java.lang.IndexOutOfBoundsException
- if using an array index in the key path is out of bounds.public java.lang.Object get(java.lang.Object keyPath)
get
in interface java.util.Map<java.lang.String,java.lang.Object>
get
in class java.util.LinkedHashMap<java.lang.String,java.lang.Object>
keyPath
- key path whose associated value is to be returnedjava.lang.IllegalArgumentException
- if part of the key path does not match the expected type.java.lang.IndexOutOfBoundsException
- if using an array index in the key path is out of bounds.public boolean containsKey(java.lang.Object keyPath)
containsKey
in interface java.util.Map<java.lang.String,java.lang.Object>
containsKey
in class java.util.HashMap<java.lang.String,java.lang.Object>
keyPath
- key path whose associated value is to be testedjava.lang.IllegalArgumentException
- if part of the key path does not match the expected type.java.lang.IndexOutOfBoundsException
- if using an array index in the key path is out of bounds.public java.lang.Object remove(java.lang.Object keyPath)
remove
in interface java.util.Map<java.lang.String,java.lang.Object>
remove
in class java.util.HashMap<java.lang.String,java.lang.Object>
keyPath
- key path whose associated value is to be removedjava.lang.IllegalArgumentException
- if part of the key path does not match the expected type.java.lang.IndexOutOfBoundsException
- if using an array index in the key path is out of bounds.public static java.util.Map<java.lang.String,java.lang.Object> normalize(java.util.Map<java.lang.String,java.lang.Object> m)