Class Case

java.lang.Object
ch.tocco.nice2.toolbox.api.string.Case

public class Case extends Object
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 Details

    • uc

      public static String uc(String s)
      Executes String.toUpperCase(Locale.ENGLISH).
    • lc

      public static String lc(String s)
      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

      public static boolean containsIgnoreCase(Iterable<String> haystack, String needle)
      Tells if the iterable contains the string when ignoring case.
      Parameters:
      haystack - Usually a Collection. May be empty, may contain null values.
      needle - In any case, will be compared using equalsIgnoreCase(java.lang.String, java.lang.String).
      Returns:
      true if it is in there.