in bval-jsr/src/main/java/org/apache/bval/jsr/DefaultMessageInterpolator.java [279:321]
private String replaceAnnotationAttributes(final String message, final Map<String, Object> annotationParameters) {
final MessageWithParamsKey key = new MessageWithParamsKey(message, annotationParameters);
String result = interpolations.get(key);
if (result == null) {
final Matcher matcher = MESSAGE_PARAMETER.matcher(message);
if (!matcher.find()) {
result = message;
} else {
final StringBuilder sb = new StringBuilder(64);
int prev = 0;
do {
int start = matcher.start();
String resolvedParameterValue;
String parameter = matcher.group(1);
Object variable = annotationParameters.get(parameter);
if (variable == null) {
resolvedParameterValue = matcher.group();
} else if (Object[].class.isInstance(variable)) {
resolvedParameterValue = Arrays.toString((Object[]) variable);
} else if (variable.getClass().isArray()) {
try {
resolvedParameterValue = (String) getToStringMethod(variable).invoke(null, variable);
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new IllegalStateException("Could not expand array " + variable);
}
} else {
resolvedParameterValue = variable.toString();
}
if (start > prev) {
sb.append(message, prev, start);
}
sb.append(resolvedParameterValue);
prev = matcher.end();
} while (matcher.find());
if (prev < message.length()) {
sb.append(message, prev, message.length());
}
result = sb.toString();
}
interpolations.putIfAbsent(key, result);
}
return result;
}