Annotation Type Parameter


  • @Retention(RUNTIME)
    @Target({FIELD,METHOD})
    public @interface Parameter
    This annotation should be placed on templates' fields or methods to indicate that they represent template parameters. It is only mandatory for names, literals, and types, where it avoids having to use TemplateParameter and allows for the direct accesses of the parameters. A parameter is never considered as a templated element and it is not necessary to annotate it with a Local annotation.
    • Optional Element Summary

      Optional Elements 
      Modifier and Type Optional Element Description
      java.lang.String value
      Defines the name of the parameter (optional, mostly to avoid name clashes).
    • Element Detail

      • value

        java.lang.String value
        Defines the name of the parameter (optional, mostly to avoid name clashes). In most cases, the annotation does not have a "value" and the name of a template parameter is the simple name of the annotated field.
         class T extends Template {
                \@Parameter
                CtExpression<String> $i;
        
                String s = $i.S();
         }
         
        However, in rare cases, eg to rename named elements that are in the same scope as the template parameter, such as renaming of fields or nested types, the annotation value is used to set a template parameter name (aka a proxy). In this case: contract 1: if "value" is set, then the template field type must be String contract 2: if a proxy parameter is declared and named "x" (@Parameter("x")), then a type member named "x" must exist (the one to be renamed).
         class T extends Template {
                // this parameter will contain the actual value of the _i_ field's name
                \@Parameter("_i_")
                String __i_;
        
                int _i_; // the field to be renamed
         }
         
        Default:
        ""