-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
NOTE : This is an issue specifically for JavaCommons-core : https://github.com/picoded/JavaCommons-core
GenericConvertValue introduced into core package, creates a whole set of unexpected behaviour when used with GenericConvert library, where it resorts to the fallback method of converting it into a giant JSON string (for example).
Point is, GenericConvert should defer to the GenericConvertValue implementation where possible.
For example the following changes should be done for toString()
original
public static String toString(Object input, Object fallbck) {
if (input == null) {
if (fallbck == null) {
return null;
}
return toString(fallbck, null);
}
// Output as string directly
if (input instanceof String) {
return input.toString();
}
return ConvertJSON.fromObject(input);
}
to the following
public static String toString(Object input, Object fallbck) {
if (input == null) {
if (fallbck == null) {
return null;
}
return toString(fallbck, null);
}
// GenericConvertValue optimization
if( input instanceof GenericConvertValue ) {
return toString( ((GenericConvertValue)input).getString(), fallbck );
}
// Output as string directly
if (input instanceof String) {
return input.toString();
}
return ConvertJSON.fromObject(input);
}
This changes need to apply to ALL generic convert function
Metadata
Metadata
Assignees
Labels
No labels