Class StringUtils
java.lang.Object
com.kingsrook.qqq.backend.core.utils.StringUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringallCapsToMixedCase(String input) allCapsToMixedCase - ie, UNIT_CODE -> Unit Codestatic StringappendIncrementingSuffix(String input) static Stringstatic BooleanhasContent(String input) test if string is not null and is not empty (after being trimmed).static booleandetermines if a given string is a UUIDstatic Stringjoin(String glue, Collection<? extends Object> collection) Join a collection of objects into 1 stringstatic StringjoinWithCommasAndAnd(List<String> input) joinWithCommasAndAnd [one] => [one] [one, two] => [one and two] [one, two, three] => [one, two, and three] [one, two, three, four] => [one, two, three, and four] etc.static StringLowercase the first char of a string.static StringTrims leading white spaces from a String.static StringmaskAndTruncate(String value) static StringmaskAndTruncate(String value, String mask, int minLengthToMask, int charsToShowOnEnds) static Stringstatic StringnCopiesWithGlue(int n, String s, String glue) static Stringreturns input.toString() if not null, or nullOutput if input == null (as in SQL NVL)static Stringreturns input if not null, or nullOutput if input == null (as in SQL NVL)static StringSwitch between strings based on if the 'size' parameter is 1 (the singular) or not-1 (0 or 2+, the plural).static StringSwitch between strings based on if the 'size' parameter is 1 (the singular) or not-1 (0 or 2+, the plural).static Stringplural(Collection<?> collection) Switch between strings based on if the size of the parameter collection.static Stringplural(Collection<?> collection, String ifOne, String ifNotOne) Switch between strings based on if the size of the parameter collection.static StringpluralFormat(Integer size, String formatString) Given a "formatString" containing any number of {singular,plural} style "tokens", replace the "tokens" with the "singular" options if the 'size' parameter is 1 or the "plural" options if not-1 (e.g., 0 or 2+) e.g.: StringUtils.pluralFormat(n, "Apple{,s} {was,were} eaten")) // seems easier.static Stringstatic StringTrims trailing white spaces from a String.static StringsafeAppend(String input, String contentToAppend) safely appends a string to another, changing empty string if either value is nullstatic booleansafeEqualsIgnoreCase(String a, String b) static Stringreturns input if not null, or nullOutput if input == null (as in SQL NVL)static StringsafeTruncate(String input, int maxLength) truncate a string (null- and index-bounds- safely) at a max length.static StringsafeTruncate(String input, int maxLength, String suffix) null- and index-bounds- safely truncate a string to a max length, appending a suffix (like "...") if it did get truncated.static StringUppercase the first char of a string.
-
Constructor Details
-
StringUtils
public StringUtils()
-
-
Method Details
-
hasContent
-
nvl
-
nvl
-
allCapsToMixedCase
-
safeTruncate
-
safeTruncate
-
safeAppend
-
safeTrim
-
join
Join a collection of objects into 1 string- Parameters:
glue- - String to insert between entriescollection- - The collection of objects to join.- Returns:
- String
-
joinWithCommasAndAnd
-
ltrim
-
rtrim
-
pluralFormat
Given a "formatString" containing any number of {singular,plural} style "tokens", replace the "tokens" with the "singular" options if the 'size' parameter is 1 or the "plural" options if not-1 (e.g., 0 or 2+) e.g.: StringUtils.pluralFormat(n, "Apple{,s} {was,were} eaten")) // seems easier. e.g.: StringUtils.pluralFormat(n, "Apple{ was,s were} eaten")) // also works... -
plural
Switch between strings based on if the size of the parameter collection. If it is 1 (the singular) or not-1 (0 or 2+, the plural). Get back "" or "s" -
plural
-
plural
Switch between strings based on if the size of the parameter collection. If it is 1 (the singular) or not-1 (0 or 2+, the plural). Specify/customize the values that you get back (e.g., "y", "ies") -
plural
-
lcFirst
-
ucFirst
-
isUUID
determines if a given string is a UUID -
replaceNonAsciiCharacters
-
emptyToNull
-
safeEqualsIgnoreCase
-
appendIncrementingSuffix
-
maskAndTruncate
-
maskAndTruncate
-
nCopies
-
nCopiesWithGlue
-