Home | History | Annotate | Download | only in annotation
      1 package javax.annotation;
      2 
      3 import java.lang.annotation.Documented;
      4 import java.lang.annotation.Retention;
      5 import java.lang.annotation.RetentionPolicy;
      6 
      7 import javax.annotation.meta.TypeQualifier;
      8 import javax.annotation.meta.When;
      9 
     10 /**
     11  * This annotation a value that is of a particular syntax, such as Java syntax
     12  * or regular expression syntax. This can be used to provide syntax checking of
     13  * constant values at compile time, run time checking at runtime, and can assist
     14  * IDEs in deciding how to interpret String constants (e.g., should a
     15  * refactoring that renames method x() to y() update the String constant "x()").
     16  *
     17  *
     18  */
     19 @Documented
     20 @TypeQualifier(applicableTo = String.class)
     21 @Retention(RetentionPolicy.RUNTIME)
     22 public @interface Syntax {
     23     /**
     24      * Value indicating the particular syntax denoted by this annotation.
     25      * Different tools will recognize different syntaxes, but some proposed
     26      * canonical values are:
     27      * <ul>
     28      * <li> "Java"
     29      * <li> "RegEx"
     30      * <li> "JavaScript"
     31      * <li> "Ruby"
     32      * <li> "Groovy"
     33      * <li> "SQL"
     34      * <li> "FormatString"
     35      * </ul>
     36      *
     37      * Syntax names can be followed by a colon and a list of key value pairs,
     38      * separated by commas. For example, "SQL:dialect=Oracle,version=2.3". Tools
     39      * should ignore any keys they don't recognize.
     40      */
     41     String value();
     42 
     43     When when() default When.ALWAYS;
     44 }
     45