Skip to main content

Customization Support

Custom Anchors​

Custom anchorsAnchorA marker within generated source code reserved for adding custom logic during re-expansion. are points in the templates where developers can add custom code so that the code is reinserted after re-expanding.

You add a custom anchorAnchorA marker within generated source code reserved for adding custom logic during re-expansion. to the template of an ExpanderExpanderA unit of generation that combines a data tree instance (functional M1 model) with a template to generate an artifact. or Feature by using @custom:{anchor-name}:

base() ::= <<
package <packageName>;

public class <className> {
@custom:fields
}
>>

This will generate a start and end anchorAnchorA marker within generated source code reserved for adding custom logic during re-expansion. to mark where developers can add custom code.

package org.example;

public class MyClass {
// anchor:custom-fields:start
// anchor:custom-fields:end
}
Custom Anchor Names

Custom AnchorAnchorA marker within generated source code reserved for adding custom logic during re-expansion. names should be unique within each ArtifactArtifactA build or deployment result, such as a Docker container image or Java archive, produced by a software project.. When you have a part of the template that reoccurs, you can use interpolation to create a unique name.

E.g. this template contains a custom anchorAnchorA marker within generated source code reserved for adding custom logic during re-expansion. for each fieldFieldA property of a DataElement expanded to a database column and user interface input element. to add annotations:

base() ::= <<
package <packageName>;

public class <className> {
<fields:fieldDeclaration();separator="\n">
}
>>

fieldDeclaration(field) ::= <<
@custom:<field.name>-annotations
private <field.type> <field.name>;
>>