You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hudi.apache.org by GitBox <gi...@apache.org> on 2020/01/07 16:07:38 UTC

[GitHub] [incubator-hudi] vinothchandar commented on a change in pull request #1159: [WIP][HUDI-479] Eliminate or Minimize use of Guava if possible

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_r363820681
 
 

 ##########
 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) {
 
 Review comment:
   just `isNullOrEmpty()` for brevity?

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services