public interface CdsData extends Map<String,Object>, JSONizable
Map<String, Object>
.
To simplify access to nested data representing deep structures, path access
is supported via containsPath(java.lang.String)
, putPath(java.lang.String, T)
, getPath(java.lang.String)
and removePath(java.lang.String)
. CdsData can conveniently be serialized to JSON using
JSONizable.toJson()
.Modifier and Type | Method and Description |
---|---|
boolean |
containsPath(String path)
Returns true if this map contains a mapping for the specified path.
|
static CdsData |
create()
Creates an empty CdsData instance.
|
static CdsData |
create(Map<String,?> other)
Creates a new CdsData instance from the given data.
|
Object |
get(Object key)
Returns the value to which the specified key is mapped.
|
<T> T |
getPath(String path)
Returns the value to which the specified path (see
containsPath(java.lang.String) ) is
mapped. |
<T> T |
getPathOrDefault(String path,
T defaultValue)
Returns the value to which the specified path (see
containsPath(java.lang.String) ) is
mapped, or defaultValue if this map contains no mapping for the path. |
<T> T |
putPath(String path,
T value)
Associates the specified value with the specified path in this map.
|
<T> T |
putPathIfAbsent(String path,
T value)
If the specified path (see
containsPath(java.lang.String) ) is not already associated
with a value (or is mapped to null) associates it with the given value and
returns null, else returns the current value. |
<T> T |
removePath(String path)
Removes the mapping for a path (see
containsPath(java.lang.String) ) from this map if
it is present (optional operation). |
clear, compute, computeIfAbsent, computeIfPresent, containsKey, containsValue, entrySet, equals, forEach, getOrDefault, hashCode, isEmpty, keySet, merge, put, putAll, putIfAbsent, remove, remove, replace, replace, replaceAll, size, values
toJson
static CdsData create()
static CdsData create(Map<String,?> other)
other
- the data mapObject get(Object key)
Map.get(Object)
.
Path access to nested maps is deprecated, instead use
getPath(String)
.<T> T getPath(String path)
containsPath(java.lang.String)
) is
mapped. If no value is found, null is returned. Dots in the path are
interpreted as separators, use get(java.lang.Object)
to access values with keys that
contain dots.T
- the type of the associated valuepath
- the path whose associated value is to be returned<T> T getPathOrDefault(String path, T defaultValue)
containsPath(java.lang.String)
) is
mapped, or defaultValue if this map contains no mapping for the path. Dots in
the path are interpreted as separators, use Map.getOrDefault(java.lang.Object, V)
to
access values with keys that contain dots.T
- the type of the associated valuepath
- the path whose associated value is to be returneddefaultValue
- the default mapping for the path<T> T putPath(String path, T value)
containsPath(java.lang.String)
is
true), the old value is replaced by the specified value. Creates nested maps
along the path, if a path segment (except for the last segment) is not
mapped.T
- the type of the associated valuepath
- the path with which the specified value is to be associatedvalue
- the value to be associated with the specified path<T> T putPathIfAbsent(String path, T value)
containsPath(java.lang.String)
) is not already associated
with a value (or is mapped to null) associates it with the given value and
returns null, else returns the current value. Creates nested maps along the
path, if a path segment (except for the last segment) is not mapped.T
- the type of the associated valuepath
- the path with which the specified value is to be associatedvalue
- the value to be associated with the specified pathboolean containsPath(String path)
path
- the path to a nested map's key whose presence is to be tested<T> T removePath(String path)
containsPath(java.lang.String)
) from this map if
it is present (optional operation). Returns the value previously associated
with the path, or null if the map contained no mapping for the path.
The map will not contain a mapping for the specified path once the call
returns.path
- the path whose mapping is to be removed from the mapCopyright © 2022 SAP. All rights reserved.