protected <T> T resolveExpression(String expr, Object body, MultiMap<String, String> headers,
MultiMap<String, String> queryParams, MediaType responseContentType) {
if (expr == null) {
return null;
} else if (!expressionEvaluator.isExpression(expr)) {
return (T) expr;
} else {
Map<Object, Object> attributes = new HashMap<>(2);
attributes.put("headers", headers.toImmutableMultiMap());
attributes.put("queryParams", queryParams.toImmutableMultiMap());
BindingContext resultContext = BindingContext.builder()
.addBinding("payload",
new TypedValue(body, DataType.builder().fromObject(body)
.mediaType(responseContentType).build()))
.addBinding("attributes", new TypedValue(attributes, DataType.fromType(Map.class)))
.addBinding("dataType",
new TypedValue(DataType.builder().fromObject(body).mediaType(responseContentType)
.build(), DataType.fromType(DataType.class)))
.build();
return (T) expressionEvaluator.evaluate(expr, DataType.STRING, resultContext).getValue();
}
}