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 booleancontainsIgnoreCase(Iterable<String> haystack, String needle) Tells if the iterable contains the string when ignoring case.static booleanequalsIgnoreCase(@Nullable String one, @Nullable String two) Same as Java's implementation, but does not use the default Locale.static StringExecutes String.toLowerCase(Locale.ENGLISH).static StringExecutes 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 containnullvalues.needle- In any case, will be compared usingequalsIgnoreCase(java.lang.String, java.lang.String).- Returns:
trueif it is in there.
-