Class StringUtils
java.lang.Object
com.kingsrook.qqq.backend.core.utils.StringUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic String
allCapsToMixedCase
(String input) allCapsToMixedCase - ie, UNIT_CODE -> Unit Codestatic String
appendIncrementingSuffix
(String input) static String
static Boolean
hasContent
(String input) test if string is not null and is not empty (after being trimmed).static boolean
determines if a given string is a UUIDstatic String
join
(String glue, Collection<? extends Object> collection) Join a collection of objects into 1 stringstatic String
joinWithCommasAndAnd
(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 String
Lowercase the first char of a string.static String
Trims leading white spaces from a String.static String
maskAndTruncate
(String value) static String
maskAndTruncate
(String value, String mask, int minLengthToMask, int charsToShowOnEnds) static String
static String
nCopiesWithGlue
(int n, String s, String glue) static String
returns input.toString() if not null, or nullOutput if input == null (as in SQL NVL)static String
returns input if not null, or nullOutput if input == null (as in SQL NVL)static String
Switch between strings based on if the 'size' parameter is 1 (the singular) or not-1 (0 or 2+, the plural).static String
Switch between strings based on if the 'size' parameter is 1 (the singular) or not-1 (0 or 2+, the plural).static String
plural
(Collection<?> collection) Switch between strings based on if the size of the parameter collection.static String
plural
(Collection<?> collection, String ifOne, String ifNotOne) Switch between strings based on if the size of the parameter collection.static String
pluralFormat
(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 String
static String
Trims trailing white spaces from a String.static String
safeAppend
(String input, String contentToAppend) safely appends a string to another, changing empty string if either value is nullstatic boolean
safeEqualsIgnoreCase
(String a, String b) static String
returns input if not null, or nullOutput if input == null (as in SQL NVL)static String
safeTruncate
(String input, int maxLength) truncate a string (null- and index-bounds- safely) at a max length.static String
safeTruncate
(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 String
Uppercase 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
-