hqbhoho commented on code in PR #7495:
URL: https://github.com/apache/gravitino/pull/7495#discussion_r2221063364


##########
common/src/main/java/org/apache/gravitino/utils/MapUtils.java:
##########
@@ -76,4 +76,36 @@ public static Map<String, String> getFilteredMap(Map<String, 
String> m, Predicat
   public static Map<String, String> unmodifiableMap(Map<String, String> m) {
     return Collections.unmodifiableMap(m);
   }
+
+  /**
+   * Extract an integer value from the properties map with provided key. If 
provided key not exist
+   * in the properties map, it will return null.
+   *
+   * @param properties input map
+   * @param property provided key
+   * @return integer value from the properties map with provided key.
+   */
+  public static Integer propertyAsNullableInt(Map<String, String> properties, 
String property) {
+    String value = properties.get(property);
+    if (value != null) {
+      return Integer.parseInt(value);
+    }
+    return null;
+  }
+
+  /**
+   * Extract a long value from the properties map with provided key. If 
provided key not exist in
+   * the properties map, it will return null.
+   *
+   * @param properties input map
+   * @param property provided key
+   * @return long value from the properties map with provided key.
+   */
+  public static Long propertyAsNullableLong(Map<String, String> properties, 
String property) {
+    String value = properties.get(property);
+    if (value != null) {
+      return Long.parseLong(value);
+    }
+    return null;
+  }

Review Comment:
   if add default value is necessary, it's ok!



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to