7.2 Templates

If you want to use the default generator but need to override the templates to generate some additional content, you can make use of the AROUND aspects feature of Xpand to achieve this goal. The following section lists the currently defined Xpand template hooks together with a brief description of the generated content.

For example to add some arbitrary custom annotations to every attribute contained within an entity could be accomplished with the following around advice.

«EXTENSION extensions::Names»
/** 
 * adds the annotation 'FooAnnotation' to every entity attribute
 */
«AROUND *::attribute FOR dom::Attribute»
   «IF dom::Entity.isInstance(eContainer)-»
    @FooAnnotation
    private «getImplementationType()» «name-» «IF dom::ValueObject.isInstance(type.dataType)-» = new «getImplementationType()-»()«ENDIF-»;
   «ELSE-»
     «targetDef.proceed()»
   «ENDIF-»
«ENDAROUND»