Package no.mnemonic.commons.utilities
Class StringUtils
java.lang.Object
no.mnemonic.commons.utilities.StringUtils
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Tests if a string is blank (null, "" or only whitespace).static boolean
Tests if a string is empty (null or "").static boolean
Simple method to test if an input string can be parsed to an integer.static boolean
Simple method to test if an input string can be parsed to an UUID by UUID.fromString().static int
Null-safe operation to determine the length of a string.
-
Method Details
-
isEmpty
Tests if a string is empty (null or "").- Parameters:
str
- String to be tested.- Returns:
- Returns true if a string is null or "".
-
isBlank
Tests if a string is blank (null, "" or only whitespace).- Parameters:
str
- String to be tested.- Returns:
- Returns true if a string is null, "" or only contains whitespace.
-
length
Null-safe operation to determine the length of a string.- Parameters:
str
- String to compute length for.- Returns:
- Returns 0 if 'str' is null, otherwise the length of 'str'.
-
isInteger
Simple method to test if an input string can be parsed to an integer. The input can be negative (with a minus sign immediately prefixing the numbers). No number separators or spaces will be accepted. The method will return true even if the integer string is too large to be represented by a Java Integer or Long. If the method returns true, the input string should be parseable with Integer.parseInt or Long.parseLong with the exception of integer overflow.- Parameters:
str
- string to test- Returns:
- true if string can be parsed to a integer number
-
isUUID
Simple method to test if an input string can be parsed to an UUID by UUID.fromString(). The method will only check the expected format of hexadecimal characters and hyphens, it does not check if the UUID is valid according to UUID version rules. If the method returns true, the input string should be parseable with UUID.fromString()- Parameters:
str
- string to test- Returns:
- true if string can be parsed to a UUID
- See Also:
-