use of com.devonfw.cobigen.api.to.TemplateTo in project cobigen by devonfw.
the class ConfigurationInterpreterImpl method convertIncrements.
/**
* Converts a {@link List} of {@link Increment}s with their parent {@link Trigger} to a {@link List} of
* {@link IncrementTo}s
*
* @param increments the {@link List} of {@link Increment}s
* @param trigger the parent {@link Trigger}
* @param matchingTriggerIds the {@link List} of matching trigger Id
* @return the {@link List} of {@link IncrementTo}s
*/
// TODO create ToConverter
private List<IncrementTo> convertIncrements(List<Increment> increments, Trigger trigger, List<String> matchingTriggerIds) {
List<IncrementTo> incrementTos = Lists.newLinkedList();
for (Increment increment : increments) {
String triggerId = increment.getTrigger().getId();
if (!triggerId.equals(trigger.getId())) {
// Check if the external trigger also matches
if (!matchingTriggerIds.contains(triggerId)) {
// Abort generation
throw new InvalidConfigurationException("An external incrementRef to " + increment.getTrigger().getId() + "::" + increment.getName() + " is referenced from " + trigger.getId() + " but its trigger does not match");
}
}
List<TemplateTo> templates = Lists.newLinkedList();
for (Template template : increment.getTemplates()) {
templates.add(new TemplateTo(template.getName(), template.getMergeStrategy(), triggerId));
}
incrementTos.add(new IncrementTo(increment.getName(), increment.getDescription(), triggerId, templates, convertIncrements(increment.getDependentIncrements(), trigger, matchingTriggerIds)));
}
return incrementTos;
}
Aggregations