in src/main/java/org/apache/commons/beanutils2/converters/ColorConverter.java [89:143]
protected <T> T convertToType(final Class<T> type, final Object value) throws Throwable {
if (Color.class.isAssignableFrom(type)) {
final String stringValue = toString(value);
switch (toLowerCase(stringValue)) {
case "black":
return type.cast(Color.BLACK);
case "blue":
return type.cast(Color.BLUE);
case "cyan":
return type.cast(Color.CYAN);
case "darkgray":
case "darkgrey":
case "dark_gray":
case "dark_grey":
return type.cast(Color.DARK_GRAY);
case "gray":
case "grey":
return type.cast(Color.GRAY);
case "green":
return type.cast(Color.GREEN);
case "lightgray":
case "lightgrey":
case "light_gray":
case "light_grey":
return type.cast(Color.LIGHT_GRAY);
case "magenta":
return type.cast(Color.MAGENTA);
case "orange":
return type.cast(Color.ORANGE);
case "pink":
return type.cast(Color.PINK);
case "red":
return type.cast(Color.RED);
case "white":
return type.cast(Color.WHITE);
case "yellow":
return type.cast(Color.YELLOW);
default:
// Do nothing.
}
if (stringValue.startsWith(HEX_COLOR_PREFIX)) {
return type.cast(parseHexadecimalColor(stringValue));
}
if (stringValue.contains(",")) {
return type.cast(parseToStringColor(stringValue));
}
return type.cast(Color.decode(stringValue));
}
throw conversionException(type, value);
}