Annotation Interface Format


This annotation, attached to a String type, indicates that the String may be passed to Formatter.format and similar methods.

The annotation's value represents the valid arguments that may be passed to the format method. For example:

 @Format({GENERAL, INT}) String f = "String '%s' has length %d";

  String.format(f, "Example", 7);
 
The annotation indicates that the format string requires any Object as the first parameter (ConversionCategory.GENERAL) and an integer as the second parameter (ConversionCategory.INT). The format string accepts any values as additional parameters (because it ignores them).
See Also:
See the Checker Framework Manual:
Format String Checker
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    An array of ConversionCategory, indicating the types of legal remaining arguments when a value of the annotated type is used as the first argument to Formatter.format and similar methods.
  • Element Details

    • value

      An array of ConversionCategory, indicating the types of legal remaining arguments when a value of the annotated type is used as the first argument to Formatter.format and similar methods.
      Returns:
      types that can be used as values when a value of this type is the format string