Enum LocaleMatcher.Demotion

java.lang.Object
java.lang.Enum<LocaleMatcher.Demotion>
com.ibm.icu.util.LocaleMatcher.Demotion
All Implemented Interfaces:
Serializable, Comparable<LocaleMatcher.Demotion>, java.lang.constant.Constable
Enclosing class:
LocaleMatcher

public static enum LocaleMatcher.Demotion extends Enum<LocaleMatcher.Demotion>
Builder option for whether all desired locales are treated equally or earlier ones are preferred.
See Also:
  • Enum Constant Details

    • NONE

      public static final LocaleMatcher.Demotion NONE
      All desired locales are treated equally.
    • REGION

      public static final LocaleMatcher.Demotion REGION
      Earlier desired locales are preferred.

      From each desired locale to the next, the distance to any supported locale is increased by an additional amount which is at least as large as most region mismatches. A later desired locale has to have a better match with some supported locale due to more than merely having the same region subtag.

      For example: Supported={en, sv} desired=[en-GB, sv] yields Result(en-GB, en) because with the demotion of sv its perfect match is no better than the region distance between the earlier desired locale en-GB and en=en-US.

      Notes:

      • In some cases, language and/or script differences can be as small as the typical region difference. (Example: sr-Latn vs. sr-Cyrl)
      • It is possible for certain region differences to be larger than usual, and larger than the demotion. (As of CLDR 35 there is no such case, but this is possible in future versions of the data.)
  • Method Details

    • values

      public static LocaleMatcher.Demotion[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      Returns:
      an array containing the constants of this enum type, in the order they are declared
    • valueOf

      public static LocaleMatcher.Demotion valueOf(String name)
      Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum type has no constant with the specified name
      NullPointerException - if the argument is null