public class Strings extends Object
| Modifier and Type | Method and Description |
|---|---|
static String |
emptyToNull(String string)
Returns the given string if it is non-empty,
null otherwise. |
static boolean |
endsWith(String string,
String suffix,
boolean ignoreCase)
Checks whether the given string ends with the given suffix, possibly ignoring case.
|
static String |
ensurePrefix(String string,
String prefix)
Ensures that the given string starts with the given prefix.
|
static String |
ensurePrefix(String string,
String prefix,
boolean ignoreCase)
Ensures that the given string starts with the given prefix, possibly ignoring case.
|
static String |
ensureSuffix(String string,
String suffix)
Ensures that the given string ends with the given suffix.
|
static String |
ensureSuffix(String string,
String suffix,
boolean ignoreCase)
Ensures that the given string ends with the given suffix, possibly ignoring case.
|
static boolean |
isNullOrEmpty(String string)
Checks whether the given string is
null or empty. |
static String |
normalizeWhitespace(String string)
Removes any leading and trailing whitespace characters from the given string and replaces any contained sequences of whitespace characters by a single space.
|
static String |
nullToEmpty(String string)
Returns the given string if it is non-empty, an empty string otherwise.
|
static String |
removePrefix(String string,
String prefix)
Removes the given prefix from the given string if present.
|
static String |
removePrefix(String string,
String prefix,
boolean ignoreCase)
Removes the given prefix from the given string if present, possibly ignoring case.
|
static String |
removeSuffix(String string,
String suffix)
Removes the given suffix from the given string if present.
|
static String |
removeSuffix(String string,
String suffix,
boolean ignoreCase)
Removes the given suffix from the given string if present, possibly ignoring case.
|
static String |
removeWhitespace(String string)
Removes all whitespace characters from the given string.
|
static boolean |
startsWith(String string,
String prefix,
boolean ignoreCase)
Checks whether the given string starts with the given prefix, possibly ignoring case.
|
static String |
toLowerCase(String string)
Returns the given string converted to lower case in a locale-insensitive way.
|
static String |
toUpperCase(String string)
Returns the given string converted to upper case in a locale-insensitive way.
|
public static String emptyToNull(String string)
null otherwise.public static boolean endsWith(String string, String suffix, boolean ignoreCase)
IllegalArgumentException - if string is nullIllegalArgumentException - if suffix is nullpublic static String ensurePrefix(String string, String prefix)
IllegalArgumentException - if string is nullIllegalArgumentException - if prefix is nullpublic static String ensurePrefix(String string, String prefix, boolean ignoreCase)
IllegalArgumentException - if string is nullIllegalArgumentException - if prefix is nullpublic static String ensureSuffix(String string, String suffix)
IllegalArgumentException - if string is nullIllegalArgumentException - if suffix is nullpublic static String ensureSuffix(String string, String suffix, boolean ignoreCase)
IllegalArgumentException - if string is nullIllegalArgumentException - if suffix is nullpublic static boolean isNullOrEmpty(String string)
null or empty.public static String normalizeWhitespace(String string)
IllegalArgumentException - if string is nullpublic static String nullToEmpty(String string)
public static String removePrefix(String string, String prefix)
IllegalArgumentException - if string is nullIllegalArgumentException - if prefix is nullpublic static String removePrefix(String string, String prefix, boolean ignoreCase)
IllegalArgumentException - if string is nullIllegalArgumentException - if prefix is nullpublic static String removeSuffix(String string, String suffix)
IllegalArgumentException - if string is nullIllegalArgumentException - if suffix is nullpublic static String removeSuffix(String string, String suffix, boolean ignoreCase)
IllegalArgumentException - if string is nullIllegalArgumentException - if suffix is nullpublic static String removeWhitespace(String string)
IllegalArgumentException - if string is nullpublic static boolean startsWith(String string, String prefix, boolean ignoreCase)
IllegalArgumentException - if string is nullIllegalArgumentException - if prefix is nullpublic static String toLowerCase(String string)
IllegalArgumentException - if string is nullpublic static String toUpperCase(String string)
IllegalArgumentException - if string is null