Skip to content

Commit

Permalink
add new helper to process map expressions
Browse files Browse the repository at this point in the history
  • Loading branch information
wildone committed Feb 12, 2021
1 parent 2590620 commit 844e61e
Showing 1 changed file with 23 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,29 @@ public void putAll(Map<? extends String, ?> map, Boolean update) { //NOSONAR som
}
}


/**
* evaluate expression values in a map and return all that were evaluated as expressions
*/
@SuppressWarnings({"squid:S3776"})
public static Map<String, String> mapEvaluateAllExpressionValues(Map<String, String> source, Map<String, Object> contextMap) {

JexlEngine jexl = new JexlBuilder().create();
JxltEngine jxlt = jexl.createJxltEngine();
JexlContext jc = new MapContext(contextMap);

//get all entries that have an expression as value
return source.entrySet()
.stream()
.filter(entry -> isStringRegex(entry.getValue()))
.collect(
Collectors.toMap(
Entry::getKey,
e -> (String)evaluateExpressionWithValue(jxlt, jc, e.getValue(), "")
)
);

}
/**
* evaluate expression values in component properties that have value as expression
*/
Expand Down

0 comments on commit 844e61e

Please sign in to comment.