diff --git a/documentation/src/test/java/org/hibernate/userguide/mapping/basic/bitset/BitSetUserType.java b/documentation/src/test/java/org/hibernate/userguide/mapping/basic/bitset/BitSetUserType.java index 300d8c2c84..6208f9ed02 100644 --- a/documentation/src/test/java/org/hibernate/userguide/mapping/basic/bitset/BitSetUserType.java +++ b/documentation/src/test/java/org/hibernate/userguide/mapping/basic/bitset/BitSetUserType.java @@ -24,36 +24,36 @@ import org.jboss.logging.Logger; * @author Vlad Mihalcea */ //tag::basic-custom-type-BitSetUserType-example[] -public class BitSetUserType implements UserType { +public class BitSetUserType implements UserType { public static final BitSetUserType INSTANCE = new BitSetUserType(); private static final Logger log = Logger.getLogger(BitSetUserType.class); @Override - public int[] sqlTypes() { - return new int[] { Types.VARCHAR }; + public int getSqlType() { + return Types.VARCHAR; } @Override - public Class returnedClass() { + public Class returnedClass() { return BitSet.class; } @Override - public boolean equals(Object x, Object y) + public boolean equals(BitSet x, BitSet y) throws HibernateException { return Objects.equals(x, y); } @Override - public int hashCode(Object x) + public int hashCode(BitSet x) throws HibernateException { return Objects.hashCode(x); } @Override - public Object nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { + public BitSet nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { String columnValue = (String) rs.getObject(position); if (rs.wasNull()) { columnValue = null; @@ -65,7 +65,7 @@ public class BitSetUserType implements UserType { @Override public void nullSafeSet( - PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) + PreparedStatement st, BitSet value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { if (value == null) { log.debugv("Binding null to parameter {0} ",index); @@ -79,7 +79,7 @@ public class BitSetUserType implements UserType { } @Override - public Object deepCopy(Object value) + public BitSet deepCopy(BitSet value) throws HibernateException { return value == null ? null : BitSet.valueOf(BitSet.class.cast(value).toLongArray()); @@ -91,19 +91,19 @@ public class BitSetUserType implements UserType { } @Override - public Serializable disassemble(Object value) + public Serializable disassemble(BitSet value) throws HibernateException { - return (BitSet) deepCopy(value); + return deepCopy(value); } @Override - public Object assemble(Serializable cached, Object owner) + public BitSet assemble(Serializable cached, Object owner) throws HibernateException { - return deepCopy(cached); + return deepCopy( (BitSet) cached ); } @Override - public Object replace(Object original, Object target, Object owner) + public BitSet replace(BitSet original, BitSet target, Object owner) throws HibernateException { return deepCopy(original); } diff --git a/hibernate-core/src/main/java/org/hibernate/type/CustomType.java b/hibernate-core/src/main/java/org/hibernate/type/CustomType.java index ba6039f697..53705bf29e 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/CustomType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/CustomType.java @@ -134,12 +134,12 @@ public class CustomType @Override public boolean isEqual(Object x, Object y) throws HibernateException { - return getUserType().equals( x, y ); + return getUserType().equals( (J) x, (J) y ); } @Override public int getHashCode(Object x) { - return getUserType().hashCode( x); + return getUserType().hashCode( (J) x ); } @Override @@ -149,7 +149,7 @@ public class CustomType @Override public Serializable disassemble(Object value, SharedSessionContractImplementor session, Object owner) { - return getUserType().disassemble( value); + return getUserType().disassemble( (J) value ); } @Override @@ -159,7 +159,7 @@ public class CustomType SharedSessionContractImplementor session, Object owner, Map copyCache) throws HibernateException { - return getUserType().replace( original, target, owner ); + return getUserType().replace( (J) original, (J) target, owner ); } @Override @@ -192,7 +192,7 @@ public class CustomType @Override public Object deepCopy(Object value, SessionFactoryImplementor factory) throws HibernateException { - return getUserType().deepCopy( value); + return getUserType().deepCopy( (J) value ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java index 8df48b7829..7a9b66697d 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/EnumType.java +++ b/hibernate-core/src/main/java/org/hibernate/type/EnumType.java @@ -344,9 +344,9 @@ public class EnumType> } @Override - public int[] sqlTypes() { + public int getSqlType() { verifyConfigured(); - return new int[] { enumValueConverter.getJdbcTypeCode() }; + return enumValueConverter.getJdbcTypeCode(); } @Override @@ -355,12 +355,12 @@ public class EnumType> } @Override - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(T x, T y) throws HibernateException { return x == y; } @Override - public int hashCode(Object x) throws HibernateException { + public int hashCode(T x) throws HibernateException { return x == null ? 0 : x.hashCode(); } @@ -384,7 +384,7 @@ public class EnumType> } @Override - public Object deepCopy(Object value) throws HibernateException { + public T deepCopy(T value) throws HibernateException { return value; } @@ -394,17 +394,17 @@ public class EnumType> } @Override - public Serializable disassemble(Object value) throws HibernateException { - return ( Serializable ) value; + public Serializable disassemble(T value) throws HibernateException { + return value; } @Override - public Object assemble(Serializable cached, Object owner) throws HibernateException { - return cached; + public T assemble(Serializable cached, Object owner) throws HibernateException { + return (T) cached; } @Override - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public T replace(T original, T target, Object owner) throws HibernateException { return original; } diff --git a/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeJavaTypeWrapper.java b/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeJavaTypeWrapper.java index 13118c219a..3980ba3d23 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeJavaTypeWrapper.java +++ b/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeJavaTypeWrapper.java @@ -12,7 +12,6 @@ import java.util.Comparator; import org.hibernate.SharedSessionContract; import org.hibernate.annotations.Immutable; import org.hibernate.dialect.Dialect; -import org.hibernate.engine.jdbc.Size; import org.hibernate.type.descriptor.WrapperOptions; import org.hibernate.type.descriptor.java.BasicJavaType; import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan; @@ -70,7 +69,7 @@ public class UserTypeJavaTypeWrapper implements BasicJavaType { if ( userType.equals( first, second ) ) { return 0; } - return Comparator.comparing( userType::hashCode ).compare( first, second ); + return Comparator.comparing( userType::hashCode ).compare( first, second ); } @Override @@ -80,7 +79,7 @@ public class UserTypeJavaTypeWrapper implements BasicJavaType { @Override public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) { - return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( userType.sqlTypes()[0] ); + return context.getTypeConfiguration().getJdbcTypeRegistry().getDescriptor( userType.getSqlType() ); } @Override @@ -153,8 +152,7 @@ public class UserTypeJavaTypeWrapper implements BasicJavaType { @Override public J deepCopy(J value) { - //noinspection unchecked - return (J) userType.deepCopy( value ); + return userType.deepCopy( value ); } @Override @@ -164,8 +162,7 @@ public class UserTypeJavaTypeWrapper implements BasicJavaType { @Override public J assemble(Serializable cached, SharedSessionContract session) { - //noinspection unchecked - return (J) userType.disassemble( cached ); + return userType.assemble( cached , session); } } } diff --git a/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java b/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java index f233190db7..6b299da53f 100644 --- a/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java +++ b/hibernate-core/src/main/java/org/hibernate/type/internal/UserTypeSqlTypeAdapter.java @@ -53,7 +53,7 @@ public class UserTypeSqlTypeAdapter implements JdbcType { @Override public int getJdbcTypeCode() { - return userType.sqlTypes()[0]; + return userType.getSqlType(); } @Override @@ -142,10 +142,10 @@ public class UserTypeSqlTypeAdapter implements JdbcType { } if ( extracted == null ) { - JdbcExtractingLogging.logNullExtracted( paramIndex, userType.sqlTypes()[0] ); + JdbcExtractingLogging.logNullExtracted( paramIndex, userType.getSqlType() ); } else { - JdbcExtractingLogging.logExtracted( paramIndex, userType.sqlTypes()[0], extracted ); + JdbcExtractingLogging.logExtracted( paramIndex, userType.getSqlType(), extracted ); } } @@ -155,10 +155,10 @@ public class UserTypeSqlTypeAdapter implements JdbcType { } if ( extracted == null ) { - JdbcExtractingLogging.logNullExtracted( paramName, userType.sqlTypes()[0] ); + JdbcExtractingLogging.logNullExtracted( paramName, userType.getSqlType() ); } else { - JdbcExtractingLogging.logExtracted( paramName, userType.sqlTypes()[0], extracted ); + JdbcExtractingLogging.logExtracted( paramName, userType.getSqlType(), extracted ); } } } @@ -174,10 +174,10 @@ public class UserTypeSqlTypeAdapter implements JdbcType { public void bind(PreparedStatement st, J value, int index, WrapperOptions options) throws SQLException { if ( JdbcBindingLogging.TRACE_ENABLED ) { if ( value == null ) { - JdbcBindingLogging.logNullBinding( index, userType.sqlTypes()[ 0 ] ); + JdbcBindingLogging.logNullBinding( index, userType.getSqlType() ); } else { - JdbcBindingLogging.logBinding( index, userType.sqlTypes()[ 0 ], value ); + JdbcBindingLogging.logBinding( index, userType.getSqlType(), value ); } } userType.nullSafeSet( st, value, index, options.getSession() ); diff --git a/hibernate-core/src/main/java/org/hibernate/usertype/BaseUserTypeSupport.java b/hibernate-core/src/main/java/org/hibernate/usertype/BaseUserTypeSupport.java index d174607b81..990ad15f11 100644 --- a/hibernate-core/src/main/java/org/hibernate/usertype/BaseUserTypeSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/usertype/BaseUserTypeSupport.java @@ -28,8 +28,6 @@ public abstract class BaseUserTypeSupport implements UserType { private boolean resolved; - // cached array wrapping our single type-code - private int[] sqlTypes; // cached JDBC extractor and binder private ValueExtractor jdbcValueExtractor; private ValueBinder jdbcValueBinder; @@ -45,8 +43,6 @@ public abstract class BaseUserTypeSupport implements UserType { this.javaType = javaType; this.jdbcType = jdbcType; - sqlTypes = new int[] { jdbcType.getJdbcTypeCode() }; - jdbcValueExtractor = jdbcType.getExtractor( javaType ); jdbcValueBinder = jdbcType.getBinder( javaType ); @@ -65,9 +61,9 @@ public abstract class BaseUserTypeSupport implements UserType { } @Override - public int[] sqlTypes() { + public int getSqlType() { ensureResolved(); - return sqlTypes; + return jdbcType.getDefaultSqlTypeCode(); } @Override @@ -76,15 +72,13 @@ public abstract class BaseUserTypeSupport implements UserType { } @Override - public boolean equals(Object x, Object y) throws HibernateException { - //noinspection unchecked - return javaType().areEqual( (T) x, (T) y ); + public boolean equals(T x, T y) throws HibernateException { + return javaType().areEqual( x, y ); } @Override - public int hashCode(Object x) throws HibernateException { - //noinspection unchecked - return javaType().extractHashCode( (T) x ); + public int hashCode(T x) throws HibernateException { + return javaType().extractHashCode( x ); } @Override @@ -100,9 +94,8 @@ public abstract class BaseUserTypeSupport implements UserType { } @Override - public Object deepCopy(Object value) throws HibernateException { - //noinspection unchecked - return javaType().getMutabilityPlan().deepCopy( (T) value ); + public T deepCopy(T value) throws HibernateException { + return javaType().getMutabilityPlan().deepCopy( value ); } @Override @@ -111,18 +104,17 @@ public abstract class BaseUserTypeSupport implements UserType { } @Override - public Serializable disassemble(Object value) throws HibernateException { - //noinspection unchecked - return javaType().getMutabilityPlan().disassemble( (T) value, null ); + public Serializable disassemble(T value) throws HibernateException { + return javaType().getMutabilityPlan().disassemble( value, null ); } @Override - public Object assemble(Serializable cached, Object owner) throws HibernateException { + public T assemble(Serializable cached, Object owner) throws HibernateException { return javaType().getMutabilityPlan().assemble( cached, null ); } @Override - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public T replace(T original, T target, Object owner) throws HibernateException { return deepCopy( original ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/usertype/StaticUserTypeSupport.java b/hibernate-core/src/main/java/org/hibernate/usertype/StaticUserTypeSupport.java index 63103db51d..b3c6e4975f 100644 --- a/hibernate-core/src/main/java/org/hibernate/usertype/StaticUserTypeSupport.java +++ b/hibernate-core/src/main/java/org/hibernate/usertype/StaticUserTypeSupport.java @@ -17,6 +17,7 @@ import org.hibernate.metamodel.model.convert.spi.BasicValueConverter; import org.hibernate.type.descriptor.ValueBinder; import org.hibernate.type.descriptor.ValueExtractor; import org.hibernate.type.descriptor.java.BasicJavaType; +import org.hibernate.type.descriptor.java.JavaType; import org.hibernate.type.descriptor.java.MutabilityPlan; import org.hibernate.type.descriptor.jdbc.JdbcType; @@ -24,46 +25,49 @@ import org.hibernate.type.descriptor.jdbc.JdbcType; * @author Steve Ebersole */ public class StaticUserTypeSupport implements UserType { - private final BasicJavaType javaType; + private final BasicJavaType javaType; private final JdbcType jdbcType; - private final MutabilityPlan mutabilityPlan; - private final BasicValueConverter valueConverter; + private final MutabilityPlan mutabilityPlan; + private final BasicValueConverter valueConverter; - private final int[] sqlTypes; - private ValueExtractor jdbcValueExtractor; - private ValueBinder jdbcValueBinder; + private final ValueExtractor jdbcValueExtractor; + private final ValueBinder jdbcValueBinder; - public StaticUserTypeSupport(BasicJavaType javaType, JdbcType jdbcType) { + public StaticUserTypeSupport(BasicJavaType javaType, JdbcType jdbcType) { this( javaType, jdbcType, javaType.getMutabilityPlan() ); } public StaticUserTypeSupport( - BasicJavaType javaType, + BasicJavaType javaType, JdbcType jdbcType, - MutabilityPlan mutabilityPlan) { + MutabilityPlan mutabilityPlan) { this( javaType, jdbcType, mutabilityPlan, null ); } public StaticUserTypeSupport( - BasicJavaType javaType, + BasicJavaType javaType, JdbcType jdbcType, - BasicValueConverter valueConverter) { + BasicValueConverter valueConverter) { this( javaType, jdbcType, javaType.getMutabilityPlan(), valueConverter ); } - public StaticUserTypeSupport(BasicJavaType javaType, JdbcType jdbcType, MutabilityPlan mutabilityPlan, BasicValueConverter valueConverter) { + public StaticUserTypeSupport( + BasicJavaType javaType, + JdbcType jdbcType, + MutabilityPlan mutabilityPlan, + BasicValueConverter valueConverter) { this.javaType = javaType; this.jdbcType = jdbcType; this.mutabilityPlan = mutabilityPlan; this.valueConverter = valueConverter; - this.sqlTypes = new int[] { jdbcType.getJdbcTypeCode() }; - - this.jdbcValueExtractor = jdbcType.getExtractor( javaType ); - this.jdbcValueBinder = jdbcType.getBinder( javaType ); + //noinspection unchecked + this.jdbcValueExtractor = jdbcType.getExtractor( (JavaType) javaType ); + //noinspection unchecked + this.jdbcValueBinder = jdbcType.getBinder( (JavaType) javaType ); } - public BasicJavaType getJavaType() { + public BasicJavaType getJavaType() { return javaType; } @@ -71,25 +75,25 @@ public class StaticUserTypeSupport implements UserType { return jdbcType; } - public MutabilityPlan getMutabilityPlan() { + public MutabilityPlan getMutabilityPlan() { return mutabilityPlan; } - public BasicValueConverter getValueConverter() { + public BasicValueConverter getValueConverter() { return valueConverter; } - public ValueExtractor getJdbcValueExtractor() { + public ValueExtractor getJdbcValueExtractor() { return jdbcValueExtractor; } - public ValueBinder getJdbcValueBinder() { + public ValueBinder getJdbcValueBinder() { return jdbcValueBinder; } @Override - public int[] sqlTypes() { - return sqlTypes; + public int getSqlType() { + return jdbcType.getDefaultSqlTypeCode(); } @Override @@ -98,34 +102,32 @@ public class StaticUserTypeSupport implements UserType { } @Override - public boolean equals(Object x, Object y) throws HibernateException { - //noinspection unchecked - return javaType.areEqual( (T) x, (T) y ); + public boolean equals(T x, T y) throws HibernateException { + return javaType.areEqual( x, y ); } @Override - public int hashCode(Object x) throws HibernateException { - //noinspection unchecked - return javaType.extractHashCode( (T) x ); + public int hashCode(T x) throws HibernateException { + return javaType.extractHashCode( x ); } @Override - @SuppressWarnings("unchecked") public T nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { final Object extracted = jdbcValueExtractor.extract( rs, position, session ); if ( valueConverter != null ) { - return (T) valueConverter.toDomainValue( extracted ); + return valueConverter.toDomainValue( extracted ); } + //noinspection unchecked return (T) extracted; } @Override public void nullSafeSet(PreparedStatement st, T value, int index, SharedSessionContractImplementor session) throws SQLException { - final T valueToBind; + final Object valueToBind; if ( valueConverter != null ) { - valueToBind = (T) valueConverter.toRelationalValue( value ); + valueToBind = valueConverter.toRelationalValue( value ); } else { valueToBind = value; @@ -135,9 +137,8 @@ public class StaticUserTypeSupport implements UserType { } @Override - public Object deepCopy(Object value) throws HibernateException { - //noinspection unchecked - return javaType.getMutabilityPlan().deepCopy( (T) value ); + public T deepCopy(T value) throws HibernateException { + return javaType.getMutabilityPlan().deepCopy( value ); } @Override @@ -146,18 +147,17 @@ public class StaticUserTypeSupport implements UserType { } @Override - public Serializable disassemble(Object value) throws HibernateException { - //noinspection unchecked - return javaType.getMutabilityPlan().disassemble( (T) value, null ); + public Serializable disassemble(T value) throws HibernateException { + return javaType.getMutabilityPlan().disassemble( value, null ); } @Override - public Object assemble(Serializable cached, Object owner) throws HibernateException { + public T assemble(Serializable cached, Object owner) throws HibernateException { return javaType.getMutabilityPlan().assemble( cached, null ); } @Override - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public T replace(T original, T target, Object owner) throws HibernateException { return deepCopy( original ); } diff --git a/hibernate-core/src/main/java/org/hibernate/usertype/UserType.java b/hibernate-core/src/main/java/org/hibernate/usertype/UserType.java index 2a73f97168..ccb48baacd 100644 --- a/hibernate-core/src/main/java/org/hibernate/usertype/UserType.java +++ b/hibernate-core/src/main/java/org/hibernate/usertype/UserType.java @@ -53,13 +53,13 @@ import org.hibernate.type.descriptor.jdbc.JdbcType; public interface UserType { /** - * Return the SQL type codes for the columns mapped by this type. The - * codes are generally defined on {@code java.sql.Types}, but could + * Return the SQL type code for the column mapped by this type. The + * codes are generally defined on {@code org.hibernate.type.SqlTypes}, but could * be database-specific codes * - * @see java.sql.Types + * @see org.hibernate.type.SqlTypes */ - int[] sqlTypes(); + int getSqlType(); /** * The class returned by {@code nullSafeGet()}. @@ -72,12 +72,12 @@ public interface UserType { * Compare two instances of the class mapped by this type for persistence "equality". * Equality of the persistent state. */ - boolean equals(Object x, Object y); + boolean equals(J x, J y); /** * Get a hashcode for the instance, consistent with persistence "equality" */ - int hashCode(Object x); + int hashCode(J x); /** * Retrieve an instance of the mapped class from a JDBC resultset. Implementors @@ -100,7 +100,7 @@ public interface UserType { * @param value the object to be cloned, which may be null * @return Object a copy */ - Object deepCopy(Object value); + J deepCopy(J value); /** * Are objects of this type mutable? @@ -118,7 +118,7 @@ public interface UserType { * @param value the object to be cached * @return a cacheable representation of the object */ - Serializable disassemble(Object value); + Serializable disassemble(J value); /** * Reconstruct an object from the cacheable representation. At the very least this @@ -128,7 +128,7 @@ public interface UserType { * @param owner the owner of the cached object * @return a reconstructed object from the cacheable representation */ - Object assemble(Serializable cached, Object owner); + J assemble(Serializable cached, Object owner); /** * During merge, replace the existing (target) value in the entity we are merging to @@ -142,7 +142,7 @@ public interface UserType { * * @return the value to be merged */ - Object replace(Object detached, Object managed, Object owner); + J replace(J detached, J managed, Object owner); default long getDefaultSqlLength(Dialect dialect, JdbcType jdbcType) { return Size.DEFAULT_LENGTH; diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValueUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValueUserType.java index 679405f4e2..e07bce19d5 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValueUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/DollarValueUserType.java @@ -19,11 +19,11 @@ import org.hibernate.usertype.UserType; /** * @author Chris Pheby */ -public class DollarValueUserType implements UserType { +public class DollarValueUserType implements UserType { @Override - public int[] sqlTypes() { - return new int[] {Types.BIGINT}; + public int getSqlType() { + return Types.BIGINT; } @Override @@ -32,37 +32,31 @@ public class DollarValueUserType implements UserType { } @Override - public boolean equals(Object x, Object y) throws HibernateException { - if (!(x instanceof DollarValue) || !(y instanceof DollarValue)) { - throw new HibernateException("Expected DollarValue"); - } - return ((DollarValue)x).getAmount().equals(((DollarValue)y).getAmount()); + public boolean equals(DollarValue x, DollarValue y) throws HibernateException { + return x.getAmount().equals(y.getAmount()); } @Override - public int hashCode(Object x) throws HibernateException { - if (!(x instanceof DollarValue)) { - throw new HibernateException("Expected DollarValue"); - } - return ((DollarValue)x).getAmount().hashCode(); + public int hashCode(DollarValue x) throws HibernateException { + return x.getAmount().hashCode(); } @Override - public Object nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { + public DollarValue nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { return new DollarValue( rs.getBigDecimal( position ) ); } @Override public void nullSafeSet( PreparedStatement st, - Object value, + DollarValue value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { - st.setBigDecimal(index, ((DollarValue)value).getAmount()); + st.setBigDecimal(index, value.getAmount()); } @Override - public Object deepCopy(Object value) throws HibernateException { + public DollarValue deepCopy(DollarValue value) throws HibernateException { return new DollarValue(); } @@ -72,18 +66,18 @@ public class DollarValueUserType implements UserType { } @Override - public Serializable disassemble(Object value) throws HibernateException { + public Serializable disassemble(DollarValue value) throws HibernateException { return null; } @Override - public Object assemble(Serializable cached, Object owner) + public DollarValue assemble(Serializable cached, Object owner) throws HibernateException { return null; } @Override - public Object replace(Object original, Object target, Object owner) + public DollarValue replace(DollarValue original, DollarValue target, Object owner) throws HibernateException { return null; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDateUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDateUserType.java index 6339415a8b..a81ffc6d1e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDateUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/embeddables/MyDateUserType.java @@ -19,11 +19,11 @@ import org.hibernate.usertype.UserType; /** * @author Chris Pheby */ -public class MyDateUserType implements UserType { +public class MyDateUserType implements UserType { @Override - public int[] sqlTypes() { - return new int[] {Types.DATE}; + public int getSqlType() { + return Types.DATE; } @Override @@ -32,37 +32,31 @@ public class MyDateUserType implements UserType { } @Override - public boolean equals(Object x, Object y) throws HibernateException { - if (!(x instanceof MyDate) || !(y instanceof MyDate)) { - throw new HibernateException("Expected MyDate"); - } - return ((MyDate)x).getDate().equals(((MyDate)y).getDate()); + public boolean equals(MyDate x, MyDate y) throws HibernateException { + return x.getDate().equals(y.getDate()); } @Override - public int hashCode(Object x) throws HibernateException { - if (!(x instanceof MyDate)) { - throw new HibernateException("Expected MyDate"); - } - return ((MyDate)x).getDate().hashCode(); + public int hashCode(MyDate x) throws HibernateException { + return x.getDate().hashCode(); } @Override - public Object nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { + public MyDate nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { return new MyDate( rs.getDate( position ) ); } @Override public void nullSafeSet( PreparedStatement st, - Object value, + MyDate value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { - st.setDate(index, new java.sql.Date(((MyDate)value).getDate().getTime())); + st.setDate(index, new java.sql.Date(value.getDate().getTime())); } @Override - public Object deepCopy(Object value) throws HibernateException { + public MyDate deepCopy(MyDate value) throws HibernateException { MyDate result = new MyDate(); return result; @@ -74,18 +68,18 @@ public class MyDateUserType implements UserType { } @Override - public Serializable disassemble(Object value) throws HibernateException { + public Serializable disassemble(MyDate value) throws HibernateException { return null; } @Override - public Object assemble(Serializable cached, Object owner) + public MyDate assemble(Serializable cached, Object owner) throws HibernateException { return null; } @Override - public Object replace(Object original, Object target, Object owner) + public MyDate replace(MyDate original, MyDate target, Object owner) throws HibernateException { return null; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/EnumeratedSmokeTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/EnumeratedSmokeTest.java index 02989864f4..41f8342225 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/EnumeratedSmokeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/EnumeratedSmokeTest.java @@ -76,14 +76,13 @@ public class EnumeratedSmokeTest extends BaseUnitTestCase { assertThat( customType.getUserType(), instanceOf( org.hibernate.type.EnumType.class ) ); final org.hibernate.type.EnumType hibernateMappingEnumType = (org.hibernate.type.EnumType) customType.getUserType(); assertThat( hibernateMappingEnumType.isOrdinal(), is(expectedJpaEnumType==EnumType.ORDINAL) ); - assertThat( hibernateMappingEnumType.sqlTypes().length, is(1) ); final int expectedJdbcTypeCode = jdbcRegistry.getDescriptor( expectedJpaEnumType == EnumType.ORDINAL ? Types.TINYINT : Types.VARCHAR ).getJdbcTypeCode(); assertThat( - hibernateMappingEnumType.sqlTypes()[0], + hibernateMappingEnumType.getSqlType(), is( expectedJdbcTypeCode ) ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/FirstLetterType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/FirstLetterType.java index cd8796f71f..721152ca7e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/FirstLetterType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/FirstLetterType.java @@ -21,8 +21,8 @@ import org.hibernate.orm.test.annotations.enumerated.enums.FirstLetter; public class FirstLetterType extends org.hibernate.type.EnumType { @Override - public int[] sqlTypes() { - return new int[] { Types.VARCHAR }; + public int getSqlType() { + return Types.VARCHAR; } @Override @@ -38,7 +38,7 @@ public class FirstLetterType extends org.hibernate.type.EnumType { public void nullSafeSet(PreparedStatement st, FirstLetter value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { if ( value == null ) { - st.setNull( index, sqlTypes()[0] ); + st.setNull( index, getSqlType() ); } else { String enumString = value.name(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/LastNumberType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/LastNumberType.java index d73ea8df50..d5a0f08c43 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/LastNumberType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/custom_types/LastNumberType.java @@ -21,8 +21,8 @@ import org.hibernate.orm.test.annotations.enumerated.enums.LastNumber; public class LastNumberType extends org.hibernate.type.EnumType { @Override - public int[] sqlTypes() { - return new int[] { Types.VARCHAR }; + public int getSqlType() { + return Types.VARCHAR; } @Override @@ -38,7 +38,7 @@ public class LastNumberType extends org.hibernate.type.EnumType { public void nullSafeSet(PreparedStatement st, LastNumber value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { if ( value == null ) { - st.setNull( index, sqlTypes()[0] ); + st.setNull( index, getSqlType() ); } else { String enumString = value.name(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/mappedSuperclass/EnumeratedWithMappedSuperclassTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/mappedSuperclass/EnumeratedWithMappedSuperclassTest.java index adfad838b9..93a1c79528 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/mappedSuperclass/EnumeratedWithMappedSuperclassTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/enumerated/mappedSuperclass/EnumeratedWithMappedSuperclassTest.java @@ -73,14 +73,14 @@ public class EnumeratedWithMappedSuperclassTest extends BaseUnitTestCase { final Property natureProperty = addressLevelBinding.getProperty( "nature" ); CustomType customType = assertTyping( CustomType.class, natureProperty.getType() ); EnumType enumType = assertTyping( EnumType.class, customType.getUserType() ); - assertEquals( Types.VARCHAR, enumType.sqlTypes()[0] ); + assertEquals( Types.VARCHAR, enumType.getSqlType() ); SessionFactoryImplementor sf = (SessionFactoryImplementor) metadata.buildSessionFactory(); try { EntityPersister p = sf.getRuntimeMetamodels().getMappingMetamodel().getEntityDescriptor(AddressLevel.class.getName()); CustomType runtimeType = assertTyping( CustomType.class, p.getPropertyType( "nature" ) ); EnumType runtimeEnumType = assertTyping( EnumType.class, runtimeType.getUserType() ); - assertEquals( Types.VARCHAR, runtimeEnumType.sqlTypes()[0] ); + assertEquals( Types.VARCHAR, runtimeEnumType.getSqlType() ); } finally { sf.close(); diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/StateType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/StateType.java index f0d471eaaf..36a8ee5b1f 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/StateType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/generics/StateType.java @@ -22,21 +22,21 @@ import org.hibernate.usertype.UserType; * @author Emmanuel Bernard */ public class StateType implements UserType { - public int[] sqlTypes() { - return new int[] { - Types.INTEGER - }; + + @Override + public int getSqlType() { + return Types.INTEGER; } - public Class returnedClass() { + public Class returnedClass() { return State.class; } - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(State x, State y) throws HibernateException { return x == y; } - public int hashCode(Object x) throws HibernateException { + public int hashCode(State x) throws HibernateException { return x.hashCode(); } @@ -57,7 +57,7 @@ public class StateType implements UserType { } } - public Object deepCopy(Object value) throws HibernateException { + public State deepCopy(State value) throws HibernateException { return value; } @@ -65,15 +65,15 @@ public class StateType implements UserType { return false; } - public Serializable disassemble(Object value) throws HibernateException { - return (Serializable) value; + public Serializable disassemble(State value) throws HibernateException { + return value; } - public Object assemble(Serializable cached, Object owner) throws HibernateException { - return cached; + public State assemble(Serializable cached, Object owner) throws HibernateException { + return (State) cached; } - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public State replace(State original, State target, Object owner) throws HibernateException { return original; } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyStringType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyStringType.java index 455f69f72a..93a427868b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyStringType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/annotations/type/dynamicparameterized/MyStringType.java @@ -106,8 +106,8 @@ public class MyStringType implements UserType, DynamicParameterizedType } @Override - public int[] sqlTypes() { - return new int[] { Types.VARCHAR }; + public int getSqlType() { + return Types.VARCHAR; } @Override @@ -116,17 +116,17 @@ public class MyStringType implements UserType, DynamicParameterizedType } @Override - public boolean equals(Object x, Object y) { + public boolean equals(String x, String y) { return ( x == null && y == null ) || ( x != null && y != null && x.equals( y ) ); } @Override - public int hashCode(Object x) { + public int hashCode(String x) { return x.hashCode(); } @Override - public Object deepCopy(Object value) { + public String deepCopy(String value) { return value; } @@ -136,17 +136,17 @@ public class MyStringType implements UserType, DynamicParameterizedType } @Override - public Serializable disassemble(Object value) { - return (Integer) value; + public Serializable disassemble(String value) { + return value; } @Override - public Object assemble(Serializable cached, Object owner) { - return cached; + public String assemble(Serializable cached, Object owner) { + return (String) cached; } @Override - public Object replace(Object original, Object target, Object owner) { + public String replace(String original, String target, Object owner) { return original; } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ClassificationType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ClassificationType.java index fb95ebf51c..0852994e6c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ClassificationType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/hql/ClassificationType.java @@ -15,7 +15,6 @@ import java.sql.Types; import org.hibernate.HibernateException; import org.hibernate.engine.spi.SharedSessionContractImplementor; -import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.descriptor.ValueExtractor; import org.hibernate.type.descriptor.WrapperOptions; import org.hibernate.usertype.EnhancedUserType; @@ -32,17 +31,17 @@ import org.hibernate.usertype.EnhancedUserType; public class ClassificationType implements EnhancedUserType, ValueExtractor { @Override - public int[] sqlTypes() { - return new int[] { Types.TINYINT }; + public int getSqlType() { + return Types.TINYINT; } @Override - public Class returnedClass() { + public Class returnedClass() { return Classification.class; } @Override - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(Classification x, Classification y) throws HibernateException { if ( x == null && y == null ) { return false; } @@ -55,7 +54,7 @@ public class ClassificationType implements EnhancedUserType, Val } @Override - public int hashCode(Object x) throws HibernateException { + public int hashCode(Classification x) throws HibernateException { return x.hashCode(); } @@ -79,7 +78,7 @@ public class ClassificationType implements EnhancedUserType, Val } @Override - public Object deepCopy(Object value) throws HibernateException { + public Classification deepCopy(Classification value) throws HibernateException { return value; } @@ -89,17 +88,17 @@ public class ClassificationType implements EnhancedUserType, Val } @Override - public Serializable disassemble(Object value) throws HibernateException { + public Serializable disassemble(Classification value) throws HibernateException { return ( Classification ) value; } @Override - public Object assemble(Serializable cached, Object owner) throws HibernateException { - return cached; + public Classification assemble(Serializable cached, Object owner) throws HibernateException { + return (Classification) cached; } @Override - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public Classification replace(Classification original, Classification target, Object owner) throws HibernateException { return original; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java index 2e3b939935..13532db939 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeComparableIdTest.java @@ -125,8 +125,8 @@ public class UserTypeComparableIdTest { public static class CustomIdType implements UserType, Comparator { @Override - public int[] sqlTypes() { - return new int[] { Types.BIGINT }; + public int getSqlType() { + return Types.BIGINT; } @Override @@ -162,17 +162,17 @@ public class UserTypeComparableIdTest { } @Override - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(CustomId x, CustomId y) throws HibernateException { return x.equals( y ); } @Override - public int hashCode(Object x) throws HibernateException { + public int hashCode(CustomId x) throws HibernateException { return x.hashCode(); } @Override - public Object deepCopy(Object value) throws HibernateException { + public CustomId deepCopy(CustomId value) throws HibernateException { return value; } @@ -182,17 +182,17 @@ public class UserTypeComparableIdTest { } @Override - public Serializable disassemble(Object value) throws HibernateException { - return (Serializable) value; + public Serializable disassemble(CustomId value) throws HibernateException { + return value; } @Override - public Object assemble(Serializable cached, Object owner) throws HibernateException { - return cached; + public CustomId assemble(Serializable cached, Object owner) throws HibernateException { + return (CustomId) cached; } @Override - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public CustomId replace(CustomId original, CustomId target, Object owner) throws HibernateException { return original; } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java index 2564840eeb..57e4efb536 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/id/usertype/UserTypeNonComparableIdTest.java @@ -112,8 +112,8 @@ public class UserTypeNonComparableIdTest { public static class CustomIdType implements UserType { @Override - public int[] sqlTypes() { - return new int[] { Types.BIGINT }; + public int getSqlType() { + return Types.BIGINT; } @Override @@ -139,22 +139,22 @@ public class UserTypeNonComparableIdTest { } @Override - public Class returnedClass() { + public Class returnedClass() { return CustomId.class; } @Override - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(CustomId x, CustomId y) throws HibernateException { return x.equals( y ); } @Override - public int hashCode(Object x) throws HibernateException { + public int hashCode(CustomId x) throws HibernateException { return x.hashCode(); } @Override - public Object deepCopy(Object value) throws HibernateException { + public CustomId deepCopy(CustomId value) throws HibernateException { return value; } @@ -164,17 +164,17 @@ public class UserTypeNonComparableIdTest { } @Override - public Serializable disassemble(Object value) throws HibernateException { - return (Serializable) value; + public Serializable disassemble(CustomId value) throws HibernateException { + return value; } @Override - public Object assemble(Serializable cached, Object owner) throws HibernateException { - return cached; + public CustomId assemble(Serializable cached, Object owner) throws HibernateException { + return (CustomId) cached; } @Override - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public CustomId replace(CustomId original, CustomId target, Object owner) throws HibernateException { return original; } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/QueryParametersValidationTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/QueryParametersValidationTest.java index d56c0a7db0..a63d66e5b8 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/QueryParametersValidationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/QueryParametersValidationTest.java @@ -113,8 +113,8 @@ public class QueryParametersValidationTest extends BaseEntityManagerFunctionalTe public static class BooleanUserType implements UserType { @Override - public int[] sqlTypes() { - return new int[] { Types.CHAR }; + public int getSqlType() { + return Types.CHAR; } @Override @@ -123,12 +123,12 @@ public class QueryParametersValidationTest extends BaseEntityManagerFunctionalTe } @Override - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(Boolean x, Boolean y) throws HibernateException { return Objects.equals( x, y); } @Override - public int hashCode(Object x) throws HibernateException { + public int hashCode(Boolean x) throws HibernateException { return Objects.hashCode(x); } @@ -147,7 +147,7 @@ public class QueryParametersValidationTest extends BaseEntityManagerFunctionalTe } @Override - public Object deepCopy(Object value) throws HibernateException { + public Boolean deepCopy(Boolean value) throws HibernateException { return value; } @@ -157,17 +157,17 @@ public class QueryParametersValidationTest extends BaseEntityManagerFunctionalTe } @Override - public Serializable disassemble(Object value) throws HibernateException { + public Serializable disassemble(Boolean value) throws HibernateException { return null; } @Override - public Object assemble(Serializable cached, Object owner) throws HibernateException { + public Boolean assemble(Serializable cached, Object owner) throws HibernateException { return null; } @Override - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public Boolean replace(Boolean original, Boolean target, Object owner) throws HibernateException { return null; } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/TypedValueParametersTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/TypedValueParametersTest.java index 22e8519adc..c6bad7a22e 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/TypedValueParametersTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/jpa/query/TypedValueParametersTest.java @@ -10,6 +10,7 @@ import java.io.Serializable; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Types; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -20,6 +21,7 @@ import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.query.TypedParameterValue; import org.hibernate.type.CustomType; +import org.hibernate.type.SqlTypes; import org.hibernate.usertype.UserType; import org.hibernate.testing.orm.junit.EntityManagerFactoryScope; @@ -139,12 +141,10 @@ public class TypedValueParametersTest { public static class TagUserType implements UserType> { public static final TagUserType INSTANCE = new TagUserType(); - private final int SQLTYPE = java.sql.Types.VARCHAR; - @Override public void nullSafeSet(PreparedStatement statement, List list, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { if ( list == null ) { - statement.setNull(index, SQLTYPE); + statement.setNull( index, SqlTypes.VARCHAR ); } else { StringBuilder sb = new StringBuilder(); @@ -183,8 +183,10 @@ public class TypedValueParametersTest { return list; } - public int[] sqlTypes() { - return new int[]{SQLTYPE}; + + @Override + public int getSqlType() { + return Types.VARCHAR; } @Override @@ -194,28 +196,28 @@ public class TypedValueParametersTest { } @Override - public Object assemble(final Serializable cached, final Object owner) throws HibernateException { - return cached; + public List assemble(final Serializable cached, final Object owner) throws HibernateException { + return (List) cached; } @Override @SuppressWarnings("unchecked") - public Object deepCopy(final Object o) throws HibernateException { - return o == null ? null : new ArrayList<>((List) o); + public List deepCopy(final List o) throws HibernateException { + return o == null ? null : new ArrayList<>( o ); } @Override - public Serializable disassemble(final Object o) throws HibernateException { + public Serializable disassemble(final List o) throws HibernateException { return (Serializable) o; } @Override - public boolean equals(final Object x, final Object y) throws HibernateException { + public boolean equals(final List x, final List y) throws HibernateException { return x == null ? y == null : x.equals(y); } @Override - public int hashCode(final Object o) throws HibernateException { + public int hashCode(final List o) throws HibernateException { return o == null ? 0 : o.hashCode(); } @@ -225,7 +227,7 @@ public class TypedValueParametersTest { } @Override - public Object replace(final Object original, final Object target, final Object owner) throws HibernateException { + public List replace(final List original, final List target, final Object owner) throws HibernateException { return original; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/EnumUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/EnumUserType.java index 9d4c30ca63..0ea2f7f55c 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/EnumUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/mapping/usertypes/EnumUserType.java @@ -19,15 +19,15 @@ import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.usertype.ParameterizedType; import org.hibernate.usertype.UserType; -public class EnumUserType implements UserType, ParameterizedType { +public class EnumUserType> implements UserType, ParameterizedType { - private Class clazz = null; + private Class clazz = null; - public static EnumUserType createInstance(Class clazz) { + public static > EnumUserType createInstance(Class clazz) { if ( !clazz.isEnum() ) { throw new IllegalArgumentException( "Parameter has to be an enum-class" ); } - EnumUserType that = new EnumUserType(); + EnumUserType that = new EnumUserType<>(); Properties p = new Properties(); p.setProperty( "enumClassName", clazz.getName() ); that.setParameterValues( p ); @@ -41,7 +41,8 @@ public class EnumUserType implements UserType, ParameterizedType { } try { - this.clazz = Class.forName( enumClassName ); + //noinspection unchecked + this.clazz = (Class) Class.forName( enumClassName ); } catch (ClassNotFoundException e) { throw new MappingException( "enumClass " + enumClassName + " not found", e ); @@ -51,18 +52,17 @@ public class EnumUserType implements UserType, ParameterizedType { } } - private static final int[] SQL_TYPES = {Types.CHAR}; - - public int[] sqlTypes() { - return SQL_TYPES; + @Override + public int getSqlType() { + return Types.CHAR; } - public Class returnedClass() { + public Class returnedClass() { return clazz; } @Override - public Object nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { + public T nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { final String name = rs.getString( position ); if ( rs.wasNull() ) { return null; @@ -72,24 +72,23 @@ public class EnumUserType implements UserType, ParameterizedType { public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index) throws HibernateException, SQLException { - if ( null == value ) { - preparedStatement.setNull( index, Types.VARCHAR ); - } - else { - preparedStatement.setString( index, ( (Enum) value ).name() ); - } } @Override public void nullSafeSet( PreparedStatement preparedStatement, - Object value, + T value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { - nullSafeSet( preparedStatement, value, index ); + if ( null == value ) { + preparedStatement.setNull( index, Types.VARCHAR ); + } + else { + preparedStatement.setString( index, value.name() ); + } } - public Object deepCopy(Object value) throws HibernateException { + public T deepCopy(T value) throws HibernateException { return value; } @@ -97,23 +96,24 @@ public class EnumUserType implements UserType, ParameterizedType { return false; } - public Object assemble(Serializable cached, Object owner) throws HibernateException { - return cached; + public T assemble(Serializable cached, Object owner) throws HibernateException { + //noinspection unchecked + return (T) cached; } - public Serializable disassemble(Object value) throws HibernateException { - return (Serializable) value; + public Serializable disassemble(T value) throws HibernateException { + return value; } - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public T replace(T original, T target, Object owner) throws HibernateException { return original; } - public int hashCode(Object x) throws HibernateException { + public int hashCode(T x) throws HibernateException { return x.hashCode(); } - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(T x, T y) throws HibernateException { if ( x == y ) { return true; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdType.java index a6ef8fb81a..a44b7cd2b4 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/rowid/RowIdType.java @@ -21,13 +21,14 @@ import org.hibernate.usertype.UserType; /** * @author Gavin King */ -public class RowIdType implements UserType { +public class RowIdType implements UserType{ - public int[] sqlTypes() { - return new int[] { Types.JAVA_OBJECT }; + @Override + public int getSqlType() { + return Types.JAVA_OBJECT; } - public Class returnedClass() { + public Class returnedClass() { return Object.class; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/BasicTypeRegistryTest.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/BasicTypeRegistryTest.java index 2aaaffd53c..e8748ebcea 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/type/BasicTypeRegistryTest.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/BasicTypeRegistryTest.java @@ -10,6 +10,7 @@ import java.io.Serializable; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; +import java.sql.Types; import java.util.UUID; import org.hibernate.HibernateException; @@ -117,15 +118,15 @@ public class BasicTypeRegistryTest extends BaseUnitTestCase { } } - public static class TotallyIrrelevantUserType implements UserType { + public static class TotallyIrrelevantUserType implements UserType { @Override - public int[] sqlTypes() { - return new int[0]; + public int getSqlType() { + return Types.VARCHAR; } @Override - public Class returnedClass() { + public Class returnedClass() { return null; } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/ArrayType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/ArrayType.java index 62eda1ff9e..5fa5a97e8b 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/ArrayType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/ArrayType.java @@ -37,8 +37,8 @@ public class ArrayType implements UserType, BindableType { } @Override - public int[] sqlTypes() { - return new int[] { jdbcType.getJdbcTypeCode() }; + public int getSqlType() { + return jdbcType.getJdbcTypeCode(); } @Override @@ -47,13 +47,13 @@ public class ArrayType implements UserType, BindableType { } @Override - public boolean equals(Object x, Object y) throws HibernateException { - return javaType.areEqual( (Array) x, (Array) y ); + public boolean equals(Array x, Array y) throws HibernateException { + return javaType.areEqual( x, y ); } @Override - public int hashCode(Object x) throws HibernateException { - return javaType.extractHashCode( (Array) x ); + public int hashCode(Array x) throws HibernateException { + return javaType.extractHashCode( x ); } @Override @@ -68,8 +68,8 @@ public class ArrayType implements UserType, BindableType { } @Override - public Object deepCopy(Object value) throws HibernateException { - return ArrayMutabilityPlan.INSTANCE.deepCopy( (Array) value ); + public Array deepCopy(Array value) throws HibernateException { + return ArrayMutabilityPlan.INSTANCE.deepCopy( value ); } @Override @@ -78,17 +78,17 @@ public class ArrayType implements UserType, BindableType { } @Override - public Serializable disassemble(Object value) throws HibernateException { - return ArrayMutabilityPlan.INSTANCE.disassemble( (Array) value, null ); + public Serializable disassemble(Array value) throws HibernateException { + return ArrayMutabilityPlan.INSTANCE.disassemble( value, null ); } @Override - public Object assemble(Serializable cached, Object owner) throws HibernateException { + public Array assemble(Serializable cached, Object owner) throws HibernateException { return ArrayMutabilityPlan.INSTANCE.assemble( cached, null ); } @Override - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public Array replace(Array original, Array target, Object owner) throws HibernateException { return null; } } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/StringWrapperUserType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/StringWrapperUserType.java index 0168d1b1fb..957dfa30ae 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/StringWrapperUserType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/type/contributor/usertype/StringWrapperUserType.java @@ -29,8 +29,8 @@ public class StringWrapperUserType implements UserType { private static final Logger log = Logger.getLogger( StringWrapperUserType.class ); @Override - public int[] sqlTypes() { - return new int[] { Types.VARCHAR }; + public int getSqlType() { + return Types.VARCHAR; } @Override @@ -39,13 +39,13 @@ public class StringWrapperUserType implements UserType { } @Override - public boolean equals(Object x, Object y) + public boolean equals(StringWrapper x, StringWrapper y) throws HibernateException { return Objects.equals( x, y ); } @Override - public int hashCode(Object x) + public int hashCode(StringWrapper x) throws HibernateException { return Objects.hashCode( x ); } @@ -66,7 +66,7 @@ public class StringWrapperUserType implements UserType { st.setNull( index, Types.VARCHAR ); } else { - String stringValue = toString( (StringWrapper) value ); + String stringValue = toString( value ); log.debugv("Binding {0} to parameter {1} ", stringValue, index); st.setString( index, stringValue ); } @@ -83,7 +83,7 @@ public class StringWrapperUserType implements UserType { } @Override - public Object deepCopy(Object value) + public StringWrapper deepCopy(StringWrapper value) throws HibernateException { return value; } @@ -94,19 +94,19 @@ public class StringWrapperUserType implements UserType { } @Override - public Serializable disassemble(Object value) + public Serializable disassemble(StringWrapper value) throws HibernateException { - return (StringWrapper) deepCopy( value ); + return deepCopy( value ); } @Override - public Object assemble(Serializable cached, Object owner) + public StringWrapper assemble(Serializable cached, Object owner) throws HibernateException { - return deepCopy( cached ); + return deepCopy( (StringWrapper) cached ); } @Override - public Object replace(Object original, Object target, Object owner) + public StringWrapper replace(StringWrapper original, StringWrapper target, Object owner) throws HibernateException { return deepCopy( original ); } diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/typeparameters/DefaultValueIntegerType.java b/hibernate-core/src/test/java/org/hibernate/orm/test/typeparameters/DefaultValueIntegerType.java index b8287f0fcf..c90ad62bab 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/typeparameters/DefaultValueIntegerType.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/typeparameters/DefaultValueIntegerType.java @@ -24,20 +24,21 @@ import org.jboss.logging.Logger; /** * @author Michi */ -public class DefaultValueIntegerType implements UserType, ParameterizedType, Serializable { +public class DefaultValueIntegerType implements UserType, ParameterizedType, Serializable { private static final Logger log = Logger.getLogger( DefaultValueIntegerType.class ); private Integer defaultValue; - public int[] sqlTypes() { - return new int[] {Types.INTEGER}; + @Override + public int getSqlType() { + return Types.INTEGER; } public Class returnedClass() { return int.class; } - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(Integer x, Integer y) throws HibernateException { if ( x == y ) { return true; } @@ -48,13 +49,13 @@ public class DefaultValueIntegerType implements UserType, ParameterizedType, Ser } @Override - public Object nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { + public Integer nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { Number result = (Number) rs.getObject( position ); return result == null ? defaultValue : Integer.valueOf( result.intValue() ); } @Override - public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) + public void nullSafeSet(PreparedStatement st, Integer value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { if ( value == null || defaultValue.equals( value ) ) { log.trace( "binding null to parameter: " + index ); @@ -62,32 +63,32 @@ public class DefaultValueIntegerType implements UserType, ParameterizedType, Ser } else { log.trace( "binding " + value + " to parameter: " + index ); - st.setInt( index, ( (Integer) value ).intValue() ); + st.setInt( index, value ); } } - public Object deepCopy(Object value) throws HibernateException { - return new Integer( ( (Integer) value ).intValue() ); + public Integer deepCopy(Integer value) throws HibernateException { + return value; } public boolean isMutable() { return false; } - public int hashCode(Object x) throws HibernateException { + public int hashCode(Integer x) throws HibernateException { return x.hashCode(); } - public Object assemble(Serializable cached, Object owner) + public Integer assemble(Serializable cached, Object owner) throws HibernateException { - return cached; + return (Integer) cached; } - public Serializable disassemble(Object value) throws HibernateException { - return (Serializable) value; + public Serializable disassemble(Integer value) throws HibernateException { + return value; } - public Object replace(Object original, Object target, Object owner) + public Integer replace(Integer original, Integer target, Object owner) throws HibernateException { return original; } diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/RevisionTypeType.java b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/RevisionTypeType.java index b7a4534ba9..cbb17cbfac 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/RevisionTypeType.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/internal/entities/RevisionTypeType.java @@ -23,23 +23,21 @@ import org.hibernate.usertype.UserType; * * @author Adam Warski (adam at warski dot org) */ -public class RevisionTypeType implements UserType, Serializable { +public class RevisionTypeType implements UserType, Serializable { private static final long serialVersionUID = -1053201518229282688L; - private static final int[] SQL_TYPES = {Types.TINYINT}; - @Override - public int[] sqlTypes() { - return SQL_TYPES; + public int getSqlType() { + return Types.TINYINT; } @Override - public Class returnedClass() { + public Class returnedClass() { return RevisionType.class; } @Override - public Object nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { + public RevisionType nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { byte byteValue = rs.getByte( position ); if ( rs.wasNull() ) { return null; @@ -48,7 +46,7 @@ public class RevisionTypeType implements UserType, Serializable { } @Override - public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index, SharedSessionContractImplementor session) + public void nullSafeSet(PreparedStatement preparedStatement, RevisionType value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { if ( value == null ) { preparedStatement.setNull( index, Types.TINYINT ); @@ -59,7 +57,7 @@ public class RevisionTypeType implements UserType, Serializable { } @Override - public Object deepCopy(Object value) throws HibernateException { + public RevisionType deepCopy(RevisionType value) throws HibernateException { return value; } @@ -69,27 +67,27 @@ public class RevisionTypeType implements UserType, Serializable { } @Override - public Object assemble(Serializable cached, Object owner) throws HibernateException { - return cached; + public RevisionType assemble(Serializable cached, Object owner) throws HibernateException { + return (RevisionType) cached; } @Override - public Serializable disassemble(Object value) throws HibernateException { - return (Serializable) value; + public Serializable disassemble(RevisionType value) throws HibernateException { + return value; } @Override - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public RevisionType replace(RevisionType original, RevisionType target, Object owner) throws HibernateException { return original; } @Override - public int hashCode(Object x) throws HibernateException { + public int hashCode(RevisionType x) throws HibernateException { return x.hashCode(); } @Override - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(RevisionType x, RevisionType y) throws HibernateException { return Objects.equals( x, y ); } } diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/customtype/ParametrizedTestUserType.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/customtype/ParametrizedTestUserType.java index 6609cadc6c..c83d646c44 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/customtype/ParametrizedTestUserType.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/customtype/ParametrizedTestUserType.java @@ -24,7 +24,6 @@ import org.hibernate.usertype.UserType; * @author Adam Warski (adam at warski dot org) */ public class ParametrizedTestUserType implements UserType, ParameterizedType { - private static final int[] TYPES = new int[] {Types.VARCHAR}; private String param1; private String param2; @@ -58,23 +57,24 @@ public class ParametrizedTestUserType implements UserType, Parameterized .bind( st, value, index, session ); } - public int[] sqlTypes() { - return TYPES; + @Override + public int getSqlType() { + return Types.VARCHAR; } - public Object assemble(Serializable cached, Object owner) throws HibernateException { - return cached; + public String assemble(Serializable cached, Object owner) throws HibernateException { + return (String) cached; } - public Object deepCopy(Object value) throws HibernateException { + public String deepCopy(String value) throws HibernateException { return value; } - public Serializable disassemble(Object value) throws HibernateException { - return (Serializable) value; + public Serializable disassemble(String value) throws HibernateException { + return value; } - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(String x, String y) throws HibernateException { //noinspection ObjectEquality if ( x == y ) { return true; @@ -87,7 +87,7 @@ public class ParametrizedTestUserType implements UserType, Parameterized return x.equals( y ); } - public int hashCode(Object x) throws HibernateException { + public int hashCode(String x) throws HibernateException { return x.hashCode(); } @@ -95,7 +95,7 @@ public class ParametrizedTestUserType implements UserType, Parameterized return false; } - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public String replace(String original, String target, Object owner) throws HibernateException { return original; } } diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/ids/CustomEnumUserType.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/ids/CustomEnumUserType.java index 97b9a04f13..d431288055 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/ids/CustomEnumUserType.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/entities/ids/CustomEnumUserType.java @@ -20,17 +20,17 @@ import org.hibernate.usertype.UserType; * @author Slawek Garwol (slawekgarwol at gmail dot com) */ public class CustomEnumUserType implements UserType { - private static final int[] SQL_TYPES = {Types.VARCHAR}; - public int[] sqlTypes() { - return SQL_TYPES; + @Override + public int getSqlType() { + return Types.VARCHAR; } - public Class returnedClass() { + public Class returnedClass() { return CustomEnum.class; } - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(CustomEnum x, CustomEnum y) throws HibernateException { if ( x == y ) { return true; } @@ -40,7 +40,7 @@ public class CustomEnumUserType implements UserType { return x.equals( y ); } - public int hashCode(Object x) throws HibernateException { + public int hashCode(CustomEnum x) throws HibernateException { return (x == null) ? 0 : x.hashCode(); } @@ -63,7 +63,7 @@ public class CustomEnumUserType implements UserType { } } - public Object deepCopy(Object value) throws HibernateException { + public CustomEnum deepCopy(CustomEnum value) throws HibernateException { return value; } @@ -71,15 +71,15 @@ public class CustomEnumUserType implements UserType { return false; } - public Serializable disassemble(Object value) throws HibernateException { - return (Serializable) value; + public Serializable disassemble(CustomEnum value) throws HibernateException { + return value; } - public Object assemble(Serializable cached, Object owner) throws HibernateException { - return cached; + public CustomEnum assemble(Serializable cached, Object owner) throws HibernateException { + return (CustomEnum) cached; } - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public CustomEnum replace(CustomEnum original, CustomEnum target, Object owner) throws HibernateException { return original; } } diff --git a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java index 3ee4149120..073b62f6df 100644 --- a/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java +++ b/hibernate-envers/src/test/java/org/hibernate/orm/test/envers/integration/components/dynamic/AgeType.java @@ -16,13 +16,11 @@ import org.hibernate.HibernateException; import org.hibernate.engine.spi.SharedSessionContractImplementor; import org.hibernate.usertype.UserType; -public class AgeType implements UserType { +public class AgeType implements UserType { @Override - public int[] sqlTypes() { - return new int[] { - Types.INTEGER - }; + public int getSqlType() { + return Types.INTEGER; } @Override @@ -31,29 +29,29 @@ public class AgeType implements UserType { } @Override - public boolean equals(Object x, Object y) throws HibernateException { + public boolean equals(Age x, Age y) throws HibernateException { return x != null ? x.equals( y ) : y == null; } @Override - public int hashCode(Object x) throws HibernateException { + public int hashCode(Age x) throws HibernateException { return x != null ? x.hashCode() : 1; } @Override - public Object nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { + public Age nullSafeGet(ResultSet rs, int position, SharedSessionContractImplementor session, Object owner) throws SQLException { return new Age( rs.getInt( position ) ); } @Override - public void nullSafeSet(PreparedStatement st, Object value, int index, SharedSessionContractImplementor session) + public void nullSafeSet(PreparedStatement st, Age value, int index, SharedSessionContractImplementor session) throws HibernateException, SQLException { - st.setInt( index, ( (Age) value ).getAgeInYears() ); + st.setInt( index, value.getAgeInYears() ); } @Override - public Object deepCopy(Object value) throws HibernateException { - return new Age( ( (Age) value ).getAgeInYears() ); + public Age deepCopy(Age value) throws HibernateException { + return new Age( value.getAgeInYears() ); } @Override @@ -62,17 +60,17 @@ public class AgeType implements UserType { } @Override - public Serializable disassemble(Object value) throws HibernateException { + public Serializable disassemble(Age value) throws HibernateException { return null; } @Override - public Object assemble(Serializable cached, Object owner) throws HibernateException { + public Age assemble(Serializable cached, Object owner) throws HibernateException { return null; } @Override - public Object replace(Object original, Object target, Object owner) throws HibernateException { + public Age replace(Age original, Age target, Object owner) throws HibernateException { return null; } } diff --git a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/collectionbasictype/CommaDelimitedStringMapJavaType.java b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/collectionbasictype/CommaDelimitedStringMapJavaType.java index ec5127ac97..f020cac02b 100644 --- a/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/collectionbasictype/CommaDelimitedStringMapJavaType.java +++ b/tooling/metamodel-generator/src/test/java/org/hibernate/jpamodelgen/test/collectionbasictype/CommaDelimitedStringMapJavaType.java @@ -16,39 +16,40 @@ import org.hibernate.type.descriptor.java.MutableMutabilityPlan; /** * @author Vlad Mihalcea */ -public class CommaDelimitedStringMapJavaType extends AbstractClassJavaType { +public class CommaDelimitedStringMapJavaType extends AbstractClassJavaType> { - public static final String DELIMITER = ","; + public static final String DELIMITER = ","; - public CommaDelimitedStringMapJavaType() { - super( - Map.class, - new MutableMutabilityPlan() { - @Override - protected Map deepCopyNotNull(Map value) { - return new HashMap( value ); - } - } - ); - } + public CommaDelimitedStringMapJavaType() { + //noinspection unchecked + super( + (Class>) (Class) Map.class, + new MutableMutabilityPlan<>() { + @Override + protected Map deepCopyNotNull(Map value) { + return new HashMap<>( value ); + } + } + ); + } - @Override - public String toString(Map value) { - return null; - } + @Override + public String toString(Map value) { + return null; + } - @Override - public Map fromString(CharSequence string) { - return null; - } + @Override + public Map fromString(CharSequence string) { + return null; + } - @Override - public X unwrap(Map value, Class type, WrapperOptions options) { - return (X) toString( value ); - } + @Override + public X unwrap(Map value, Class type, WrapperOptions options) { + return (X) toString( value ); + } - @Override - public Map wrap(X value, WrapperOptions options) { - return fromString( (String) value ); - } + @Override + public Map wrap(X value, WrapperOptions options) { + return fromString( (String) value ); + } }