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:
Gavin King 2022-01-07 00:11:36 +01:00
parent 6c83e1d0ec
commit e79d7efbce
35 changed files with 116 additions and 116 deletions

View File

@ -110,7 +110,7 @@ public class BlobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Blob
try {
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
return (X) ( (BlobImplementer) value ).getUnderlyingStream();
}
@ -120,7 +120,7 @@ public class BlobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Blob
}
}
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
return (X) ( (BlobImplementer) value ).getUnderlyingStream().getBytes();
}
@ -130,7 +130,7 @@ public class BlobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Blob
}
}
else if (Blob.class.isAssignableFrom( type )) {
final Blob blob = WrappedBlob.class.isInstance( value )
final Blob blob = value instanceof WrappedBlob
? ( (WrappedBlob) value ).getWrappedBlob()
: value;
return (X) blob;

View File

@ -85,18 +85,18 @@ public class BooleanJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<B
if ( value == null ) {
return null;
}
if ( Boolean.class.isInstance( value ) ) {
if (value instanceof Boolean) {
return (Boolean) value;
}
if ( Number.class.isInstance( value ) ) {
if (value instanceof Number) {
final int intValue = ( (Number) value ).intValue();
return intValue != 0;
}
if ( Character.class.isInstance( value ) ) {
if (value instanceof Character) {
return isTrue( (Character) value );
}
if ( String.class.isInstance( value ) ) {
return isTrue((String) value);
if (value instanceof String) {
return isTrue( (String) value );
}
throw unknownWrap( value.getClass() );
}

View File

@ -100,16 +100,16 @@ public class ByteArrayJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor
if ( value == null ) {
return null;
}
if ( Byte[].class.isInstance( value ) ) {
if (value instanceof Byte[]) {
return (Byte[]) value;
}
if ( byte[].class.isInstance( value ) ) {
if (value instanceof byte[]) {
return wrapBytes( (byte[]) value );
}
if ( InputStream.class.isInstance( value ) ) {
if (value instanceof InputStream) {
return wrapBytes( DataHelper.extractBytes( (InputStream) value ) );
}
if ( Blob.class.isInstance( value ) || DataHelper.isNClob( value.getClass() ) ) {
if ( value instanceof Blob || DataHelper.isNClob( value.getClass() ) ) {
try {
return wrapBytes( DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() ) );
}

View File

@ -120,11 +120,11 @@ public class CalendarDateJavaTypeDescriptor extends AbstractTemporalJavaTypeDesc
if ( value == null ) {
return null;
}
if ( Calendar.class.isInstance( value ) ) {
if (value instanceof Calendar) {
return (Calendar) value;
}
if ( ! Date.class.isInstance( value ) ) {
if ( !(value instanceof Date)) {
throw unknownWrap( value.getClass() );
}

View File

@ -136,11 +136,11 @@ public class CalendarJavaTypeDescriptor extends AbstractTemporalJavaTypeDescript
if ( value == null ) {
return null;
}
if ( Calendar.class.isInstance( value ) ) {
if (value instanceof Calendar) {
return (Calendar) value;
}
if ( ! java.util.Date.class.isInstance( value ) ) {
if ( !(value instanceof java.util.Date)) {
throw unknownWrap( value.getClass() );
}

View File

@ -120,11 +120,11 @@ public class CalendarTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDesc
if ( value == null ) {
return null;
}
if ( Calendar.class.isInstance( value ) ) {
if (value instanceof Calendar) {
return (Calendar) value;
}
if ( ! Date.class.isInstance( value ) ) {
if ( !(value instanceof Date)) {
throw unknownWrap( value.getClass() );
}

View File

@ -81,16 +81,16 @@ public class CharacterArrayJavaTypeDescriptor extends AbstractClassJavaTypeDescr
if ( value == null ) {
return null;
}
if ( Character[].class.isInstance( value ) ) {
if (value instanceof Character[]) {
return (Character[]) value;
}
if ( String.class.isInstance( value ) ) {
if (value instanceof String) {
return wrapChars( ( (String) value ).toCharArray() );
}
if ( Clob.class.isInstance( value ) ) {
if (value instanceof Clob) {
return wrapChars( DataHelper.extractString( ( (Clob) value ) ).toCharArray() );
}
if ( Reader.class.isInstance( value ) ) {
if (value instanceof Reader) {
return wrapChars( DataHelper.extractString( (Reader) value ).toCharArray() );
}
throw unknownWrap( value.getClass() );

View File

@ -59,14 +59,14 @@ public class CharacterJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor
if ( value == null ) {
return null;
}
if ( Character.class.isInstance( value ) ) {
if (value instanceof Character) {
return (Character) value;
}
if ( String.class.isInstance( value ) ) {
if (value instanceof String) {
final String str = (String) value;
return str.charAt( 0 );
}
if ( Number.class.isInstance( value ) ) {
if (value instanceof Number) {
final Number nbr = (Number) value;
return (char) nbr.shortValue();
}

View File

@ -56,10 +56,10 @@ public class ClassJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Cla
if ( value == null ) {
return null;
}
if ( Class.class.isInstance( value ) ) {
if (value instanceof Class) {
return (Class) value;
}
if ( CharSequence.class.isInstance( value ) ) {
if (value instanceof CharSequence) {
return fromString( (CharSequence) value );
}
throw unknownWrap( value.getClass() );

View File

@ -97,7 +97,7 @@ public class ClobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Clob
}
}
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
return (X) ( (ClobImplementer) value ).getUnderlyingStream().asString();
}

View File

@ -48,7 +48,7 @@ public class CurrencyJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<
if ( value == null ) {
return null;
}
if ( String.class.isInstance( value ) ) {
if (value instanceof String) {
return Currency.getInstance( (String) value );
}
throw unknownWrap( value.getClass() );

View File

@ -115,19 +115,19 @@ public class DateJavaTypeDescriptor extends AbstractTemporalJavaTypeDescriptor<D
return null;
}
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
: new java.sql.Date( value.getTime() );
return (X) rtn;
}
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
: new java.sql.Time( value.getTime() );
return (X) rtn;
}
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
: new java.sql.Timestamp( value.getTime() );
return (X) rtn;
@ -150,15 +150,15 @@ public class DateJavaTypeDescriptor extends AbstractTemporalJavaTypeDescriptor<D
if ( value == null ) {
return null;
}
if ( Date.class.isInstance( value ) ) {
if (value instanceof Date) {
return (Date) value;
}
if ( Long.class.isInstance( value ) ) {
if (value instanceof Long) {
return new Date( (Long) value );
}
if ( Calendar.class.isInstance( value ) ) {
if (value instanceof Calendar) {
return new Date( ( (Calendar) value ).getTimeInMillis() );
}

View File

@ -53,6 +53,9 @@ public class DoubleJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Do
if ( Double.class.isAssignableFrom( type ) ) {
return (X) value;
}
if ( Float.class.isAssignableFrom( type ) ) {
return (X) Float.valueOf( value.floatValue() );
}
if ( Byte.class.isAssignableFrom( type ) ) {
return (X) Byte.valueOf( value.byteValue() );
}
@ -65,9 +68,6 @@ public class DoubleJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Do
if ( Long.class.isAssignableFrom( type ) ) {
return (X) Long.valueOf( value.longValue() );
}
if ( Float.class.isAssignableFrom( type ) ) {
return (X) Float.valueOf( value.floatValue() );
}
if ( BigInteger.class.isAssignableFrom( type ) ) {
return (X) BigInteger.valueOf( value.longValue() );
}

View File

@ -106,11 +106,11 @@ public class DurationJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<
return null;
}
if ( Duration.class.isInstance( value ) ) {
if (value instanceof Duration) {
return (Duration) value;
}
if ( BigDecimal.class.isInstance( value ) ) {
if (value instanceof BigDecimal) {
BigDecimal[] secondsAndNanos =
((BigDecimal) value).divideAndRemainder( BigDecimal.ONE );
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 );
}
if ( String.class.isInstance( value ) ) {
if (value instanceof String) {
return Duration.parse( (String) value );
}

View File

@ -52,6 +52,9 @@ public class FloatTypeDescriptor extends AbstractClassJavaTypeDescriptor<Float>
if ( Float.class.isAssignableFrom( type ) ) {
return (X) value;
}
if ( Double.class.isAssignableFrom( type ) ) {
return (X) Double.valueOf( value.doubleValue() );
}
if ( Byte.class.isAssignableFrom( type ) ) {
return (X) Byte.valueOf( value.byteValue() );
}
@ -64,9 +67,6 @@ public class FloatTypeDescriptor extends AbstractClassJavaTypeDescriptor<Float>
if ( Long.class.isAssignableFrom( type ) ) {
return (X) Long.valueOf( value.longValue() );
}
if ( Double.class.isAssignableFrom( type ) ) {
return (X) Double.valueOf( value.doubleValue() );
}
if ( BigInteger.class.isAssignableFrom( type ) ) {
return (X) BigInteger.valueOf( value.longValue() );
}
@ -83,13 +83,13 @@ public class FloatTypeDescriptor extends AbstractClassJavaTypeDescriptor<Float>
if ( value == null ) {
return null;
}
if ( Float.class.isInstance( value ) ) {
if (value instanceof Float) {
return (Float) value;
}
if ( Number.class.isInstance( value ) ) {
if (value instanceof Number) {
return ( (Number) value ).floatValue();
}
else if ( String.class.isInstance( value ) ) {
else if (value instanceof String) {
return Float.valueOf( ( (String) value ) );
}
throw unknownWrap( value.getClass() );

View File

@ -71,10 +71,10 @@ public class InetAddressJavaTypeDescriptor extends AbstractClassJavaTypeDescript
if ( value == null ) {
return null;
}
if ( InetAddress.class.isInstance( value ) ) {
if (value instanceof InetAddress) {
return (InetAddress) value;
}
if ( byte[].class.isInstance( value ) ) {
if (value instanceof byte[]) {
try {
return InetAddress.getByAddress( (byte[]) value );
}
@ -82,7 +82,7 @@ public class InetAddressJavaTypeDescriptor extends AbstractClassJavaTypeDescript
throw new IllegalArgumentException( e );
}
}
if ( String.class.isInstance( value ) ) {
if (value instanceof String) {
try {
return InetAddress.getByName( (String) value );
}

View File

@ -80,13 +80,13 @@ public class IntegerJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<I
if ( value == null ) {
return null;
}
if ( Integer.class.isInstance( value ) ) {
if (value instanceof Integer) {
return (Integer) value;
}
if ( Number.class.isInstance( value ) ) {
if (value instanceof Number) {
return ( (Number) value ).intValue();
}
if ( String.class.isInstance( value ) ) {
if (value instanceof String) {
return Integer.valueOf( ( (String) value ) );
}
throw unknownWrap( value.getClass() );

View File

@ -120,11 +120,11 @@ public class LocalDateJavaTypeDescriptor extends AbstractTemporalJavaTypeDescrip
return null;
}
if ( LocalDate.class.isInstance( value ) ) {
if (value instanceof LocalDate) {
return (LocalDate) value;
}
if ( Timestamp.class.isInstance( value ) ) {
if (value instanceof Timestamp) {
final Timestamp ts = (Timestamp) value;
/*
* Workaround for HHH-13266 (JDK-8061577).
@ -136,18 +136,18 @@ public class LocalDateJavaTypeDescriptor extends AbstractTemporalJavaTypeDescrip
return ts.toLocalDateTime().toLocalDate();
}
if ( Long.class.isInstance( value ) ) {
if (value instanceof Long) {
final Instant instant = Instant.ofEpochMilli( (Long) value );
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalDate();
}
if ( Calendar.class.isInstance( value ) ) {
if (value instanceof Calendar) {
final Calendar calendar = (Calendar) value;
return LocalDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() ).toLocalDate();
}
if ( Date.class.isInstance( value ) ) {
if ( java.sql.Date.class.isInstance( value ) ) {
if (value instanceof Date) {
if (value instanceof java.sql.Date) {
return ((java.sql.Date) value).toLocalDate();
}
else {

View File

@ -123,11 +123,11 @@ public class LocalDateTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDes
return null;
}
if ( LocalDateTime.class.isInstance( value ) ) {
if (value instanceof LocalDateTime) {
return (LocalDateTime) value;
}
if ( Timestamp.class.isInstance( value ) ) {
if (value instanceof Timestamp) {
final Timestamp ts = (Timestamp) value;
/*
* Workaround for HHH-13266 (JDK-8061577).
@ -139,17 +139,17 @@ public class LocalDateTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDes
return ts.toLocalDateTime();
}
if ( Long.class.isInstance( value ) ) {
if (value instanceof Long) {
final Instant instant = Instant.ofEpochMilli( (Long) value );
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() );
}
if ( Calendar.class.isInstance( value ) ) {
if (value instanceof Calendar) {
final Calendar calendar = (Calendar) value;
return LocalDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
}
if ( Date.class.isInstance( value ) ) {
if (value instanceof Date) {
final Timestamp ts = (Timestamp) value;
final Instant instant = Instant.ofEpochMilli( ts.getTime() );
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() );

View File

@ -119,26 +119,26 @@ public class LocalTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDescrip
return null;
}
if ( LocalTime.class.isInstance( value ) ) {
if (value instanceof LocalTime) {
return (LocalTime) value;
}
if ( Timestamp.class.isInstance( value ) ) {
if (value instanceof Timestamp) {
final Timestamp ts = (Timestamp) value;
return LocalDateTime.ofInstant( ts.toInstant(), ZoneId.systemDefault() ).toLocalTime();
}
if ( Long.class.isInstance( value ) ) {
if (value instanceof Long) {
final Instant instant = Instant.ofEpochMilli( (Long) value );
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalTime();
}
if ( Calendar.class.isInstance( value ) ) {
if (value instanceof Calendar) {
final Calendar calendar = (Calendar) value;
return LocalDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() ).toLocalTime();
}
if ( Date.class.isInstance( value ) ) {
if (value instanceof Date) {
final Date ts = (Date) value;
final Instant instant = Instant.ofEpochMilli( ts.getTime() );
return LocalDateTime.ofInstant( instant, ZoneId.systemDefault() ).toLocalTime();

View File

@ -101,7 +101,7 @@ public class LocaleJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Lo
if ( value == null ) {
return null;
}
if ( CharSequence.class.isInstance( value ) ) {
if (value instanceof CharSequence) {
return fromString( (CharSequence) value );
}
throw unknownWrap( value.getClass() );

View File

@ -92,7 +92,7 @@ public class NClobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<NCl
try {
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
return (X) ( (NClobImplementer) value ).getUnderlyingStream();
}
@ -102,7 +102,7 @@ public class NClobJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<NCl
}
}
else if (NClob.class.isAssignableFrom( type )) {
final NClob nclob = WrappedNClob.class.isInstance( value )
final NClob nclob = value instanceof WrappedNClob
? ( (WrappedNClob) value ).getWrappedNClob()
: value;
return (X) nclob;

View File

@ -81,7 +81,7 @@ public class ObjectArrayJavaTypeDescriptor extends AbstractClassJavaTypeDescript
if ( value == null ) {
return null;
}
if ( Object[].class.isInstance( value ) ) {
if (value instanceof Object[]) {
return (Object[]) value;
}
throw unknownWrap( value.getClass() );

View File

@ -155,16 +155,16 @@ public class OffsetDateTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDe
return null;
}
if ( OffsetDateTime.class.isInstance( value ) ) {
if (value instanceof OffsetDateTime) {
return (OffsetDateTime) value;
}
if ( ZonedDateTime.class.isInstance( value ) ) {
if (value instanceof ZonedDateTime) {
ZonedDateTime zonedDateTime = (ZonedDateTime) value;
return OffsetDateTime.of( zonedDateTime.toLocalDateTime(), zonedDateTime.getOffset() );
}
if ( Timestamp.class.isInstance( value ) ) {
if (value instanceof Timestamp) {
final Timestamp ts = (Timestamp) value;
/*
* 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;
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() );
}
if ( Calendar.class.isInstance( value ) ) {
if (value instanceof Calendar) {
final Calendar calendar = (Calendar) value;
return OffsetDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
}

View File

@ -120,7 +120,7 @@ public class OffsetTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDescri
return null;
}
if ( OffsetTime.class.isInstance( value ) ) {
if (value instanceof OffsetTime) {
return (OffsetTime) value;
}
@ -140,11 +140,11 @@ public class OffsetTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDescri
*/
ZoneOffset offset = OffsetDateTime.now().getOffset();
if ( Time.class.isInstance( value ) ) {
if (value instanceof Time) {
return ( (Time) value ).toLocalTime().atOffset( offset );
}
if ( Timestamp.class.isInstance( value ) ) {
if (value instanceof Timestamp) {
final Timestamp ts = (Timestamp) value;
/*
* Workaround for HHH-13266 (JDK-8061577).
@ -155,16 +155,16 @@ public class OffsetTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDescri
return ts.toLocalDateTime().toLocalTime().atOffset( offset );
}
if ( Date.class.isInstance( value ) ) {
if (value instanceof Date) {
final Date date = (Date) value;
return OffsetTime.ofInstant( date.toInstant(), offset );
}
if ( Long.class.isInstance( value ) ) {
if (value instanceof Long) {
return OffsetTime.ofInstant( Instant.ofEpochMilli( (Long) value ), offset );
}
if ( Calendar.class.isInstance( value ) ) {
if (value instanceof Calendar) {
final Calendar calendar = (Calendar) value;
return OffsetTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
}

View File

@ -111,13 +111,13 @@ public class PrimitiveByteArrayJavaTypeDescriptor extends AbstractClassJavaTypeD
if ( value == null ) {
return null;
}
if ( byte[].class.isInstance( value ) ) {
if (value instanceof byte[]) {
return (byte[]) value;
}
if ( InputStream.class.isInstance( value ) ) {
if (value instanceof InputStream) {
return DataHelper.extractBytes( (InputStream) value );
}
if ( Blob.class.isInstance( value ) || DataHelper.isNClob( value.getClass() ) ) {
if ( value instanceof Blob || DataHelper.isNClob( value.getClass() ) ) {
try {
return DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() );
}

View File

@ -78,16 +78,16 @@ public class PrimitiveCharacterArrayJavaTypeDescriptor extends AbstractClassJava
if ( value == null ) {
return null;
}
if ( char[].class.isInstance( value ) ) {
if (value instanceof char[]) {
return (char[]) value;
}
if ( String.class.isInstance( value ) ) {
if (value instanceof String) {
return ( (String) value ).toCharArray();
}
if ( Clob.class.isInstance( value ) ) {
if (value instanceof Clob) {
return DataHelper.extractString( ( (Clob) value ) ).toCharArray();
}
if ( Reader.class.isInstance( value ) ) {
if (value instanceof Reader) {
return DataHelper.extractString( ( (Reader) value ) ).toCharArray();
}
throw unknownWrap( value.getClass() );

View File

@ -106,13 +106,13 @@ public class RowVersionJavaTypeDescriptor extends AbstractClassJavaTypeDescripto
if ( value == null ) {
return null;
}
if ( byte[].class.isInstance( value ) ) {
if (value instanceof byte[]) {
return (byte[]) value;
}
if ( InputStream.class.isInstance( value ) ) {
if (value instanceof InputStream) {
return DataHelper.extractBytes( (InputStream) value );
}
if ( Blob.class.isInstance( value ) || DataHelper.isNClob( value.getClass() ) ) {
if ( value instanceof Blob || DataHelper.isNClob( value.getClass() ) ) {
try {
return DataHelper.extractBytes( ( (Blob) value ).getBinaryStream() );
}

View File

@ -124,13 +124,13 @@ public class SerializableJavaTypeDescriptor<T extends Serializable> extends Abst
if ( value == null ) {
return null;
}
else if ( byte[].class.isInstance( value ) ) {
else if (value instanceof byte[]) {
return fromBytes( (byte[]) value );
}
else if ( InputStream.class.isInstance( value ) ) {
else if (value instanceof InputStream) {
return fromBytes( DataHelper.extractBytes( (InputStream) value ) );
}
else if ( Blob.class.isInstance( value ) ) {
else if (value instanceof Blob) {
try {
return fromBytes( DataHelper.extractBytes( ((Blob) value).getBinaryStream() ) );
}

View File

@ -83,13 +83,13 @@ public class ShortJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<Sho
if ( value == null ) {
return null;
}
if ( Short.class.isInstance( value ) ) {
if (value instanceof Short) {
return (Short) value;
}
if ( Number.class.isInstance( value ) ) {
if (value instanceof Number) {
return ( (Number) value ).shortValue();
}
if ( String.class.isInstance( value ) ) {
if (value instanceof String) {
return Short.valueOf( ( (String) value ) );
}
throw unknownWrap( value.getClass() );

View File

@ -87,13 +87,13 @@ public class StringJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<St
if ( value == null ) {
return null;
}
if ( String.class.isInstance( value ) ) {
if (value instanceof String) {
return (String) value;
}
if ( Reader.class.isInstance( value ) ) {
if (value instanceof Reader) {
return DataHelper.extractString( (Reader) value );
}
if ( Clob.class.isInstance( value ) ) {
if (value instanceof Clob) {
return DataHelper.extractString( (Clob) value );
}

View File

@ -54,7 +54,7 @@ public class TimeZoneJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<
if ( value == null ) {
return null;
}
if ( CharSequence.class.isInstance( value ) ) {
if (value instanceof CharSequence) {
return fromString( (CharSequence) value );
}
throw unknownWrap( value.getClass() );

View File

@ -73,13 +73,13 @@ public class UUIDJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<UUID
if ( value == null ) {
return null;
}
if ( UUID.class.isInstance( value ) ) {
if (value instanceof UUID) {
return PassThroughTransformer.INSTANCE.parse( value );
}
if ( String.class.isInstance( value ) ) {
if (value instanceof String) {
return ToStringTransformer.INSTANCE.parse( value );
}
if ( byte[].class.isInstance( value ) ) {
if (value instanceof byte[]) {
return ToBytesTransformer.INSTANCE.parse( value );
}
throw unknownWrap( value.getClass() );

View File

@ -60,7 +60,7 @@ public class UrlJavaTypeDescriptor extends AbstractClassJavaTypeDescriptor<URL>
if ( value == null ) {
return null;
}
if ( CharSequence.class.isInstance( value ) ) {
if (value instanceof CharSequence) {
return fromString( (CharSequence) value );
}
throw unknownWrap( value.getClass() );

View File

@ -155,16 +155,16 @@ public class ZonedDateTimeJavaTypeDescriptor extends AbstractTemporalJavaTypeDes
return null;
}
if ( ZonedDateTime.class.isInstance( value ) ) {
if (value instanceof ZonedDateTime) {
return (ZonedDateTime) value;
}
if ( OffsetDateTime.class.isInstance( value ) ) {
if (value instanceof OffsetDateTime) {
OffsetDateTime offsetDateTime = (OffsetDateTime) value;
return offsetDateTime.toZonedDateTime();
}
if ( Timestamp.class.isInstance( value ) ) {
if (value instanceof Timestamp) {
final Timestamp ts = (Timestamp) value;
/*
* 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;
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() );
}
if ( Calendar.class.isInstance( value ) ) {
if (value instanceof Calendar) {
final Calendar calendar = (Calendar) value;
return ZonedDateTime.ofInstant( calendar.toInstant(), calendar.getTimeZone().toZoneId() );
}