Class StringUtils

java.lang.Object
org.incendo.cloud.util.StringUtils

@API(status=INTERNAL, consumers="org.incendo.cloud.*") public final class StringUtils extends Object
String utilities
  • Method Details

    • countCharOccurrences

      public static int countCharOccurrences(@NonNull String haystack, char needle)
      Count the occurrences of a character in a string
      Parameters:
      haystack - The string to search in
      needle - The character to count for
      Returns:
      Number of occurrences
    • replaceAll

      public static @NonNull String replaceAll(@NonNull String string, @NonNull Pattern pattern, @NonNull Function<@NonNull MatchResult,@NonNull String> replacer)
      Replace all matches in a string.
      Parameters:
      string - string to process
      pattern - replacement pattern
      replacer - replacement function
      Returns:
      processed string
    • trimBeforeLastSpace

      public static @Nullable String trimBeforeLastSpace(String suggestion, String input)
      Trims before the last space from suggestion, if it matches input tokens.
      Parameters:
      suggestion - suggestion text
      input - current input
      Returns:
      filtered suggestion text
    • trimBeforeLastSpace

      public static @Nullable String trimBeforeLastSpace(String suggestion, CommandInput commandInput)
      Trims before the last space from suggestion, if it matches input tokens.
      Parameters:
      suggestion - suggestion
      commandInput - command input
      Returns:
      filtered suggestion text