public class ManStringExt extends Object
Constructor and Description |
---|
ManStringExt() |
Modifier and Type | Method and Description |
---|---|
static String |
emptyIfNull(String thiz)
Returns the string if it is not null, or the empty string otherwise.
|
static String |
padEnd(String thiz,
int length,
char padChar)
Pads the string to the specified
length at the end with the specified character or space. |
static String |
padStart(String thiz,
int length,
char padChar)
Pads the string to the specified
length at the beginning with the specified character or space. |
static String |
removePrefix(String thiz,
CharSequence prefix)
If thiz string starts with the given
prefix , returns a copy of thiz string
with the prefix removed. |
static String |
removeSuffix(String thiz,
CharSequence suffix)
If thiz string ends with the given
suffix , returns a copy of thiz string
with the suffix removed. |
static CharSequence |
removeSurrounding(String thiz,
CharSequence delimiter)
Removes the given
delimiter string from both the start and the end of thiz string
if and only if it starts with and ends with the delimiter . |
static String |
removeSurrounding(String thiz,
CharSequence prefix,
CharSequence suffix)
Removes from a string both the given
prefix and suffix if and only if
it starts with the prefix and ends with the suffix . |
static String |
substringAfter(String thiz,
char delimiter)
Returns a substring after the first occurrence of
delimiter or null if the string
does not contain the delimiter |
static String |
substringAfter(String thiz,
String delimiter)
Returns a substring after the first occurrence of
delimiter or null if the string
does not contain the delimiter |
static String |
substringAfterLast(String thiz,
char delimiter)
Returns a substring after the last occurrence of delimiter or null if the string
does not contain the delimiter
|
static String |
substringAfterLast(String thiz,
String delimiter)
Returns a substring after the last occurrence of delimiter or null if the string
does not contain the delimiter
|
static String |
substringBefore(String thiz,
char delimiter)
Returns a substring before the first occurrence of
delimiter or null if the string
does not contain the delimiter |
static String |
substringBefore(String thiz,
String delimiter)
Returns a substring before the first occurrence of
delimiter or null if the string
does not contain the delimiter |
static String |
substringBeforeLast(String thiz,
char delimiter)
Returns a substring before the last occurrence of
delimiter or null if the string
does not contain the delimiter |
static String |
substringBeforeLast(String thiz,
String delimiter)
Returns a substring before the last occurrence of
delimiter or null if the string
does not contain the delimiter |
static String |
trim(String thiz,
char... chars)
Returns a string with leading and trailing characters from the
chars array trimmed. |
static String |
trim(String thiz,
CharPredicate predicate)
Returns a string with leading and trailing characters matching the
predicate trimmed. |
static String |
trimEnd(String thiz)
Returns a string with trailing whitespace removed.
|
static String |
trimEnd(String thiz,
char... chars)
Returns a string with trailing characters from the
chars array trimmed. |
static String |
trimEnd(String thiz,
CharPredicate predicate)
Returns a string with trailing characters matching the
predicate trimmed. |
static String |
trimStart(String thiz)
Returns a string with leading whitespace removed.
|
static String |
trimStart(String thiz,
char... chars)
Returns a string with leading and trailing characters from the
chars array trimmed. |
static String |
trimStart(String thiz,
CharPredicate predicate)
Returns a string with leading characters matching the
predicate trimmed. |
public static String trim(String thiz, CharPredicate predicate)
predicate
trimmed.public static String trimStart(String thiz, CharPredicate predicate)
predicate
trimmed.public static String trimEnd(String thiz, CharPredicate predicate)
predicate
trimmed.public static String trim(String thiz, char... chars)
chars
array trimmed.public static String trimStart(String thiz, char... chars)
chars
array trimmed.public static String trimEnd(String thiz, char... chars)
chars
array trimmed.public static String trimStart(String thiz)
public static String trimEnd(String thiz)
public static String padStart(String thiz, int length, char padChar)
length
at the beginning with the specified character or space.length
- the desired string length.padChar
- the character to pad string with, if it has length less than the length
specified.length
, consisting of string prepended with padChar
as many times.
as are necessary to reach that length.public static String padEnd(String thiz, int length, char padChar)
length
at the end with the specified character or space.length
- the desired string length.padChar
- the character to pad string with, if it has length less than the length
specified.length
, consisting of string prepended with padChar
as many times.
as are necessary to reach that length.public static String emptyIfNull(String thiz)
public static String substringBefore(String thiz, char delimiter)
delimiter
or null if the string
does not contain the delimiterpublic static String substringBefore(String thiz, String delimiter)
delimiter
or null if the string
does not contain the delimiterpublic static String substringAfter(String thiz, char delimiter)
delimiter
or null if the string
does not contain the delimiterpublic static String substringAfter(String thiz, String delimiter)
delimiter
or null if the string
does not contain the delimiterpublic static String substringBeforeLast(String thiz, char delimiter)
delimiter
or null if the string
does not contain the delimiterpublic static String substringBeforeLast(String thiz, String delimiter)
delimiter
or null if the string
does not contain the delimiterpublic static String substringAfterLast(String thiz, char delimiter)
public static String substringAfterLast(String thiz, String delimiter)
public static String removePrefix(String thiz, CharSequence prefix)
prefix
, returns a copy of thiz string
with the prefix removed. Otherwise, returns thiz string.public static String removeSuffix(String thiz, CharSequence suffix)
suffix
, returns a copy of thiz string
with the suffix removed. Otherwise, returns thiz string.public static String removeSurrounding(String thiz, CharSequence prefix, CharSequence suffix)
prefix
and suffix
if and only if
it starts with the prefix
and ends with the suffix
.
Otherwise returns thiz string unchanged.public static CharSequence removeSurrounding(String thiz, CharSequence delimiter)
delimiter
string from both the start and the end of thiz string
if and only if it starts with and ends with the delimiter
.
Otherwise returns thiz string unchanged.Copyright © 2024. All rights reserved.