Enum Class I18nConversionCategory

java.lang.Object
java.lang.Enum<I18nConversionCategory>
org.checkerframework.checker.i18nformatter.qual.I18nConversionCategory
All Implemented Interfaces:
Serializable, Comparable<I18nConversionCategory>, Constable

@AnnotatedFor("nullness") public enum I18nConversionCategory extends Enum<I18nConversionCategory>
Elements of this enumeration are used in a I18nFormat annotation to indicate the valid types that may be passed as a format parameter. For example:
@I18nFormat({GENERAL, NUMBER}) String f = "{0}{1, number}";
 MessageFormat.format(f, "Example", 0) // valid
The annotation indicates that the format string requires any object as the first parameter (GENERAL) and a number as the second parameter (NUMBER).
See the Checker Framework Manual:
Internationalization Format String Checker
  • Enum Constant Details

    • UNUSED

      public static final I18nConversionCategory UNUSED
      Use if a parameter is not used by the formatter. For example, in
       MessageFormat.format("{1}", a, b);
       
      only the second argument ("b") is used. The first argument ("a") is ignored.
    • GENERAL

      public static final I18nConversionCategory GENERAL
      Use if the parameter can be of any type.
    • DATE

      public static final I18nConversionCategory DATE
      Use if the parameter can be of date, time, or number types.
    • NUMBER

      public static final I18nConversionCategory NUMBER
      Use if the parameter can be of number or choice types. An example of choice:
      
       format("{0, choice, 0#zero|1#one|1<{0, number} is more than 1}", 2)
       
      This will print "2 is more than 1".
  • Field Details

  • Method Details

    • values

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

      public static I18nConversionCategory valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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 class has no constant with the specified name
      NullPointerException - if the argument is null
    • stringToI18nConversionCategory

      public static I18nConversionCategory stringToI18nConversionCategory(String string)
      Creates a conversion cagetogry from a string name.
       I18nConversionCategory.stringToI18nConversionCategory("number") == I18nConversionCategory.NUMBER;
       
      Returns:
      the I18nConversionCategory associated with the given string
    • isSubsetOf

      public static boolean isSubsetOf(I18nConversionCategory a, I18nConversionCategory b)
      Return true if a is a subset of b.
      Returns:
      true if a is a subset of b
    • intersect

      Returns the intersection of the two given I18nConversionCategories.
       I18nConversionCategory.intersect(DATE, NUMBER) == NUMBER;
       
    • union

      Returns the union of the two given I18nConversionCategories.
       I18nConversionCategory.intersect(DATE, NUMBER) == DATE;
       
    • isAssignableFrom

      public boolean isAssignableFrom(Class<?> argType)
      Returns true if argType can be an argument used by this format specifier.
      Parameters:
      argType - an argument type
      Returns:
      true if argType can be an argument used by this format specifier
    • toString

      public String toString()
      Returns a pretty printed I18nConversionCategory.
      Overrides:
      toString in class Enum<I18nConversionCategory>