Enum I18nConversionCategory
- java.lang.Object
-
- java.lang.Enum<I18nConversionCategory>
-
- org.checkerframework.checker.i18nformatter.qual.I18nConversionCategory
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Comparable<I18nConversionCategory>
@AnnotatedFor("nullness") public enum I18nConversionCategory extends java.lang.Enum<I18nConversionCategory>
Elements of this enumeration are used in aI18nFormat
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
).
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static I18nConversionCategory
intersect(I18nConversionCategory a, I18nConversionCategory b)
Returns the intersection of the two given I18nConversionCategories.boolean
isAssignableFrom(java.lang.Class<?> argType)
Returns true ifargType
can be an argument used by this format specifier.static boolean
isSubsetOf(I18nConversionCategory a, I18nConversionCategory b)
Return true if a is a subset of b.static I18nConversionCategory
stringToI18nConversionCategory(java.lang.String string)
Creates a conversion cagetogry from a string name.java.lang.String
toString()
Returns a pretty printedI18nConversionCategory
.static I18nConversionCategory
union(I18nConversionCategory a, I18nConversionCategory b)
Returns the union of the two given I18nConversionCategories.static I18nConversionCategory
valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name.static I18nConversionCategory[]
values()
Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
UNUSED
public static final I18nConversionCategory UNUSED
Use if a parameter is not used by the formatter. For example, inMessageFormat.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:
This will print "2 is more than 1".format("{0, choice, 0#zero|1#one|1<{0, number} is more than 1}", 2)
-
-
Method Detail
-
values
public static I18nConversionCategory[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (I18nConversionCategory c : I18nConversionCategory.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static I18nConversionCategory valueOf(java.lang.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:
java.lang.IllegalArgumentException
- if this enum type has no constant with the specified namejava.lang.NullPointerException
- if the argument is null
-
stringToI18nConversionCategory
public static I18nConversionCategory stringToI18nConversionCategory(java.lang.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
public static I18nConversionCategory intersect(I18nConversionCategory a, I18nConversionCategory b)
Returns the intersection of the two given I18nConversionCategories.I18nConversionCategory.intersect(DATE, NUMBER) == NUMBER;
-
union
public static I18nConversionCategory union(I18nConversionCategory a, I18nConversionCategory b)
Returns the union of the two given I18nConversionCategories.I18nConversionCategory.intersect(DATE, NUMBER) == DATE;
-
isAssignableFrom
public boolean isAssignableFrom(java.lang.Class<?> argType)
Returns true ifargType
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 java.lang.String toString()
Returns a pretty printedI18nConversionCategory
.- Overrides:
toString
in classjava.lang.Enum<I18nConversionCategory>
-
-