Package valorless.valorlessutils.json
Class StringUtils
java.lang.Object
valorless.valorlessutils.json.StringUtils
Utility functions related to Strings.
- 
Nested Class SummaryNested Classes
- 
Method SummaryModifier and TypeMethodDescriptionstatic <T> voidaddArgumentsToMap(Map<@NonNull String, @NonNull Object> argumentsMap, @NonNull Object... argumentPairs) static StringcapitalizeAll(String source) static booleanChecks if the givenStringcontains the specified character.static booleancontainsNewline(@Nullable String string) static booleancontainsWhitespace(@Nullable String string) Checks if the given String contains whitespace characters.static StringescapeNewlinesAndBackslash(String string) static @Nullable StringgetNotEmpty(@Nullable String string) Makes sure that the given String is not empty.static StringgetOrEmpty(@Nullable String string) Makes sure that the given String is notnull.static booleanstatic StringNormalizes the given identifier.static StringnormalizeKeepCase(String identifier) Normalizes the given identifier.static StringremoveWhitespace(String source) Removes all whitespace characters inside the given source String.static StringreplaceArguments(String source, @NonNull Object... argumentPairs) static StringreplaceArguments(String source, Map<? extends @NonNull String, @NonNull ?> arguments) static StringreplaceArguments(String source, MessageArguments arguments) replaceArguments(Collection<? extends @NonNull String> messages, @NonNull Object... argumentPairs) replaceArguments(Collection<? extends @NonNull String> sources, Map<? extends @NonNull String, @NonNull ?> arguments) replaceArguments(Collection<? extends @NonNull String> sources, MessageArguments arguments) static StringreplaceFirst(String source, String target, CharSequence replacement) static StringreplaceWhitespace(String source, String replacement) Replaces all whitespace characters inside the given source String.static @NonNull String[]splitLines(String source) static @NonNull String[]splitLines(String source, boolean splitLiteralNewlines) static StringstripTrailingNewlines(String string) static StringtoStringOrEmpty(@Nullable Object object) Converts the givenObjectto a String via itsObject.toString()method.static @Nullable StringtoStringOrNull(@Nullable Object object) Converts the givenObjectto a String via itsObject.toString()method.
- 
Method Details- 
isEmpty
- 
getNotEmptyMakes sure that the given String is not empty.- Parameters:
- string- the String
- Returns:
- the String itself, or nullif it is empty
 
- 
getOrEmptyMakes sure that the given String is notnull.- Parameters:
- string- the String
- Returns:
- the String itself, or an empty String if it is null
 
- 
toStringOrEmptyConverts the givenObjectto a String via itsObject.toString()method.If the object is null, or if itsObject.toString()method returnsnull, this returns an empty String.- Parameters:
- object- the object
- Returns:
- the String, not null
 
- 
toStringOrNullConverts the givenObjectto a String via itsObject.toString()method.Returns nullif the object isnull, or if itsObject.toString()method returnsnull.- Parameters:
- object- the object
- Returns:
- the String, possibly null
 
- 
containsChecks if the givenStringcontains the specified character.This is a shortcut for invoking String.indexOf(int)and checking if the return value does not equal-1.- Parameters:
- string- the String
- character- the character
- Returns:
- trueif the String contains the given character
 
- 
normalizeKeepCaseNormalizes the given identifier.This trims leading and trailing whitespace and converts all remaining whitespace and underscores to dashes (' -').- Parameters:
- identifier- the identifier, not- null
- Returns:
- the normalized identifier
 
- 
normalizeNormalizes the given identifier.This trims leading and trailing whitespace, converts all remaining whitespace and underscores to dashes (' -') and converts all characters to lower case.- Parameters:
- identifier- the identifier, not- null
- Returns:
- the normalized identifier
 
- 
normalize
- 
containsWhitespaceChecks if the given String contains whitespace characters.- Parameters:
- string- the String
- Returns:
- trueif the given String is not empty and contains at least one whitespace character
 
- 
removeWhitespaceRemoves all whitespace characters inside the given source String.- Parameters:
- source- the source String, not- null
- Returns:
- the String without any whitespace characters
 
- 
replaceWhitespaceReplaces all whitespace characters inside the given source String.- Parameters:
- source- the source String, not- null
- replacement- the replacement String, not- null
- Returns:
- the String with any whitespace characters replaced
 
- 
capitalizeAll
- 
splitLines
- 
splitLines
- 
stripTrailingNewlines
- 
containsNewline
- 
escapeNewlinesAndBackslash
- 
replaceFirst
- 
addArgumentsToMap
- 
replaceArguments
- 
replaceArguments
- 
replaceArguments
- 
replaceArgumentspublic static List<@NonNull String> replaceArguments(Collection<? extends @NonNull String> messages, @NonNull Object... argumentPairs) 
- 
replaceArguments
- 
replaceArgumentspublic static List<@NonNull String> replaceArguments(Collection<? extends @NonNull String> sources, MessageArguments arguments) 
 
-