public class Strings extends Object
Constructor and Description |
---|
Strings() |
Modifier and Type | Method and Description |
---|---|
static boolean |
equalsIgnoreCase(String s,
String v) |
static boolean |
isBlank(String s) |
static boolean |
isEmpty(String s)
Returns whether the specified string is empty while remaining null-safe.
|
static boolean |
isNotBlank(String s) |
static boolean |
isNotEmpty(String s)
Returns whether the specified string is not empty while remaining null-safe.
|
static String |
join(Iterable<?> col,
String separator) |
static String |
joinClassNames(Iterable<?> iterable) |
static List<String> |
splitAndTrim(String value,
String regex) |
static Boolean |
toBoolean(String s)
Attempts to return the best boolean representation for the specified string while remaining null-safe and
ignoring any leading/trailing whitespace as well as case.
|
static String |
trim(String s)
Trims the specified string while remaining null-safe.
|
static String |
trimToNull(String s)
Trims the specified string and, if the resulting string is empty, will return null instead.
|
public static boolean isBlank(String s)
public static boolean isNotBlank(String s)
public static boolean isEmpty(String s)
Returns whether the specified string is empty while remaining null-safe.
s
- the string to be checked (may be null)s
is either null or contains no characters.public static boolean isNotEmpty(String s)
Returns whether the specified string is not empty while remaining null-safe.
s
- the string to be checked (may be null)s
is not null and contains at least one character.public static String trim(String s)
Trims the specified string while remaining null-safe.
s
- the string to be trimmed (may be null)s
or null if s
is null.public static String trimToNull(String s)
Trims the specified string and, if the resulting string is empty, will return null instead.
s
- the string to be trimmed (may be null)s
or null if s
is null before or after being trimmed.public static Boolean toBoolean(String s)
Attempts to return the best boolean representation for the specified string while remaining null-safe and ignoring any leading/trailing whitespace as well as case.
This method simply uses a set of predefined values that it compares s
to in order to determine the best
Boolean
representation. If s
does not fall into either category, it is considered invalid and
will result in an IllegalArgumentException
being thrown.
s
- the string to be converted into a Boolean
Boolean
representation of s
or null if s
is null.IllegalArgumentException
- If s
is non-null and does not match any of the predefined values.Copyright © 2017. All Rights Reserved.