Skip to main content

Features with Default Content

In some cases, you might need some default implementation in an Expander that can be replaced. For this, you add define a feature anchor with some default content:

public void helloWorld() {
@anchor:hello:start
System.out.println("Hello World");
@anchor:hello:end
}

If no Feature adds any content for the anchor, the default content will be used:

public void helloWorld() {
// @anchor:hello:start
System.out.println("Hello World");
// @anchor:hello:end
}

A Feature can define a feature segment like any other:

@hook:hello:start
System.out.println("Hello Universe!");
@hook:hello:end

This will then replace the default content in the expanded artifact:

public void helloWorld() {
// @anchor:hello:start
System.out.println("Hello Universe!");
// @anchor:hello:end
}
note

If multiple segments are inserted in the anchor (e.g. from multiple features), they are concatenated like in a regular feature anchor.