Package org.faktorips.runtime.internal
Class IpsStringUtils
java.lang.Object
org.faktorips.runtime.internal.IpsStringUtils
A collection of utility methods for Strings. We don't use a class library like apache-commons
here to minimize the dependencies for the generated code.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanequalsNullAsEmpty(String s1, String s2) Compares two strings, treatingnullasEMPTY.static booleanReturnstrueifsis eithernull, the empty string or a string that only contains whitespace, otherwisefalse.static booleanReturnstrueifsis eithernullor the empty string, otherwisefalse.static booleanisNotBlank(String s) Returnstrueifsis neithernull, the empty string nor a string that only contains whitespace, otherwisefalse.static booleanisNotEmpty(String s) Returnstrueifsis neithernullnor the empty string, otherwisefalse.static Stringstatic StringJoins the elements of the providedIterableinto a single String containing the provided elements with the given separator.static <T> Stringstatic <T> Stringstatic StringJoins the elements of the provided array into a single String containing the provided elements with the default separator ", ".static StringJoins the elements of the provided array into a single String containing the provided elements with the given separator.static Stringjoin(Collection<?> collection, String separator) Joins the elements of the providedCollectioninto a single String containing the provided elements with the given separator.static StringreplaceEach(String text, String[] searchList, String[] replacementList) Replaces all occurrences of Strings within another String.static StringtoLowerFirstChar(String string) static StringtoUpperFirstChar(String string) static booleantrimEquals(String s1, String s2) Trims the parameters, if the are notnulland checks for equality usingObjects.equals(Object, Object).
-
Field Details
-
EMPTY
- See Also:
-
-
Method Details
-
isEmpty
Returnstrueifsis eithernullor the empty string, otherwisefalse. -
isNotEmpty
Returnstrueifsis neithernullnor the empty string, otherwisefalse. -
isBlank
Returnstrueifsis eithernull, the empty string or a string that only contains whitespace, otherwisefalse. -
isNotBlank
Returnstrueifsis neithernull, the empty string nor a string that only contains whitespace, otherwisefalse. -
trimEquals
Trims the parameters, if the are notnulland checks for equality usingObjects.equals(Object, Object).- Parameters:
s1- a strings2- another string to be compared with a for equality- Returns:
trueif the arguments are equal to each other andfalseotherwise
-
equalsNullAsEmpty
Compares two strings, treatingnullasEMPTY.- Parameters:
s1- a strings2- another string- Returns:
- whether both strings are equal
-
join
Joins the elements of the providedCollectioninto a single String containing the provided elements with the given separator. No delimiter is added before or after the list.- Parameters:
collection- the Collection of values to join together, may benullseparator- the separator to use,nulltreated as ""- Returns:
- the joined String, empty if the collection is
null
-
join
Joins the elements of the providedIterableinto a single String containing the provided elements with the given separator. No delimiter is added before or after the list.- Parameters:
iterable- the Collection of values to join together, may benullseparator- the separator to use,nulltreated as ""- Returns:
- the joined String, empty if the collection is
null
-
join
Joins the elements of the providedIterableinto a single String containing the provided elements with the default separator ", ". No delimiter is added before or after the list.- Parameters:
iterable- the Collection of values to join together, may benull- Returns:
- the joined String, empty if the collection is
null
-
join
Joins the elements of the provided array into a single String containing the provided elements with the default separator ", ". No delimiter is added before or after the list.- Parameters:
objectArray- the array of values to join together, may benull- Returns:
- the joined String, empty if the collection is
null
-
join
Joins the elements of the provided array into a single String containing the provided elements with the given separator. No delimiter is added before or after the list.- Parameters:
objectArray- the array of values to join together, may benullseparator- the separator to use,nulltreated as ""- Returns:
- the joined String, empty if the collection is
null
-
join
-
join
public static <T> String join(Iterable<T> iterable, Function<? super T, String> toString, String separator) -
toLowerFirstChar
-
toUpperFirstChar
- Since:
- 24.7
-
replaceEach
Replaces all occurrences of Strings within another String.
A
nullreference passed to this method is a no-op, or if any "search string" or "string to replace" isnull, that replace will be ignored.IpsStringUtils.replaceEach(null, *, *) = null IpsStringUtils.replaceEach("", *, *) = "" IpsStringUtils.replaceEach("aba", null, null) = "aba" IpsStringUtils.replaceEach("aba", new String[0], null) = "aba" IpsStringUtils.replaceEach("aba", null, new String[0]) = "aba" IpsStringUtils.replaceEach("aba", new String[]{"a"}, null) = "aba" IpsStringUtils.replaceEach("aba", new String[]{"a"}, new String[]{""}) = "b" IpsStringUtils.replaceEach("aba", new String[]{null}, new String[]{"a"}) = "aba" IpsStringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"w", "t"}) = "wcte" (example of how it does not repeat) IpsStringUtils.replaceEach("abcde", new String[]{"ab", "d"}, new String[]{"d", "t"}) = "dcte"- Parameters:
text- text to search and replace in, no-op if nullsearchList- the Strings to search for, no-op if nullreplacementList- the Strings to replace them with, no-op if null- Returns:
- the text with any replacements processed,
nullif null String input - Throws:
IllegalArgumentException- if the lengths of the arrays are not the same (null is ok, and/or size 0)
-