vinothchandar commented on a change in pull request #1159: [WIP][HUDI-479] 
Eliminate or Minimize use of Guava if possible
URL: https://github.com/apache/incubator-hudi/pull/1159#discussion_r363821619
 
 

 ##########
 File path: 
hudi-common/src/main/java/org/apache/hudi/common/util/StringUtils.java
 ##########
 @@ -67,4 +69,45 @@ public static String toHexString(byte[] bytes) {
   public static boolean isNullOrEmpty(String str) {
     return str == null || str.length() == 0;
   }
+
+  /**
+   * Returns the given string if it is non-null; the empty string otherwise.
+   *
+   * @param string the string to test and possibly return
+   * @return {@code string} itself if it is non-null; {@code ""} if it is null
+   */
+  public static String nullToEmpty(@Nullable String string) {
+    return string == null ? "" : string;
+  }
+
+  /**
+   * Returns the given string if it is nonempty; {@code null} otherwise.
+   *
+   * @param string the string to test and possibly return
+   * @return {@code string} itself if it is nonempty; {@code null} if it is 
empty or null
+   */
+  public static @Nullable String emptyToNull(@Nullable String string) {
+    return stringIsNullOrEmpty(string) ? null : string;
+  }
+
+  public static boolean stringIsNullOrEmpty(@Nullable String string) {
+    return string == null || string.isEmpty();
+  }
+
+  /**
+   * Convert a Signed Hash to Hex.
+   * @param bytes - hashed bytes
+   * @return Hex representation of hash
+   */
+  public static String bytesToHexString(final byte[] bytes) {
 
 Review comment:
   Realized that this class needs a unit test.. :/ 

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to