java.lang.Object
net.buildtheearth.terraminusminus.util.Strings

public final class Strings extends Object
String related utility functions.
  • Field Details

    • EMPTY_STRING_ARRAY

      public static String[] EMPTY_STRING_ARRAY
  • Method Details

    • isNullOrEmpty

      public static boolean isNullOrEmpty(@Nullable @Nullable String string)
      Tests whether a string is null or empty.
      Parameters:
      string - a string to test
      Returns:
      true if the string is either null or the empty string, false otherwise
    • countMatches

      public static int countMatches(@Nullable @Nullable CharSequence haystack, @Nullable @Nullable CharSequence needle)
      Counts the number of times a substring appears in a string. Occurrences of the substring overlapping each other count as one.
      Parameters:
      haystack - the string to search in
      needle - the substring to search
      Returns:
      the number of occurrences of the substring in the string, or 0 if either is null
    • countMatches

      public static int countMatches(@Nullable @Nullable CharSequence haystack, char needle)
      Counts the number of times a chars appears in a string.
      Parameters:
      haystack - the string to search in
      needle - the char to search
      Returns:
      the number of occurrences of the substring in the string, or 0 if the string is null
    • split

      @NonNull public static @NonNull String[] split(@Nullable @Nullable CharSequence str, char delimiter)
      Splits a string into a string array using a given delimiter. The delimiter is not included in the members of the resulting array. A null string returns an empty array.
      Parameters:
      str - the string to split
      delimiter - the delimiter to split the string with
      Returns:
      an array where each entry is a section of the origin string that was delimited by the given delimiter