BigDecimalJavaType and BigIntegerJavaType should support conversion to String

This commit is contained in:
Gavin 2022-12-29 21:48:53 +01:00 committed by Gavin King
parent b4b8e955f8
commit c829c84d55
2 changed files with 12 additions and 0 deletions

View File

@ -73,6 +73,9 @@ public class BigDecimalJavaType extends AbstractClassJavaType<BigDecimal> {
if ( Float.class.isAssignableFrom( type ) ) {
return (X) Float.valueOf( value.floatValue() );
}
if ( String.class.isAssignableFrom( type ) ) {
return (X) value.toString();
}
throw unknownUnwrap( type );
}
@ -89,6 +92,9 @@ public class BigDecimalJavaType extends AbstractClassJavaType<BigDecimal> {
if ( value instanceof Number ) {
return BigDecimal.valueOf( ( (Number) value ).doubleValue() );
}
if ( value instanceof String ) {
return new BigDecimal( (String) value );
}
throw unknownWrap( value.getClass() );
}

View File

@ -71,6 +71,9 @@ public class BigIntegerJavaType extends AbstractClassJavaType<BigInteger> {
if ( Float.class.isAssignableFrom( type ) ) {
return (X) Float.valueOf( value.floatValue() );
}
if ( String.class.isAssignableFrom( type ) ) {
return (X) value.toString();
}
throw unknownUnwrap( type );
}
@ -88,6 +91,9 @@ public class BigIntegerJavaType extends AbstractClassJavaType<BigInteger> {
if ( value instanceof Number ) {
return BigInteger.valueOf( ( (Number) value ).longValue() );
}
if ( value instanceof String ) {
return new BigInteger( (String) value );
}
throw unknownWrap( value.getClass() );
}