Package org.togglz.core.util
Class Strings
- java.lang.Object
-
- org.togglz.core.util.Strings
-
public class Strings extends Object
-
-
Constructor Summary
Constructors Constructor Description Strings()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static booleanisBlank(String s)static booleanisEmpty(String s)Returns whether the specified string is empty while remaining null-safe.static booleanisNotBlank(String s)static booleanisNotEmpty(String s)Returns whether the specified string is not empty while remaining null-safe.static Stringjoin(Iterable<?> col, String separator)static StringjoinClassNames(Iterable<?> iterable)static List<String>splitAndTrim(String value, String regex)static BooleantoBoolean(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 Stringtrim(String s)Trims the specified string while remaining null-safe.static StringtrimToNull(String s)Trims the specified string and, if the resulting string is empty, will return null instead.
-
-
-
Method Detail
-
isBlank
public static boolean isBlank(String s)
-
isNotBlank
public static boolean isNotBlank(String s)
-
isEmpty
public static boolean isEmpty(String s)
Returns whether the specified string is empty while remaining null-safe.
- Parameters:
s- the string to be checked (may be null)- Returns:
- true if
sis either null or contains no characters.
-
isNotEmpty
public static boolean isNotEmpty(String s)
Returns whether the specified string is not empty while remaining null-safe.
- Parameters:
s- the string to be checked (may be null)- Returns:
- true if
sis not null and contains at least one character.
-
trim
public static String trim(String s)
Trims the specified string while remaining null-safe.
- Parameters:
s- the string to be trimmed (may be null)- Returns:
- The trimmed
sor null ifsis null.
-
trimToNull
public static String trimToNull(String s)
Trims the specified string and, if the resulting string is empty, will return null instead.
- Parameters:
s- the string to be trimmed (may be null)- Returns:
- The trimmed
sor null ifsis null before or after being trimmed.
-
toBoolean
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
sto in order to determine the bestBooleanrepresentation. Ifsdoes not fall into either category, it is considered invalid and will result in anIllegalArgumentExceptionbeing thrown.- Parameters:
s- the string to be converted into aBoolean- Returns:
- The
Booleanrepresentation ofsor null ifsis null. - Throws:
IllegalArgumentException- Ifsis non-null and does not match any of the predefined values.
-
-