Strings,
CharSequences, etc.
These utilities are intended solely for usage within the JUnit framework itself. Any usage by external parties is not supported. Use at your own risk!
| Modifier and Type | Class and Description |
|---|---|
| private static record | |
| private static record | |
| public static interface | StringUtils.
The result of splitting a string into up to two parts. |
| Modifier and Type | Field and Description |
|---|---|
| private static final Pattern | |
| private static final Pattern |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv static Pattern | |
| public static boolean | Returns: true if the string contains an ISO control characterthe string to check; may be str)nullDetermine if the supplied |
| public static boolean | Returns: true if the string contains whitespacethe string to check; may be str)nullDetermine if the supplied |
| public static String | Returns: the default String representation of the supplied object; nevernullthe object to convert to a String; may be obj)nullConvert the supplied |
| public static boolean | Returns: true if the string does not contain an ISO control characterthe string to check; may be str)nullDetermine if the supplied |
| public static boolean | Returns: true if the string does not contain whitespacethe string to check; may be str)nullDetermine if the supplied |
| public static boolean | |
| public static boolean | Returns: true if the string is not blankthe string to check; may be str)null |
| public static String | Returns: a String representation of the supplied object; nevernullthe object to convert to a String; may be obj)nullConvert the supplied |
| public static @Nullable String | Returns: the supplied string with all control characters replaced, ornull if the supplied string was nullthe string in which to perform the replacement; may be str, String nullthe replacement string; never replacement)nullReplace all ISO control characters in the supplied |
| public static @Nullable String | Returns: the supplied string with all whitespace characters replaced, ornull if the supplied string was nullthe string in which to perform the replacement; may be str, String nullthe replacement string; never replacement)nullReplace all whitespace characters in the supplied |
| public static StringUtils. | splitIntoTwo(char
the separator character separator, String the value to split; never value)nullSplit the supplied |
| public static StringUtils. | splitIntoTwo(String
the separator string; never separator, String nullthe value to split; never value)nullSplit the supplied |
| private static StringUtils. |
| ISO_CONTROL_PATTERN | back to summary |
|---|---|
| private static final Pattern ISO_CONTROL_PATTERN | |
| WHITESPACE_PATTERN | back to summary |
|---|---|
| private static final Pattern WHITESPACE_PATTERN | |
| StringUtils | back to summary |
|---|---|
| private StringUtils() | |
| compileIsoControlPattern | back to summary |
|---|---|
| pack-priv static Pattern compileIsoControlPattern() Guard against "IllegalArgumentException: Unsupported flags: 256" errors.
| |
| containsIsoControlCharacter | back to summary |
|---|---|
| public static boolean containsIsoControlCharacter(@Nullable String str) Determine if the supplied
| |
| containsWhitespace | back to summary |
|---|---|
| public static boolean containsWhitespace(@Nullable String str) Determine if the supplied
| |
| defaultToString | back to summary |
|---|---|
| public static String defaultToString(@Nullable Object obj) Convert the supplied
| |
| doesNotContainIsoControlCharacter | back to summary |
|---|---|
| public static boolean doesNotContainIsoControlCharacter(@Nullable String str) Determine if the supplied
| |
| doesNotContainWhitespace | back to summary |
|---|---|
| public static boolean doesNotContainWhitespace(@Nullable String str) Determine if the supplied
| |
| isBlank | back to summary |
|---|---|
| public static boolean isBlank(@Nullable String str) Determine if the supplied
| |
| isNotBlank | back to summary |
|---|---|
| public static boolean isNotBlank(@Nullable String str) Determine if the supplied
| |
| nullSafeToString | back to summary |
|---|---|
| public static String nullSafeToString(@Nullable Object obj) Convert the supplied
| |
| replaceIsoControlCharacters | back to summary |
|---|---|
| public static @Nullable String replaceIsoControlCharacters(@Nullable String str, String replacement) Replace all ISO control characters in the supplied | |
| replaceWhitespaceCharacters | back to summary |
|---|---|
| public static @Nullable String replaceWhitespaceCharacters(@Nullable String str, String replacement) Replace all whitespace characters in the supplied | |
| splitIntoTwo | back to summary |
|---|---|
| public static StringUtils. Split the supplied | |
| splitIntoTwo | back to summary |
|---|---|
| public static StringUtils. Split the supplied | |
| splitIntoTwo | back to summary |
|---|---|
| private static StringUtils. | |
| Modifier and Type | Field and Description |
|---|---|
| private final String |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| public <T> T | map(Function<String, ? extends T> onePartMapper, BiFunction<String, String, ? extends T> twoPartsMapper)
Implements org. Map the result of splitting a string into up to two parts. |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| public String |
| value | back to summary |
|---|---|
| private final String value Record Component accessed by value(). | |
| OnePart | back to summary |
|---|---|
| private OnePart(String value) | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| map | back to summary |
|---|---|
| public <T> T map(Function<String, ? extends T> onePartMapper, BiFunction<String, String, ? extends T> twoPartsMapper) Implements org. Doc from org. Map the result of splitting a string into up to two parts.
| |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |
| value | back to summary |
|---|---|
| public String value() Record Component getter of value. | |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public String | |
| public final int | |
| public <T> T | map(Function<String, ? extends T> onePartMapper, BiFunction<String, String, ? extends T> twoPartsMapper)
Implements org. Map the result of splitting a string into up to two parts. |
| public String | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| first | back to summary |
|---|---|
| private final String first Record Component accessed by first(). | |
| second | back to summary |
|---|---|
| private final String second Record Component accessed by second(). | |
| TwoParts | back to summary |
|---|---|
| private TwoParts(String first, String second) | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| first | back to summary |
|---|---|
| public String first() Record Component getter of first. | |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| map | back to summary |
|---|---|
| public <T> T map(Function<String, ? extends T> onePartMapper, BiFunction<String, String, ? extends T> twoPartsMapper) Implements org. Doc from org. Map the result of splitting a string into up to two parts.
| |
| second | back to summary |
|---|---|
| public String second() Record Component getter of second. | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves. | |
StringUtils#splitIntoTwo(char, String), StringUtils#splitIntoTwo(String, String)
| Modifier and Type | Method and Description |
|---|---|
| public <T> T | |
| public default <T> T | mapTwo(Supplier<? extends RuntimeException>
the exception creator to use if the string
was split into a single part onePartExceptionCreator, BiFunction<String, String, ? extends T> the mapper to use if the string was split into two parts twoPartsMapper)Map the result of splitting a string into two parts or throw an exception. |
| map | back to summary |
|---|---|
| public <T> T map(Function<String, ? extends T> onePartMapper, BiFunction<String, String, ? extends T> twoPartsMapper) Map the result of splitting a string into up to two parts.
| |
| mapTwo | back to summary |
|---|---|
| public default <T> T mapTwo(Supplier<? extends RuntimeException> onePartExceptionCreator, BiFunction<String, String, ? extends T> twoPartsMapper) Map the result of splitting a string into two parts or throw an exception.
| |