Class Case
java.lang.Object
ch.tocco.nice2.toolbox.api.string.Case
Static utility methods for dealing with upper/lower casing in Java when it comes to
comparing Strings for equality. This is for "logical" casing, not i18n.
Reading: http://cafe.elharo.com/blogroll/turkish/
The reason for using a separate class instead of hacking in the commands everywhere is to implicitly document the intention of doing a logical case conversion or comparision, not an i18n one.
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
containsIgnoreCase
(Iterable<String> haystack, String needle) Tells if the iterable contains the string when ignoring case.static boolean
equalsIgnoreCase
(@Nullable String one, @Nullable String two) Same as Java's implementation, but does not use the default Locale.static String
Executes String.toLowerCase(Locale.ENGLISH).static String
Executes String.toUpperCase(Locale.ENGLISH).
-
Method Details
-
uc
Executes String.toUpperCase(Locale.ENGLISH). -
lc
Executes String.toLowerCase(Locale.ENGLISH). -
equalsIgnoreCase
public static boolean equalsIgnoreCase(@Nullable @Nullable String one, @Nullable @Nullable String two) Same as Java's implementation, but does not use the default Locale.If any (or all) of the params are null then the result is false. Because it is considered a mistake to call this method with two null values.
-
containsIgnoreCase
Tells if the iterable contains the string when ignoring case.- Parameters:
haystack
- Usually a Collection. May be empty, may containnull
values.needle
- In any case, will be compared usingequalsIgnoreCase(java.lang.String, java.lang.String)
.- Returns:
true
if it is in there.
-