Class MapUtils
java.lang.Object
io.github.vitalforge.persistlib.util.MapUtils
Utility class for operations on Maps.
-
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable Object
getDeepValue
(Map<String, Object> map, String path) Retrieves a value from a nested map using a string path.static <K> @Nullable Object
getDeepValue
(Map<K, Object> map, K[] path) Retrieves a value from a nested map using an array of keys.static void
Inserts a value into a map at a specified string path, creating nested maps as necessary.static <K> void
putDeepValue
(Map<K, Object> map, Object value, K[] path) Inserts a value into a map at a specified path, creating nested maps as necessary.
-
Method Details
-
getDeepValue
Retrieves a value from a nested map using a string path.- Parameters:
map
- The map from which to retrieve the value.path
- The path to the value in the map.- Returns:
- The value at the specified path, or null if the path does not exist.
-
getDeepValue
Retrieves a value from a nested map using an array of keys.- Type Parameters:
K
- The type of the keys in the map.- Parameters:
map
- The map from which to retrieve the value.path
- The path to the value in the map.- Returns:
- The value at the specified path, or null if the path does not exist.
-
putDeepValue
Inserts a value into a map at a specified string path, creating nested maps as necessary.- Parameters:
map
- The map into which to insert the value.value
- The value to insert.path
- The path at which to insert the value.
-
putDeepValue
Inserts a value into a map at a specified path, creating nested maps as necessary.- Type Parameters:
K
- The type of the keys in the map.- Parameters:
map
- The map into which to insert the value.value
- The value to insert.path
- The path at which to insert the value.
-