Package dev.paseto.jpaseto.lang
Class Strings
- java.lang.Object
-
- dev.paseto.jpaseto.lang.Strings
-
public final class Strings extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.CharSequenceclean(java.lang.CharSequence str)static java.lang.Stringclean(java.lang.String str)static booleanhasLength(java.lang.CharSequence str)Check that the given CharSequence is neithernullnor of length 0.static booleanhasText(java.lang.CharSequence str)Check whether the given CharSequence has actual text.static booleanhasText(java.lang.String str)Check whether the given String has actual text.static java.lang.StringtrimWhitespace(java.lang.String str)Trim leading and trailing whitespace from the given String.
-
-
-
Method Detail
-
hasLength
public static boolean hasLength(java.lang.CharSequence str)
Check that the given CharSequence is neithernullnor of length 0. Note: Will returntruefor a CharSequence that purely consists of whitespace.Strings.hasLength(null) = false Strings.hasLength("") = false Strings.hasLength(" ") = true Strings.hasLength("Hello") = true- Parameters:
str- the CharSequence to check (may benull)- Returns:
trueif the CharSequence is not null and has length- See Also:
hasText(String)
-
hasText
public static boolean hasText(java.lang.CharSequence str)
Check whether the given CharSequence has actual text. More specifically, returnstrueif the string notnull, its length is greater than 0, and it contains at least one non-whitespace character.Strings.hasText(null) = false Strings.hasText("") = false Strings.hasText(" ") = false Strings.hasText("12345") = true Strings.hasText(" 12345 ") = true- Parameters:
str- the CharSequence to check (may benull)- Returns:
trueif the CharSequence is notnull, its length is greater than 0, and it does not contain whitespace only- See Also:
Character.isWhitespace(char)
-
hasText
public static boolean hasText(java.lang.String str)
Check whether the given String has actual text. More specifically, returnstrueif the string notnull, its length is greater than 0, and it contains at least one non-whitespace character.- Parameters:
str- the String to check (may benull)- Returns:
trueif the String is notnull, its length is greater than 0, and it does not contain whitespace only- See Also:
hasText(CharSequence)
-
trimWhitespace
public static java.lang.String trimWhitespace(java.lang.String str)
Trim leading and trailing whitespace from the given String.- Parameters:
str- the String to check- Returns:
- the trimmed String
- See Also:
Character.isWhitespace(char)
-
clean
public static java.lang.String clean(java.lang.String str)
-
clean
public static java.lang.CharSequence clean(java.lang.CharSequence str)
-
-