Package com.sap.cds.util
Class DataUtils
java.lang.Object
com.sap.cds.util.DataUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic void
addCounts
(List<? extends Map<String, Object>> rows, List<? extends Map<String, Object>> counts, String expRefName, Map<String, String> mapping) static boolean
containsKey
(Map<String, Object> data, String path) Returns true if the specified key is present in the map.static boolean
containsKey
(Map<String, Object> data, String path, boolean propagateNull) Returns true if the specified key is present in the map.copyGenericList
(List original) static String
static DataUtils
create
(Supplier<SessionContext> session, int timestampPrecision) static void
createPath
(Map<String, Object> map, String path, boolean notNull) dateTimeValues
(List<Instant> instants) deepMapKeys
(Map<String, ?> map) static boolean
generateUuidKeys
(CdsStructuredType struct, Map<String, Object> data) static <T> T
getOrDefault
(Map<String, Object> data, String path, T defaultValue) Returns the value to which the specified key is mapped.static <T> T
static <T> T
getPathOrDefault
(Map<String, Object> data, String path, T defaultValue) Returns the value to which the specified path is mapped.static <T> T
getPathOrDefault
(T defaultValue, Map<String, Object> d, String[] segment) static boolean
hasDefaultValue
(CdsElement element, CdsType type) static boolean
hasManagedUuidValue
(CdsElement element) static boolean
hasNonKeyValues
(CdsStructuredType type, Map<String, Object> data) static boolean
isDeep
(CdsStructuredType type, Collection<Map<String, Object>> entries) static boolean
isFkUpdate
(CdsElement assoc, Map<String, Object> data, SessionContext session) Extracts the key values for the given entity from the data map.static void
merge
(List<? extends Map<String, Object>> source, List<? extends Map<String, Object>> target, String expRefName, Map<String, String> mapping, String fkPrefix, boolean addCount) static void
normalizedUuidKeys
(CdsStructuredType type, Iterable<? extends Map<String, Object>> entries) void
prepareForInsert
(CdsStructuredType struct, List<? extends Map<String, Object>> entries) void
prepareForUpdate
(CdsStructuredType struct, List<? extends Map<String, Object>> entries) void
processOnInsert
(CdsStructuredType struct, Iterable<? extends Map<String, Object>> data) void
processOnUpdate
(CdsStructuredType struct, Iterable<? extends Map<String, Object>> data, boolean deep) static Object
static Object
void
removeOpenTypeElements
(CdsStructuredType struct, Iterable<? extends Map<String, Object>> data) static <T> T
removePath
(Map<String, Object> data, String path, boolean removeEmptyMaps) void
removeVirtualElements
(CdsStructuredType struct, List<? extends Map<String, Object>> data) static void
static void
timestampValues
(List<Instant> instants, int precision) static boolean
uniformData
(CdsStructuredType type, Collection<Map<String, Object>> entries)
-
Method Details
-
create
-
isDeep
-
hasNonKeyValues
-
uniformData
-
prepareForInsert
-
prepareForUpdate
-
processOnInsert
-
processOnUpdate
public void processOnUpdate(CdsStructuredType struct, Iterable<? extends Map<String, Object>> data, boolean deep) -
resolvePaths
-
hasDefaultValue
-
defaultValue
-
resolvePathAndAdd
-
putPath
-
putPath
-
createPath
-
dateTimeValues
-
timestampValues
-
generateUuidKeys
-
hasManagedUuidValue
-
normalizedUuidKeys
public static void normalizedUuidKeys(CdsStructuredType type, Iterable<? extends Map<String, Object>> entries) -
copyMap
-
copyGenericList
-
removeVirtualElements
public void removeVirtualElements(CdsStructuredType struct, List<? extends Map<String, Object>> data) -
removeOpenTypeElements
public void removeOpenTypeElements(CdsStructuredType struct, Iterable<? extends Map<String, Object>> data) -
merge
-
addCounts
-
countName
-
deepMapKeys
-
keyValues
Extracts the key values for the given entity from the data map. If data does not contain a value for a key, it is mapped to null. For association keys, fk values can be extracted from nested maps in data.- Parameters:
entity
- the entitydata
- the data map- Returns:
- the key values of the entity
-
getOrDefault
Returns the value to which the specified key is mapped. The key can be a path separated by '.' to extract values from nested maps. If no value is found, defaultValue is returned.- Type Parameters:
T
- the type to which the value is casted- Parameters:
data
- the data mappath
- the path or key whose associated value is to be returneddefaultValue
- the default mapping of the key- Returns:
- the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key
-
getPathOrDefault
Returns the value to which the specified path is mapped. If no value is found, defaultValue is returned.- Type Parameters:
T
- the type to which the value is casted- Parameters:
data
- the data mappath
- the path with dot separator whose associated value is to be returneddefaultValue
- the default mapping of the key- Returns:
- the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key
-
getPathOrDefault
-
getPath
-
removePath
-
containsKey
Returns true if the specified key is present in the map. The key can be a path separated by '.' to check keys in nested maps.- Parameters:
data
- the data mappath
- the path or key to be checked- Returns:
- true if the specified key is present
-
containsKey
Returns true if the specified key is present in the map. The key can be a path separated by '.' to check keys in nested maps.- Parameters:
data
- the data mappath
- the path or key to be checkedpropagateNull
- true, if explicit null values should be considered propagating, meaning all values from that key-level on are considered explicitly set to null- Returns:
- true if the specified key is present
-
isFkUpdate
-