Customizing the Generated Code
Each element of the generated code uses a specific annotation in order to distinguish generated code from custom code.
The custom code can be added at the bottom of the class, after the generated code.
For example, custom imports need to be added outside the block <generated-imports>.
// <generated-imports>
...
// </generated-imports>
import java.util.Map;
@Generated(value = "DomGenerator")
public interface Plant extends DbDomObject {
@GeneratedMethod
List<Activity> getActivities();
...
/**
* @return the sum of the activities duration that are using this plant
*/
Double getDurationInHours();
}
// <generated-imports>
...
// </generated-imports>
import java.util.Map;
@Generated("DomGenerator")
public class PlantImpl extends DbDomObjectImpl implements Plant {
@GeneratedField
protected List<Activity> activities;
...
@Override
@GeneratedMethod
public List<Activity> getActivities() {
return this.activities;
}
...
/**
* @return the sum of the activities duration that are using this plant
*/
@Override
public Double getDurationInHours() {
return getActivities().stream().mapToDouble(Activity::getDurationInHours).sum();
}
}