M - the type extending this interfacepublic interface StringObjectMap<M extends StringObjectMap<M>> extends Map<String,Object>
StringObjectMap does not allow null keys. It allows null values.
Implementing classes can bei either mutable or immutable. In case a subclass is immutable, its methods may throw
UnsupportedOperationException when calling modifying methods. *
| Modifier and Type | Method and Description |
|---|---|
default M |
append(String key,
Object value)
|
M |
fromJson(String json)
initializes this object from the given JSON String.
|
default <T> T |
get(Object key,
Class<T> type)
Returns the value to which the specified
key is mapped, or null if this document contains no
mapping for the key. |
default Boolean |
getBoolean(String key)
Returns the value to which the specified
key is mapped, or null if this document contains no
mapping for the key. |
default boolean |
getBooleanOrDefault(String key,
boolean defaultValue)
Returns the value to which the specified
key is mapped or defaultValue if this document contains no
mapping for the key. |
default boolean |
getBooleanOrDefault(String key,
BooleanSupplier defaultValue)
Returns the value to which the specified
key is mapped or the value from defaultValue if this
document contains no mapping for the key. |
default Integer |
getInt(String key)
Returns the value to which the specified
key is mapped, or null if this document contains no
mapping for the key. |
default int |
getIntOrDefault(String key,
int defaultValue)
Returns the value to which the specified
key is mapped or defaultValue if this document contains no
mapping for the key. |
default int |
getIntOrDefault(String key,
IntSupplier defaultValue)
Returns the value to which the specified
key is mapped or the value from defaultValue if this
document contains no mapping for the key. |
default Long |
getLong(String key)
Returns the value to which the specified
key is mapped, or null if this document contains no
mapping for the key. |
default long |
getLongOrDefault(String key,
long defaultValue)
Returns the value to which the specified
key is mapped or defaultValue if this document contains no
mapping for the key. |
default long |
getLongOrDefault(String key,
LongSupplier defaultValue)
Returns the value to which the specified
key is mapped or the value from defaultValue if this
document contains no mapping for the key. |
default String |
getString(String key)
Returns the value to which the specified
key is mapped, or null if this document contains no
mapping for the key. |
default String |
getStringOrDefault(String key,
String defaultValue)
Returns the value to which the specified
key is mapped or defaultValue if this document contains no
mapping for the key. |
default String |
getStringOrDefault(String key,
Supplier<String> defaultValue)
Returns the value to which the specified
key is mapped or the value from defaultValue if this
document contains no mapping for the key. |
String |
toJson()
Render this
Document to JSON. |
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, get, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, valuesdefault M append(String key, Object value)
key - key with which the specified value is to be associated. must not be null.value - value to be associated with the specified key.this object.@Nullable default <T> T get(Object key, Class<T> type)
key is mapped, or null if this document contains no
mapping for the key. The value is casted within the method which makes it useful for calling code as it does not
require casting on the calling side. If the value type is not assignable to type, then this method throws
ClassCastException.T - expected return type.key - the key whose associated value is to be returnedtype - the expected return value type.ClassCastException - if the value of the given key is not of type T.@Nullable default Boolean getBoolean(String key)
key is mapped, or null if this document contains no
mapping for the key. If the value type is not a Boolean, then this method throws
ClassCastException.key - the key whose associated value is to be returnedClassCastException - if the value of the given key is not a Boolean.default boolean getBooleanOrDefault(String key, boolean defaultValue)
key is mapped or defaultValue if this document contains no
mapping for the key. If the value type is not a Boolean, then this method throws
ClassCastException.key - the key whose associated value is to be returneddefaultValue if this document contains no mapping
for the key.ClassCastException - if the value of the given key is not a Boolean.default boolean getBooleanOrDefault(String key, BooleanSupplier defaultValue)
key is mapped or the value from defaultValue if this
document contains no mapping for the key. If the value type is not a Boolean, then this method throws
ClassCastException.key - the key whose associated value is to be returneddefaultValue if this document
contains no mapping for the key.ClassCastException - if the value of the given key is not a Boolean.BooleanSupplier@Nullable default Integer getInt(String key)
key is mapped, or null if this document contains no
mapping for the key. If the value type is not a Integer, then this method throws
ClassCastException.key - the key whose associated value is to be returnedClassCastException - if the value of the given key is not a Integer.default int getIntOrDefault(String key, int defaultValue)
key is mapped or defaultValue if this document contains no
mapping for the key. If the value type is not a Integer, then this method throws
ClassCastException.key - the key whose associated value is to be returneddefaultValue if this document contains no mapping
for the key.ClassCastException - if the value of the given key is not a Integer.default int getIntOrDefault(String key, IntSupplier defaultValue)
key is mapped or the value from defaultValue if this
document contains no mapping for the key. If the value type is not a Integer, then this method throws
ClassCastException.key - the key whose associated value is to be returneddefaultValue if this document
contains no mapping for the key.ClassCastException - if the value of the given key is not a Integer.IntSupplier@Nullable default Long getLong(String key)
key is mapped, or null if this document contains no
mapping for the key. If the value type is not a Long, then this method throws ClassCastException.key - the key whose associated value is to be returnedClassCastException - if the value of the given key is not a Long.default long getLongOrDefault(String key, long defaultValue)
key is mapped or defaultValue if this document contains no
mapping for the key. If the value type is not a Long, then this method throws ClassCastException.key - the key whose associated value is to be returneddefaultValue if this document contains no mapping
for the key.ClassCastException - if the value of the given key is not a Long.default long getLongOrDefault(String key, LongSupplier defaultValue)
key is mapped or the value from defaultValue if this
document contains no mapping for the key. If the value type is not a Long, then this method throws
ClassCastException.key - the key whose associated value is to be returneddefaultValue if this document
contains no mapping for the key.ClassCastException - if the value of the given key is not a Long.LongSupplier@Nullable default String getString(String key)
key is mapped, or null if this document contains no
mapping for the key. If the value type is not a String, then this method throws ClassCastException.key - the key whose associated value is to be returnedClassCastException - if the value of the given key is not a String.default String getStringOrDefault(String key, String defaultValue)
key is mapped or defaultValue if this document contains no
mapping for the key. If the value type is not a String, then this method throws ClassCastException.key - the key whose associated value is to be returneddefaultValue if this document contains no mapping
for the key.ClassCastException - if the value of the given key is not a String.default String getStringOrDefault(String key, Supplier<String> defaultValue)
key is mapped or the value from defaultValue if this
document contains no mapping for the key. If the value type is not a String, then this method throws
ClassCastException.key - the key whose associated value is to be returneddefaultValue if this document
contains no mapping for the key.ClassCastException - if the value of the given key is not a String.SupplierString toJson()
Document to JSON. Auxiliary values such as Id and version are not considered within the JSON
representation.Copyright © 2011–2021 Pivotal Software, Inc.. All rights reserved.