Type-conversion utilities
public static <TO extends Enum<TO>, FROM extends Enum<FROM>> TO convert(Class<TO> toType, FROM value) {
return convert(toType, value, null);
}
public static <TO extends Enum<TO>, FROM extends Enum<FROM>> TO convert(Class<TO> toType, FROM value, TO defaultValue) {
return value == null ? defaultValue : Enum.valueOf(toType, value.name());
}