Annotation Type PrintFormat


  • @Documented
    @Pattern("(?:[^%]|%%|(?:%(?:\\d+\\$)?(?:[-#+ 0,(<]*)?(?:\\d+)?(?:\\.\\d+)?(?:[tT])?(?:[a-zA-Z%])))*")
    public @interface PrintFormat
    Specifies that the method parameter is a printf-style print format pattern, as described in Formatter.

    Code editors that support Pattern annotation will check the syntax of this value automatically. It could also be especially recognized to check whether the subsequent var-arg arguments match the expected arguments mentioned in the pattern. E. g., consider that the following method is annotated:

    
     void myprintf(@PrintFormat String format, Object... args) {...}
     

    In this case, code editors might recognize that the following call is erroneous, and issue a warning:

    
     myprintf("%d\n", "hello"); // warning: a number expected instead of "hello"
     
    See Also:
    Pattern