Annotation Interface GenerateTemplate


@Retention(SOURCE) @Target(TYPE) public @interface GenerateTemplate
Annotation for use on CodeDelegate subclasses to create a class body template file during compilation. This relies on the compiler in use allowing the annotation processor to load source files. Add the token values in comments. All lines between PXJ-BEGIN: and PXJ-END: will be copied into the template, excluding the lines containing the template. It is advised to write an ID for the section (eg. body, imports, etc.) after the tokens, but these are not checked in processing.
 invalid input: '{@code
 @GenerateTemplate(Foo.TEMPLATE_PATH)
 class Foo extends CoreCodeDelegate {
 
   final static String TEMPLATE_PATH = "resources/foo.pxj";
  
   // PXJ-BEGIN:body
 
   @Override
   public void update() {
     
   }
 
   // PXJ-END:body
 
 } 
 </pre>'
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Path, relative to the Java source file, to generate the template.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Value of the starting token - PXJ-BEGIN:
    static final String
    Value of the ending token - PXJ-END:
  • Field Details

  • Element Details

    • value

      String value
      Path, relative to the Java source file, to generate the template. The file should usually be given a .pxj extension. It can be stored in a final static field in the class for use in the factory (see main example).
      Returns:
      relative path to template file