java.lang.Object
is.codion.common.utilities.Text
A utility class for working with text, such as collating and padding.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final PropertyValue<String> Specifies the default collator locale language. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<T> Sorts the given list in place, comparing the string representations of the list contents using the space aware collator.static <T> Comparator<T> collator()Returns a Comparator which compares the string representations of the objects using the Collator for theCOLLATOR_LANGUAGElanguage, taking spaces into account.static <T> Comparator<T> Creates a Comparator which compares the string representations of the objects using the Collator for the given locale, taking spaces into account.static StringLeft pads the given string with the given pad character until a length oflengthhas been reachedstatic booleannullOrEmpty(@Nullable String string) Returns true if the given string is null or empty.static booleannullOrEmpty(@Nullable String... strings) Returns true if any of the given strings is null or empty.Splits and trims the given comma separated string.static StringRight pads the given string with the given pad character until a length oflengthhas been reached
-
Field Details
-
COLLATOR_LANGUAGE
Specifies the default collator locale language.- Value type: String
- Default value:
Locale.getDefault().getLanguage().
- See Also:
-
-
Method Details
-
collate
Sorts the given list in place, comparing the string representations of the list contents using the space aware collator.- Type Parameters:
T- the list element type- Parameters:
values- the list to sort (collate)- Returns:
- the given list, sorted in place
- See Also:
-
collator
Returns a Comparator which compares the string representations of the objects using the Collator for theCOLLATOR_LANGUAGElanguage, taking spaces into account.Note that the collator language is captured on first use; changing
COLLATOR_LANGUAGEafterwards has no effect.- Type Parameters:
T- the type of the objects to compare- Returns:
- a space aware collator
- See Also:
-
collator
Creates a Comparator which compares the string representations of the objects using the Collator for the given locale, taking spaces into account.- Type Parameters:
T- the type of the objects to compare- Parameters:
locale- the collator locale- Returns:
- a space aware collator
-
rightPad
Right pads the given string with the given pad character until a length oflengthhas been reached- Parameters:
string- the string to padlength- the desired lengthpadChar- the character to use for padding- Returns:
- the padded string
-
leftPad
Left pads the given string with the given pad character until a length oflengthhas been reached- Parameters:
string- the string to padlength- the desired lengthpadChar- the character to use for padding- Returns:
- the padded string
-
parseCSV
Splits and trims the given comma separated string. Returns an empty list in case of null or empty string argument. Empty segments are dropped, so"a,,b"yields[a, b].- Parameters:
csv- a String with comma separated values- Returns:
- the trimmed values
-
nullOrEmpty
Returns true if the given string is null or empty.- Parameters:
string- the string to check- Returns:
- true if the given string is null or empty, false otherwise
-
nullOrEmpty
Returns true if any of the given strings is null or empty.- Parameters:
strings- the strings to check- Returns:
- true if one of the given strings is null or empty or if no arguments are provided, false otherwise
-