Package org.incendo.cloud.util
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 Summary
Modifier and TypeMethodDescriptionstatic intcountCharOccurrences(@NonNull String haystack, char needle) Count the occurrences of a character in a stringreplaceAll(@NonNull String string, @NonNull Pattern pattern, @NonNull Function<@NonNull MatchResult, @NonNull String> replacer) Replace all matches in a string.trimBeforeLastSpace(String suggestion, String input) Trims before the last space from suggestion, if it matches input tokens.trimBeforeLastSpace(String suggestion, CommandInput commandInput) Trims before the last space from suggestion, if it matches input tokens.
-
Method Details
-
countCharOccurrences
Count the occurrences of a character in a string- Parameters:
haystack- The string to search inneedle- 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 processpattern- replacement patternreplacer- replacement function- Returns:
- processed string
-
trimBeforeLastSpace
Trims before the last space from suggestion, if it matches input tokens.- Parameters:
suggestion- suggestion textinput- current input- Returns:
- filtered suggestion text
-
trimBeforeLastSpace
Trims before the last space from suggestion, if it matches input tokens.- Parameters:
suggestion- suggestioncommandInput- command input- Returns:
- filtered suggestion text
-