Annotation Type Format


  • @Documented
    @Retention(RUNTIME)
    @Target({TYPE_USE,TYPE_PARAMETER})
    @SubtypeOf(UnknownFormat.class)
    public @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:
    ConversionCategory
    See the Checker Framework Manual:
    Format String Checker
    • Required Element Summary

      Required Elements 
      Modifier and Type Required Element Description
      ConversionCategory[] 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.
    • Element Detail

      • value

        ConversionCategory[] 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