Skip to content

Commit

Permalink
devonfw#1696: fixed ContextConfiguration merge
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-vcapgemini committed Aug 10, 2023
1 parent 9d6b1f2 commit ca2d7db
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import java.math.BigDecimal;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

Expand All @@ -21,7 +22,7 @@ public class ContextConfiguration {
/**
* All available {@link Trigger}s
*/
private Map<String, Trigger> triggers;
private Map<String, Trigger> triggers = new HashMap<>();

/**
* Path of the configuration. Might point to a folder or a jar or maybe even something different in future.
Expand Down Expand Up @@ -80,12 +81,17 @@ public Trigger getTrigger(String id) {

/**
* Merges another context configuration into _this_ context configuration instance
*
*
* @param contextConfiguration to be merged
*/
public ContextConfiguration merge(ContextConfiguration contextConfiguration) {

triggers.putAll(contextConfiguration.triggers);
List<Trigger> contextTriggers = contextConfiguration.getTriggers();
Map<String, Trigger> triggerMap = new HashMap<>();
for (Trigger trigger : contextTriggers) {
triggerMap.put(trigger.getId(), trigger);
}
triggers.putAll(triggerMap);
return this;
}
}

0 comments on commit ca2d7db

Please sign in to comment.