use instanceof instead of isInstance() on the hot path
surely NBD, but such an easy thing to fix and remove all doubt
This commit is contained in:
parent
6c83e1d0ec
commit
e79d7efbce
|
@ -110,7 +110,7 @@ public class BlobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Blob
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ( BinaryStream.class.isAssignableFrom( type ) ) {
|
if ( BinaryStream.class.isAssignableFrom( type ) ) {
|
||||||
if ( BlobImplementer.class.isInstance( value ) ) {
|
if (value instanceof BlobImplementer) {
|
||||||
// if the incoming Blob is a wrapper, just pass along its BinaryStream
|
// if the incoming Blob is a wrapper, just pass along its BinaryStream
|
||||||
return (X) ( (BlobImplementer) value ).getUnderlyingStream();
|
return (X) ( (BlobImplementer) value ).getUnderlyingStream();
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ public class BlobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Blob
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( byte[].class.isAssignableFrom( type )) {
|
else if ( byte[].class.isAssignableFrom( type )) {
|
||||||
if ( BlobImplementer.class.isInstance( value ) ) {
|
if (value instanceof BlobImplementer) {
|
||||||
// if the incoming Blob is a wrapper, just grab the bytes from its BinaryStream
|
// if the incoming Blob is a wrapper, just grab the bytes from its BinaryStream
|
||||||
return (X) ( (BlobImplementer) value ).getUnderlyingStream().getBytes();
|
return (X) ( (BlobImplementer) value ).getUnderlyingStream().getBytes();
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ public class BlobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Blob
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (Blob.class.isAssignableFrom( type )) {
|
else if (Blob.class.isAssignableFrom( type )) {
|
||||||
final Blob blob = WrappedBlob.class.isInstance( value )
|
final Blob blob = value instanceof WrappedBlob
|
||||||
? ( (WrappedBlob) value ).getWrappedBlob()
|
? ( (WrappedBlob) value ).getWrappedBlob()
|
||||||
: value;
|
: value;
|
||||||
return (X) blob;
|
return (X) blob;
|
||||||
|
|
|
@ -85,18 +85,18 @@ public class BooleanJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<B
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Boolean.class.isInstance( value ) ) {
|
if (value instanceof Boolean) {
|
||||||
return (Boolean) value;
|
return (Boolean) value;
|
||||||
}
|
}
|
||||||
if ( Number.class.isInstance( value ) ) {
|
if (value instanceof Number) {
|
||||||
final int intValue = ( (Number) value ).intValue();
|
final int intValue = ( (Number) value ).intValue();
|
||||||
return intValue != 0;
|
return intValue != 0;
|
||||||
}
|
}
|
||||||
if ( Character.class.isInstance( value ) ) {
|
if (value instanceof Character) {
|
||||||
return isTrue( (Character) value );
|
return isTrue( (Character) value );
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if (value instanceof String) {
|
||||||
return isTrue((String) value);
|
return isTrue( (String) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,16 +100,16 @@ public class ByteArrayJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Byte[].class.isInstance( value ) ) {
|
if (value instanceof Byte[]) {
|
||||||
return (Byte[]) value;
|
return (Byte[]) value;
|
||||||
}
|
}
|
||||||
if ( byte[].class.isInstance( value ) ) {
|
if (value instanceof byte[]) {
|
||||||
return wrapBytes( (byte[]) value );
|
return wrapBytes( (byte[]) value );
|
||||||
}
|
}
|
||||||
if ( InputStream.class.isInstance( value ) ) {
|
if (value instanceof InputStream) {
|
||||||
return wrapBytes( DataHelper.extractBytes( (InputStream) value ) );
|
return wrapBytes( DataHelper.extractBytes( (InputStream) value ) );
|
||||||
}
|
}
|
||||||
if ( Blob.class.isInstance( value ) || DataHelper.isNClob( value.getClass() ) ) {
|
if ( value instanceof Blob || DataHelper.isNClob( value.getClass() ) ) {
|
||||||
try {
|
try {
|
||||||
return wrapBytes( DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() ) );
|
return wrapBytes( DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,11 +120,11 @@ public class CalendarDateJavaTypeDescriptor extends AbstractTemporalJavaTypeDesc
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Calendar.class.isInstance( value ) ) {
|
if (value instanceof Calendar) {
|
||||||
return (Calendar) value;
|
return (Calendar) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! Date.class.isInstance( value ) ) {
|
if ( !(value instanceof Date)) {
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,11 +136,11 @@ public class CalendarJavaTypeDescriptor extends AbstractTemporalJavaTypeDescript
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Calendar.class.isInstance( value ) ) {
|
if (value instanceof Calendar) {
|
||||||
return (Calendar) value;
|
return (Calendar) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! java.util.Date.class.isInstance( value ) ) {
|
if ( !(value instanceof java.util.Date)) {
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,11 +120,11 @@ public class CalendarTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDesc
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Calendar.class.isInstance( value ) ) {
|
if (value instanceof Calendar) {
|
||||||
return (Calendar) value;
|
return (Calendar) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! Date.class.isInstance( value ) ) {
|
if ( !(value instanceof Date)) {
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,16 +81,16 @@ public class CharacterArrayJavaTypeDescriptor extends AbstractClassJavaTypeDescr
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Character[].class.isInstance( value ) ) {
|
if (value instanceof Character[]) {
|
||||||
return (Character[]) value;
|
return (Character[]) value;
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if (value instanceof String) {
|
||||||
return wrapChars( ( (String) value ).toCharArray() );
|
return wrapChars( ( (String) value ).toCharArray() );
|
||||||
}
|
}
|
||||||
if ( Clob.class.isInstance( value ) ) {
|
if (value instanceof Clob) {
|
||||||
return wrapChars( DataHelper.extractString( ( (Clob) value ) ).toCharArray() );
|
return wrapChars( DataHelper.extractString( ( (Clob) value ) ).toCharArray() );
|
||||||
}
|
}
|
||||||
if ( Reader.class.isInstance( value ) ) {
|
if (value instanceof Reader) {
|
||||||
return wrapChars( DataHelper.extractString( (Reader) value ).toCharArray() );
|
return wrapChars( DataHelper.extractString( (Reader) value ).toCharArray() );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -59,14 +59,14 @@ public class CharacterJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Character.class.isInstance( value ) ) {
|
if (value instanceof Character) {
|
||||||
return (Character) value;
|
return (Character) value;
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if (value instanceof String) {
|
||||||
final String str = (String) value;
|
final String str = (String) value;
|
||||||
return str.charAt( 0 );
|
return str.charAt( 0 );
|
||||||
}
|
}
|
||||||
if ( Number.class.isInstance( value ) ) {
|
if (value instanceof Number) {
|
||||||
final Number nbr = (Number) value;
|
final Number nbr = (Number) value;
|
||||||
return (char) nbr.shortValue();
|
return (char) nbr.shortValue();
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,10 +56,10 @@ public class ClassJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Cla
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Class.class.isInstance( value ) ) {
|
if (value instanceof Class) {
|
||||||
return (Class) value;
|
return (Class) value;
|
||||||
}
|
}
|
||||||
if ( CharSequence.class.isInstance( value ) ) {
|
if (value instanceof CharSequence) {
|
||||||
return fromString( (CharSequence) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -97,7 +97,7 @@ public class ClobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Clob
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( String.class.isAssignableFrom( type ) ) {
|
else if ( String.class.isAssignableFrom( type ) ) {
|
||||||
if ( ClobImplementer.class.isInstance( value ) ) {
|
if (value instanceof ClobImplementer) {
|
||||||
// if the incoming Clob is a wrapper, just grab the bytes from its BinaryStream
|
// if the incoming Clob is a wrapper, just grab the bytes from its BinaryStream
|
||||||
return (X) ( (ClobImplementer) value ).getUnderlyingStream().asString();
|
return (X) ( (ClobImplementer) value ).getUnderlyingStream().asString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class CurrencyJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if (value instanceof String) {
|
||||||
return Currency.getInstance( (String) value );
|
return Currency.getInstance( (String) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -115,19 +115,19 @@ public class DateJavaTypeDescriptor extends AbstractTemporalJavaTypeDescriptor<D
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( java.sql.Date.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Date.class.isAssignableFrom( type ) ) {
|
||||||
final java.sql.Date rtn = java.sql.Date.class.isInstance( value )
|
final java.sql.Date rtn = value instanceof java.sql.Date
|
||||||
? ( java.sql.Date ) value
|
? ( java.sql.Date ) value
|
||||||
: new java.sql.Date( value.getTime() );
|
: new java.sql.Date( value.getTime() );
|
||||||
return (X) rtn;
|
return (X) rtn;
|
||||||
}
|
}
|
||||||
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Time.class.isAssignableFrom( type ) ) {
|
||||||
final java.sql.Time rtn = java.sql.Time.class.isInstance( value )
|
final java.sql.Time rtn = value instanceof java.sql.Time
|
||||||
? ( java.sql.Time ) value
|
? ( java.sql.Time ) value
|
||||||
: new java.sql.Time( value.getTime() );
|
: new java.sql.Time( value.getTime() );
|
||||||
return (X) rtn;
|
return (X) rtn;
|
||||||
}
|
}
|
||||||
if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
|
if ( java.sql.Timestamp.class.isAssignableFrom( type ) ) {
|
||||||
final java.sql.Timestamp rtn = java.sql.Timestamp.class.isInstance( value )
|
final java.sql.Timestamp rtn = value instanceof Timestamp
|
||||||
? ( java.sql.Timestamp ) value
|
? ( java.sql.Timestamp ) value
|
||||||
: new java.sql.Timestamp( value.getTime() );
|
: new java.sql.Timestamp( value.getTime() );
|
||||||
return (X) rtn;
|
return (X) rtn;
|
||||||
|
@ -150,15 +150,15 @@ public class DateJavaTypeDescriptor extends AbstractTemporalJavaTypeDescriptor<D
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Date.class.isInstance( value ) ) {
|
if (value instanceof Date) {
|
||||||
return (Date) value;
|
return (Date) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Long.class.isInstance( value ) ) {
|
if (value instanceof Long) {
|
||||||
return new Date( (Long) value );
|
return new Date( (Long) value );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Calendar.class.isInstance( value ) ) {
|
if (value instanceof Calendar) {
|
||||||
return new Date( ( (Calendar) value ).getTimeInMillis() );
|
return new Date( ( (Calendar) value ).getTimeInMillis() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,9 @@ public class DoubleJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Do
|
||||||
if ( Double.class.isAssignableFrom( type ) ) {
|
if ( Double.class.isAssignableFrom( type ) ) {
|
||||||
return (X) value;
|
return (X) value;
|
||||||
}
|
}
|
||||||
|
if ( Float.class.isAssignableFrom( type ) ) {
|
||||||
|
return (X) Float.valueOf( value.floatValue() );
|
||||||
|
}
|
||||||
if ( Byte.class.isAssignableFrom( type ) ) {
|
if ( Byte.class.isAssignableFrom( type ) ) {
|
||||||
return (X) Byte.valueOf( value.byteValue() );
|
return (X) Byte.valueOf( value.byteValue() );
|
||||||
}
|
}
|
||||||
|
@ -65,9 +68,6 @@ public class DoubleJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Do
|
||||||
if ( Long.class.isAssignableFrom( type ) ) {
|
if ( Long.class.isAssignableFrom( type ) ) {
|
||||||
return (X) Long.valueOf( value.longValue() );
|
return (X) Long.valueOf( value.longValue() );
|
||||||
}
|
}
|
||||||
if ( Float.class.isAssignableFrom( type ) ) {
|
|
||||||
return (X) Float.valueOf( value.floatValue() );
|
|
||||||
}
|
|
||||||
if ( BigInteger.class.isAssignableFrom( type ) ) {
|
if ( BigInteger.class.isAssignableFrom( type ) ) {
|
||||||
return (X) BigInteger.valueOf( value.longValue() );
|
return (X) BigInteger.valueOf( value.longValue() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,11 +106,11 @@ public class DurationJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Duration.class.isInstance( value ) ) {
|
if (value instanceof Duration) {
|
||||||
return (Duration) value;
|
return (Duration) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( BigDecimal.class.isInstance( value ) ) {
|
if (value instanceof BigDecimal) {
|
||||||
BigDecimal[] secondsAndNanos =
|
BigDecimal[] secondsAndNanos =
|
||||||
((BigDecimal) value).divideAndRemainder( BigDecimal.ONE );
|
((BigDecimal) value).divideAndRemainder( BigDecimal.ONE );
|
||||||
return Duration.ofSeconds(
|
return Duration.ofSeconds(
|
||||||
|
@ -123,11 +123,11 @@ public class DurationJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Long.class.isInstance( value ) ) {
|
if (value instanceof Long) {
|
||||||
return Duration.ofNanos( (Long) value );
|
return Duration.ofNanos( (Long) value );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( String.class.isInstance( value ) ) {
|
if (value instanceof String) {
|
||||||
return Duration.parse( (String) value );
|
return Duration.parse( (String) value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,9 @@ public class FloatTypeDescriptor extends AbstractClassJavaTypeDescriptor<Float>
|
||||||
if ( Float.class.isAssignableFrom( type ) ) {
|
if ( Float.class.isAssignableFrom( type ) ) {
|
||||||
return (X) value;
|
return (X) value;
|
||||||
}
|
}
|
||||||
|
if ( Double.class.isAssignableFrom( type ) ) {
|
||||||
|
return (X) Double.valueOf( value.doubleValue() );
|
||||||
|
}
|
||||||
if ( Byte.class.isAssignableFrom( type ) ) {
|
if ( Byte.class.isAssignableFrom( type ) ) {
|
||||||
return (X) Byte.valueOf( value.byteValue() );
|
return (X) Byte.valueOf( value.byteValue() );
|
||||||
}
|
}
|
||||||
|
@ -64,9 +67,6 @@ public class FloatTypeDescriptor extends AbstractClassJavaTypeDescriptor<Float>
|
||||||
if ( Long.class.isAssignableFrom( type ) ) {
|
if ( Long.class.isAssignableFrom( type ) ) {
|
||||||
return (X) Long.valueOf( value.longValue() );
|
return (X) Long.valueOf( value.longValue() );
|
||||||
}
|
}
|
||||||
if ( Double.class.isAssignableFrom( type ) ) {
|
|
||||||
return (X) Double.valueOf( value.doubleValue() );
|
|
||||||
}
|
|
||||||
if ( BigInteger.class.isAssignableFrom( type ) ) {
|
if ( BigInteger.class.isAssignableFrom( type ) ) {
|
||||||
return (X) BigInteger.valueOf( value.longValue() );
|
return (X) BigInteger.valueOf( value.longValue() );
|
||||||
}
|
}
|
||||||
|
@ -83,13 +83,13 @@ public class FloatTypeDescriptor extends AbstractClassJavaTypeDescriptor<Float>
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Float.class.isInstance( value ) ) {
|
if (value instanceof Float) {
|
||||||
return (Float) value;
|
return (Float) value;
|
||||||
}
|
}
|
||||||
if ( Number.class.isInstance( value ) ) {
|
if (value instanceof Number) {
|
||||||
return ( (Number) value ).floatValue();
|
return ( (Number) value ).floatValue();
|
||||||
}
|
}
|
||||||
else if ( String.class.isInstance( value ) ) {
|
else if (value instanceof String) {
|
||||||
return Float.valueOf( ( (String) value ) );
|
return Float.valueOf( ( (String) value ) );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -71,10 +71,10 @@ public class InetAddressJavaTypeDescriptor extends AbstractClassJavaTypeDescript
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( InetAddress.class.isInstance( value ) ) {
|
if (value instanceof InetAddress) {
|
||||||
return (InetAddress) value;
|
return (InetAddress) value;
|
||||||
}
|
}
|
||||||
if ( byte[].class.isInstance( value ) ) {
|
if (value instanceof byte[]) {
|
||||||
try {
|
try {
|
||||||
return InetAddress.getByAddress( (byte[]) value );
|
return InetAddress.getByAddress( (byte[]) value );
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ public class InetAddressJavaTypeDescriptor extends AbstractClassJavaTypeDescript
|
||||||
throw new IllegalArgumentException( e );
|
throw new IllegalArgumentException( e );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if (value instanceof String) {
|
||||||
try {
|
try {
|
||||||
return InetAddress.getByName( (String) value );
|
return InetAddress.getByName( (String) value );
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,13 +80,13 @@ public class IntegerJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<I
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Integer.class.isInstance( value ) ) {
|
if (value instanceof Integer) {
|
||||||
return (Integer) value;
|
return (Integer) value;
|
||||||
}
|
}
|
||||||
if ( Number.class.isInstance( value ) ) {
|
if (value instanceof Number) {
|
||||||
return ( (Number) value ).intValue();
|
return ( (Number) value ).intValue();
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if (value instanceof String) {
|
||||||
return Integer.valueOf( ( (String) value ) );
|
return Integer.valueOf( ( (String) value ) );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -120,11 +120,11 @@ public class LocalDateJavaTypeDescriptor extends AbstractTemporalJavaTypeDescrip
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( LocalDate.class.isInstance( value ) ) {
|
if (value instanceof LocalDate) {
|
||||||
return (LocalDate) value;
|
return (LocalDate) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Timestamp.class.isInstance( value ) ) {
|
if (value instanceof Timestamp) {
|
||||||
final Timestamp ts = (Timestamp) value;
|
final Timestamp ts = (Timestamp) value;
|
||||||
/*
|
/*
|
||||||
* Workaround for HHH-13266 (JDK-8061577).
|
* Workaround for HHH-13266 (JDK-8061577).
|
||||||
|
@ -136,18 +136,18 @@ public class LocalDateJavaTypeDescriptor extends AbstractTemporalJavaTypeDescrip
|
||||||
return ts.toLocalDateTime().toLocalDate();
|
return ts.toLocalDateTime().toLocalDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Long.class.isInstance( value ) ) {
|
if (value instanceof Long) {
|
||||||
final Instant instant = Instant.ofEpochMilli( (Long) value );
|
final Instant instant = Instant.ofEpochMilli( (Long) value );
|
||||||
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalDate();
|
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Calendar.class.isInstance( value ) ) {
|
if (value instanceof Calendar) {
|
||||||
final Calendar calendar = (Calendar) value;
|
final Calendar calendar = (Calendar) value;
|
||||||
return LocalDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() ).toLocalDate();
|
return LocalDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() ).toLocalDate();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Date.class.isInstance( value ) ) {
|
if (value instanceof Date) {
|
||||||
if ( java.sql.Date.class.isInstance( value ) ) {
|
if (value instanceof java.sql.Date) {
|
||||||
return ((java.sql.Date) value).toLocalDate();
|
return ((java.sql.Date) value).toLocalDate();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -123,11 +123,11 @@ public class LocalDateTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDes
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( LocalDateTime.class.isInstance( value ) ) {
|
if (value instanceof LocalDateTime) {
|
||||||
return (LocalDateTime) value;
|
return (LocalDateTime) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Timestamp.class.isInstance( value ) ) {
|
if (value instanceof Timestamp) {
|
||||||
final Timestamp ts = (Timestamp) value;
|
final Timestamp ts = (Timestamp) value;
|
||||||
/*
|
/*
|
||||||
* Workaround for HHH-13266 (JDK-8061577).
|
* Workaround for HHH-13266 (JDK-8061577).
|
||||||
|
@ -139,17 +139,17 @@ public class LocalDateTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDes
|
||||||
return ts.toLocalDateTime();
|
return ts.toLocalDateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Long.class.isInstance( value ) ) {
|
if (value instanceof Long) {
|
||||||
final Instant instant = Instant.ofEpochMilli( (Long) value );
|
final Instant instant = Instant.ofEpochMilli( (Long) value );
|
||||||
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() );
|
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Calendar.class.isInstance( value ) ) {
|
if (value instanceof Calendar) {
|
||||||
final Calendar calendar = (Calendar) value;
|
final Calendar calendar = (Calendar) value;
|
||||||
return LocalDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
|
return LocalDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Date.class.isInstance( value ) ) {
|
if (value instanceof Date) {
|
||||||
final Timestamp ts = (Timestamp) value;
|
final Timestamp ts = (Timestamp) value;
|
||||||
final Instant instant = Instant.ofEpochMilli( ts.getTime() );
|
final Instant instant = Instant.ofEpochMilli( ts.getTime() );
|
||||||
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() );
|
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() );
|
||||||
|
|
|
@ -119,26 +119,26 @@ public class LocalTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDescrip
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( LocalTime.class.isInstance( value ) ) {
|
if (value instanceof LocalTime) {
|
||||||
return (LocalTime) value;
|
return (LocalTime) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Timestamp.class.isInstance( value ) ) {
|
if (value instanceof Timestamp) {
|
||||||
final Timestamp ts = (Timestamp) value;
|
final Timestamp ts = (Timestamp) value;
|
||||||
return LocalDateTime.ofInstant( ts.toInstant(), ZoneId.systemDefault() ).toLocalTime();
|
return LocalDateTime.ofInstant( ts.toInstant(), ZoneId.systemDefault() ).toLocalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Long.class.isInstance( value ) ) {
|
if (value instanceof Long) {
|
||||||
final Instant instant = Instant.ofEpochMilli( (Long) value );
|
final Instant instant = Instant.ofEpochMilli( (Long) value );
|
||||||
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalTime();
|
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Calendar.class.isInstance( value ) ) {
|
if (value instanceof Calendar) {
|
||||||
final Calendar calendar = (Calendar) value;
|
final Calendar calendar = (Calendar) value;
|
||||||
return LocalDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() ).toLocalTime();
|
return LocalDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() ).toLocalTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Date.class.isInstance( value ) ) {
|
if (value instanceof Date) {
|
||||||
final Date ts = (Date) value;
|
final Date ts = (Date) value;
|
||||||
final Instant instant = Instant.ofEpochMilli( ts.getTime() );
|
final Instant instant = Instant.ofEpochMilli( ts.getTime() );
|
||||||
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalTime();
|
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalTime();
|
||||||
|
|
|
@ -101,7 +101,7 @@ public class LocaleJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Lo
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( CharSequence.class.isInstance( value ) ) {
|
if (value instanceof CharSequence) {
|
||||||
return fromString( (CharSequence) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -92,7 +92,7 @@ public class NClobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<NCl
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ( CharacterStream.class.isAssignableFrom( type ) ) {
|
if ( CharacterStream.class.isAssignableFrom( type ) ) {
|
||||||
if ( NClobImplementer.class.isInstance( value ) ) {
|
if (value instanceof NClobImplementer) {
|
||||||
// if the incoming NClob is a wrapper, just pass along its BinaryStream
|
// if the incoming NClob is a wrapper, just pass along its BinaryStream
|
||||||
return (X) ( (NClobImplementer) value ).getUnderlyingStream();
|
return (X) ( (NClobImplementer) value ).getUnderlyingStream();
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class NClobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<NCl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (NClob.class.isAssignableFrom( type )) {
|
else if (NClob.class.isAssignableFrom( type )) {
|
||||||
final NClob nclob = WrappedNClob.class.isInstance( value )
|
final NClob nclob = value instanceof WrappedNClob
|
||||||
? ( (WrappedNClob) value ).getWrappedNClob()
|
? ( (WrappedNClob) value ).getWrappedNClob()
|
||||||
: value;
|
: value;
|
||||||
return (X) nclob;
|
return (X) nclob;
|
||||||
|
|
|
@ -81,7 +81,7 @@ public class ObjectArrayJavaTypeDescriptor extends AbstractClassJavaTypeDescript
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Object[].class.isInstance( value ) ) {
|
if (value instanceof Object[]) {
|
||||||
return (Object[]) value;
|
return (Object[]) value;
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -155,16 +155,16 @@ public class OffsetDateTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDe
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( OffsetDateTime.class.isInstance( value ) ) {
|
if (value instanceof OffsetDateTime) {
|
||||||
return (OffsetDateTime) value;
|
return (OffsetDateTime) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ZonedDateTime.class.isInstance( value ) ) {
|
if (value instanceof ZonedDateTime) {
|
||||||
ZonedDateTime zonedDateTime = (ZonedDateTime) value;
|
ZonedDateTime zonedDateTime = (ZonedDateTime) value;
|
||||||
return OffsetDateTime.of( zonedDateTime.toLocalDateTime(), zonedDateTime.getOffset() );
|
return OffsetDateTime.of( zonedDateTime.toLocalDateTime(), zonedDateTime.getOffset() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Timestamp.class.isInstance( value ) ) {
|
if (value instanceof Timestamp) {
|
||||||
final Timestamp ts = (Timestamp) value;
|
final Timestamp ts = (Timestamp) value;
|
||||||
/*
|
/*
|
||||||
* This works around two bugs:
|
* This works around two bugs:
|
||||||
|
@ -184,16 +184,16 @@ public class OffsetDateTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDe
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Date.class.isInstance( value ) ) {
|
if (value instanceof Date) {
|
||||||
final Date date = (Date) value;
|
final Date date = (Date) value;
|
||||||
return OffsetDateTime.ofInstant( date.toInstant(), ZoneId.systemDefault() );
|
return OffsetDateTime.ofInstant( date.toInstant(), ZoneId.systemDefault() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Long.class.isInstance( value ) ) {
|
if (value instanceof Long) {
|
||||||
return OffsetDateTime.ofInstant( Instant.ofEpochMilli( (Long) value ), ZoneId.systemDefault() );
|
return OffsetDateTime.ofInstant( Instant.ofEpochMilli( (Long) value ), ZoneId.systemDefault() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Calendar.class.isInstance( value ) ) {
|
if (value instanceof Calendar) {
|
||||||
final Calendar calendar = (Calendar) value;
|
final Calendar calendar = (Calendar) value;
|
||||||
return OffsetDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
|
return OffsetDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -120,7 +120,7 @@ public class OffsetTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDescri
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( OffsetTime.class.isInstance( value ) ) {
|
if (value instanceof OffsetTime) {
|
||||||
return (OffsetTime) value;
|
return (OffsetTime) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,11 +140,11 @@ public class OffsetTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDescri
|
||||||
*/
|
*/
|
||||||
ZoneOffset offset = OffsetDateTime.now().getOffset();
|
ZoneOffset offset = OffsetDateTime.now().getOffset();
|
||||||
|
|
||||||
if ( Time.class.isInstance( value ) ) {
|
if (value instanceof Time) {
|
||||||
return ( (Time) value ).toLocalTime().atOffset( offset );
|
return ( (Time) value ).toLocalTime().atOffset( offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Timestamp.class.isInstance( value ) ) {
|
if (value instanceof Timestamp) {
|
||||||
final Timestamp ts = (Timestamp) value;
|
final Timestamp ts = (Timestamp) value;
|
||||||
/*
|
/*
|
||||||
* Workaround for HHH-13266 (JDK-8061577).
|
* Workaround for HHH-13266 (JDK-8061577).
|
||||||
|
@ -155,16 +155,16 @@ public class OffsetTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDescri
|
||||||
return ts.toLocalDateTime().toLocalTime().atOffset( offset );
|
return ts.toLocalDateTime().toLocalTime().atOffset( offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Date.class.isInstance( value ) ) {
|
if (value instanceof Date) {
|
||||||
final Date date = (Date) value;
|
final Date date = (Date) value;
|
||||||
return OffsetTime.ofInstant( date.toInstant(), offset );
|
return OffsetTime.ofInstant( date.toInstant(), offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Long.class.isInstance( value ) ) {
|
if (value instanceof Long) {
|
||||||
return OffsetTime.ofInstant( Instant.ofEpochMilli( (Long) value ), offset );
|
return OffsetTime.ofInstant( Instant.ofEpochMilli( (Long) value ), offset );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Calendar.class.isInstance( value ) ) {
|
if (value instanceof Calendar) {
|
||||||
final Calendar calendar = (Calendar) value;
|
final Calendar calendar = (Calendar) value;
|
||||||
return OffsetTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
|
return OffsetTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,13 +111,13 @@ public class PrimitiveByteArrayJavaTypeDescriptor extends AbstractClassJavaTypeD
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( byte[].class.isInstance( value ) ) {
|
if (value instanceof byte[]) {
|
||||||
return (byte[]) value;
|
return (byte[]) value;
|
||||||
}
|
}
|
||||||
if ( InputStream.class.isInstance( value ) ) {
|
if (value instanceof InputStream) {
|
||||||
return DataHelper.extractBytes( (InputStream) value );
|
return DataHelper.extractBytes( (InputStream) value );
|
||||||
}
|
}
|
||||||
if ( Blob.class.isInstance( value ) || DataHelper.isNClob( value.getClass() ) ) {
|
if ( value instanceof Blob || DataHelper.isNClob( value.getClass() ) ) {
|
||||||
try {
|
try {
|
||||||
return DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() );
|
return DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,16 +78,16 @@ public class PrimitiveCharacterArrayJavaTypeDescriptor extends AbstractClassJava
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( char[].class.isInstance( value ) ) {
|
if (value instanceof char[]) {
|
||||||
return (char[]) value;
|
return (char[]) value;
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if (value instanceof String) {
|
||||||
return ( (String) value ).toCharArray();
|
return ( (String) value ).toCharArray();
|
||||||
}
|
}
|
||||||
if ( Clob.class.isInstance( value ) ) {
|
if (value instanceof Clob) {
|
||||||
return DataHelper.extractString( ( (Clob) value ) ).toCharArray();
|
return DataHelper.extractString( ( (Clob) value ) ).toCharArray();
|
||||||
}
|
}
|
||||||
if ( Reader.class.isInstance( value ) ) {
|
if (value instanceof Reader) {
|
||||||
return DataHelper.extractString( ( (Reader) value ) ).toCharArray();
|
return DataHelper.extractString( ( (Reader) value ) ).toCharArray();
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -106,13 +106,13 @@ public class RowVersionJavaTypeDescriptor extends AbstractClassJavaTypeDescripto
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( byte[].class.isInstance( value ) ) {
|
if (value instanceof byte[]) {
|
||||||
return (byte[]) value;
|
return (byte[]) value;
|
||||||
}
|
}
|
||||||
if ( InputStream.class.isInstance( value ) ) {
|
if (value instanceof InputStream) {
|
||||||
return DataHelper.extractBytes( (InputStream) value );
|
return DataHelper.extractBytes( (InputStream) value );
|
||||||
}
|
}
|
||||||
if ( Blob.class.isInstance( value ) || DataHelper.isNClob( value.getClass() ) ) {
|
if ( value instanceof Blob || DataHelper.isNClob( value.getClass() ) ) {
|
||||||
try {
|
try {
|
||||||
return DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() );
|
return DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,13 +124,13 @@ public class SerializableJavaTypeDescriptor<T extends Serializable> extends Abst
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
else if ( byte[].class.isInstance( value ) ) {
|
else if (value instanceof byte[]) {
|
||||||
return fromBytes( (byte[]) value );
|
return fromBytes( (byte[]) value );
|
||||||
}
|
}
|
||||||
else if ( InputStream.class.isInstance( value ) ) {
|
else if (value instanceof InputStream) {
|
||||||
return fromBytes( DataHelper.extractBytes( (InputStream) value ) );
|
return fromBytes( DataHelper.extractBytes( (InputStream) value ) );
|
||||||
}
|
}
|
||||||
else if ( Blob.class.isInstance( value ) ) {
|
else if (value instanceof Blob) {
|
||||||
try {
|
try {
|
||||||
return fromBytes( DataHelper.extractBytes( ((Blob) value).getBinaryStream() ) );
|
return fromBytes( DataHelper.extractBytes( ((Blob) value).getBinaryStream() ) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,13 +83,13 @@ public class ShortJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Sho
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( Short.class.isInstance( value ) ) {
|
if (value instanceof Short) {
|
||||||
return (Short) value;
|
return (Short) value;
|
||||||
}
|
}
|
||||||
if ( Number.class.isInstance( value ) ) {
|
if (value instanceof Number) {
|
||||||
return ( (Number) value ).shortValue();
|
return ( (Number) value ).shortValue();
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if (value instanceof String) {
|
||||||
return Short.valueOf( ( (String) value ) );
|
return Short.valueOf( ( (String) value ) );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -87,13 +87,13 @@ public class StringJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<St
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if (value instanceof String) {
|
||||||
return (String) value;
|
return (String) value;
|
||||||
}
|
}
|
||||||
if ( Reader.class.isInstance( value ) ) {
|
if (value instanceof Reader) {
|
||||||
return DataHelper.extractString( (Reader) value );
|
return DataHelper.extractString( (Reader) value );
|
||||||
}
|
}
|
||||||
if ( Clob.class.isInstance( value ) ) {
|
if (value instanceof Clob) {
|
||||||
return DataHelper.extractString( (Clob) value );
|
return DataHelper.extractString( (Clob) value );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class TimeZoneJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( CharSequence.class.isInstance( value ) ) {
|
if (value instanceof CharSequence) {
|
||||||
return fromString( (CharSequence) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -73,13 +73,13 @@ public class UUIDJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<UUID
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( UUID.class.isInstance( value ) ) {
|
if (value instanceof UUID) {
|
||||||
return PassThroughTransformer.INSTANCE.parse( value );
|
return PassThroughTransformer.INSTANCE.parse( value );
|
||||||
}
|
}
|
||||||
if ( String.class.isInstance( value ) ) {
|
if (value instanceof String) {
|
||||||
return ToStringTransformer.INSTANCE.parse( value );
|
return ToStringTransformer.INSTANCE.parse( value );
|
||||||
}
|
}
|
||||||
if ( byte[].class.isInstance( value ) ) {
|
if (value instanceof byte[]) {
|
||||||
return ToBytesTransformer.INSTANCE.parse( value );
|
return ToBytesTransformer.INSTANCE.parse( value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -60,7 +60,7 @@ public class UrlJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<URL>
|
||||||
if ( value == null ) {
|
if ( value == null ) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if ( CharSequence.class.isInstance( value ) ) {
|
if (value instanceof CharSequence) {
|
||||||
return fromString( (CharSequence) value );
|
return fromString( (CharSequence) value );
|
||||||
}
|
}
|
||||||
throw unknownWrap( value.getClass() );
|
throw unknownWrap( value.getClass() );
|
||||||
|
|
|
@ -155,16 +155,16 @@ public class ZonedDateTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDes
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ZonedDateTime.class.isInstance( value ) ) {
|
if (value instanceof ZonedDateTime) {
|
||||||
return (ZonedDateTime) value;
|
return (ZonedDateTime) value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( OffsetDateTime.class.isInstance( value ) ) {
|
if (value instanceof OffsetDateTime) {
|
||||||
OffsetDateTime offsetDateTime = (OffsetDateTime) value;
|
OffsetDateTime offsetDateTime = (OffsetDateTime) value;
|
||||||
return offsetDateTime.toZonedDateTime();
|
return offsetDateTime.toZonedDateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Timestamp.class.isInstance( value ) ) {
|
if (value instanceof Timestamp) {
|
||||||
final Timestamp ts = (Timestamp) value;
|
final Timestamp ts = (Timestamp) value;
|
||||||
/*
|
/*
|
||||||
* This works around two bugs:
|
* This works around two bugs:
|
||||||
|
@ -184,16 +184,16 @@ public class ZonedDateTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDes
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Date.class.isInstance( value ) ) {
|
if (value instanceof Date) {
|
||||||
final Date date = (Date) value;
|
final Date date = (Date) value;
|
||||||
return ZonedDateTime.ofInstant( date.toInstant(), ZoneId.systemDefault() );
|
return ZonedDateTime.ofInstant( date.toInstant(), ZoneId.systemDefault() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Long.class.isInstance( value ) ) {
|
if (value instanceof Long) {
|
||||||
return ZonedDateTime.ofInstant( Instant.ofEpochMilli( (Long) value ), ZoneId.systemDefault() );
|
return ZonedDateTime.ofInstant( Instant.ofEpochMilli( (Long) value ), ZoneId.systemDefault() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( Calendar.class.isInstance( value ) ) {
|
if (value instanceof Calendar) {
|
||||||
final Calendar calendar = (Calendar) value;
|
final Calendar calendar = (Calendar) value;
|
||||||
return ZonedDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
|
return ZonedDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue