Class StringUtils

java.lang.Object
io.micrometer.core.instrument.util.StringUtils

public final class StringUtils extends Object
Utilities for String.
  • Method Details

    • isBlank

      public static boolean isBlank(@Nullable String string)
      Check if the String is null or has only whitespaces. Modified from StringUtils.isBlank(String).
      Parameters:
      string - String to check
      Returns:
      true if the String is null or has only whitespaces
    • isNotBlank

      public static boolean isNotBlank(@Nullable String string)
      Check if the String has any non-whitespace character.
      Parameters:
      string - String to check
      Returns:
      true if the String has any non-whitespace character
    • isEmpty

      public static boolean isEmpty(@Nullable String string)
      Check if the String is null or empty.
      Parameters:
      string - String to check
      Returns:
      true if the String is null or empty
    • isNotEmpty

      public static boolean isNotEmpty(@Nullable String string)
      Check if the String has any character.
      Parameters:
      string - String to check
      Returns:
      true if the String has any character
      Since:
      1.1.0
    • truncate

      public static String truncate(String string, int maxLength)
      Truncate the String to the max length.
      Parameters:
      string - String to truncate
      maxLength - max length
      Returns:
      truncated String
    • truncate

      public static String truncate(String string, int maxLength, String truncationIndicator)
      Truncate the String to the max length and append string to indicate if truncation was applied
      Parameters:
      string - String to truncate
      maxLength - max length, which includes the length required for truncationIndicator
      truncationIndicator - A string that is appended if string is truncated
      Returns:
      truncated String