Package org.apache.gravitino.utils
Class MapUtils
java.lang.Object
org.apache.gravitino.utils.MapUtils
Utility class for working with maps.
-
Method Summary
Modifier and TypeMethodDescriptiongetFilteredMap
(Map<String, String> m, Predicate predicate) Returns a map with all keys that match the predicate.getMapWithoutPrefix
(Map<String, String> m, String prefix) Returns a new map containing entries whose keys do NOT start with the given prefix.getPrefixMap
(Map<String, String> m, String prefix) Returns a map with all keys that start with the given prefix.getPrefixMap
(Map<String, String> m, String prefix, boolean keepPrefix) Returns a map with all keys that start with the given prefix.static int
propertyAsInt
(Map<String, String> properties, String property, int defaultValue) Extract an integer value from the properties map with provided key.static long
propertyAsLong
(Map<String, String> properties, String property, long defaultValue) Extract a long value from the properties map with provided key.Returns an unmodifiable map.
-
Method Details
-
getPrefixMap
Returns a map with all keys that start with the given prefix.- Parameters:
m
- The map to filter.prefix
- The prefix to filter by.- Returns:
- A map with all keys that start with the given prefix.
-
getPrefixMap
public static Map<String,String> getPrefixMap(Map<String, String> m, String prefix, boolean keepPrefix) Returns a map with all keys that start with the given prefix.- Parameters:
m
- The map to filter.prefix
- The prefix to filter by.keepPrefix
- Whether to keep the prefix in the key or not.- Returns:
- A map with all keys that start with the given prefix.
-
getMapWithoutPrefix
Returns a new map containing entries whose keys do NOT start with the given prefix.- Parameters:
m
- the original mapprefix
- the prefix to exclude- Returns:
- a filtered map without entries whose keys start with the prefix
-
getFilteredMap
Returns a map with all keys that match the predicate.- Parameters:
m
- The map to filter.predicate
- The predicate expression to filter the keys.- Returns:
- A map with all keys that match the predicate.
-
unmodifiableMap
Returns an unmodifiable map.- Parameters:
m
- The map to make unmodifiable.- Returns:
- An unmodifiable map.
-
propertyAsInt
Extract an integer value from the properties map with provided key. If provided key not exist in the properties map, it will return default value.- Parameters:
properties
- input mapproperty
- provided keydefaultValue
- default value- Returns:
- integer value from the properties map with provided key.
-
propertyAsLong
public static long propertyAsLong(Map<String, String> properties, String property, long defaultValue) Extract a long value from the properties map with provided key. If provided key not exist in the properties map, it will return default value.- Parameters:
properties
- input mapproperty
- provided keydefaultValue
- default value- Returns:
- long value from the properties map with provided key.
-