Class StringUtils

java.lang.Object
org.graylog2.shared.utilities.StringUtils

public final class StringUtils extends Object
  • Method Details

    • f

      public static String f(String format, Object... args)
      Calls String.format(Locale, String, Object...) with the given arguments with a locale value of Locale.ENGLISH.
      Parameters:
      format - the format string
      args - the format arguments
      Returns:
      the formatted string
    • toUpperCase

      public static String toUpperCase(@Nullable String value)
      Calls String.toUpperCase(Locale) on the given string with a locale value of Locale.ENGLISH.
      Parameters:
      value - the value
      Returns:
      the value in upper case
      Throws:
      IllegalArgumentException - when given value is null
    • toLowerCase

      public static String toLowerCase(@Nullable String value)
      Calls String.toLowerCase(Locale) on the given string with a locale value of Locale.ENGLISH.
      Parameters:
      value - the value
      Returns:
      the value in lower case
      Throws:
      IllegalArgumentException - when given value is null
    • humanReadableByteCount

      public static String humanReadableByteCount(long bytes)
    • splitByComma

      public static Set<String> splitByComma(Set<String> values)
    • splitByComma

      public static List<String> splitByComma(List<String> values)
    • requireNonBlank

      @Nonnull public static String requireNonBlank(String value)
      Returns the given string if it's not null and not only whitespace. Otherwise, throws an exception.
      Parameters:
      value - the string value to check
      Returns:
      the value if not null or blank
      Throws:
      IllegalArgumentException - when given string is null or whitespace
    • requireNonBlank

      @Nonnull public static String requireNonBlank(String value, String message)
      Returns the given string if it's not null and not only whitespace. Otherwise, throws an exception.
      Parameters:
      value - the string value to check
      message - the exception message
      Returns:
      the value if not null or blank
      Throws:
      IllegalArgumentException - when given string is null or whitespace