Skip to content

Commit

Permalink
builder-items will now prevail over the extended environment in Evalu…
Browse files Browse the repository at this point in the history
…ationEnvironmentBuilder#build
  • Loading branch information
BlvckBytes committed Nov 2, 2024
1 parent e9decbb commit b814ccb
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,21 @@ public IEvaluationEnvironment build() {
}

public IEvaluationEnvironment build(@Nullable IEvaluationEnvironment environmentToExtend) {
Map<String, AExpressionFunction> resultingFunctions = new HashMap<>(this.functions);
Map<String, Supplier<?>> resultingLiveVariables = new HashMap<>(this.liveVariables);
Map<String, Object> resultingStaticVariables = new HashMap<>(this.staticVariables);
Map<String, AExpressionFunction> resultingFunctions = new HashMap<>();
Map<String, Supplier<?>> resultingLiveVariables = new HashMap<>();
Map<String, Object> resultingStaticVariables = new HashMap<>();

if (environmentToExtend != null) {
resultingFunctions.putAll(environmentToExtend.getFunctions());
resultingLiveVariables.putAll(environmentToExtend.getLiveVariables());
resultingStaticVariables.putAll(environmentToExtend.getStaticVariables());
}

// Put builder-items last, as to make them prevail over the possibly extended environment
resultingFunctions.putAll(this.functions);
resultingLiveVariables.putAll(this.liveVariables);
resultingStaticVariables.putAll(this.staticVariables);

return new IEvaluationEnvironment() {

@Override
Expand Down

0 comments on commit b814ccb

Please sign in to comment.