Interface JavaType<T>
-
- All Superinterfaces:
Serializable
- All Known Subinterfaces:
BasicJavaType<T>,PrimitiveJavaType<J>,TemporalJavaType<T>,VersionJavaType<T>
- All Known Implementing Classes:
AbstractArrayJavaType,AbstractClassJavaType,AbstractJavaType,AbstractTemporalJavaType,ArrayJavaType,BasicCollectionJavaType,BigDecimalJavaType,BigIntegerJavaType,BlobJavaType,BooleanJavaType,BooleanPrimitiveArrayJavaType,ByteArrayJavaType,ByteJavaType,CalendarDateJavaType,CalendarJavaType,CalendarTimeJavaType,CharacterArrayJavaType,CharacterJavaType,ClassJavaType,ClobJavaType,CollectionJavaType,CurrencyJavaType,DateJavaType,DbTimestampJavaType,DoubleJavaType,DoublePrimitiveArrayJavaType,DurationJavaType,DynamicModelJavaType,EntityJavaType,EnumJavaType,FloatJavaType,FloatPrimitiveArrayJavaType,InetAddressJavaType,InstantJavaType,IntegerJavaType,IntegerPrimitiveArrayJavaType,JavaTypeBasicAdaptor,JdbcDateJavaType,JdbcTimeJavaType,JdbcTimestampJavaType,LocalDateJavaType,LocalDateTimeJavaType,LocaleJavaType,LocalTimeJavaType,LongJavaType,LongPrimitiveArrayJavaType,MapEntryJavaType,NClobJavaType,ObjectArrayJavaType,ObjectJavaType,OffsetDateTimeJavaType,OffsetTimeJavaType,PrimitiveByteArrayJavaType,PrimitiveCharacterArrayJavaType,RowVersionJavaType,SerializableJavaType,ShortJavaType,ShortPrimitiveArrayJavaType,StringJavaType,TimeZoneJavaType,UnknownBasicJavaType,UrlJavaType,UUIDJavaType,YearJavaType,ZonedDateTimeJavaType,ZoneIdJavaType,ZoneOffsetJavaType
public interface JavaType<T> extends Serializable
Descriptor for the Java side of a value mapping.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceJavaType.CoercionContext
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default booleanareEqual(T one, T another)Determine if two instances are equaldefault <X> Tcoerce(X value, JavaType.CoercionContext coercionContext)default JavaType<T>createJavaType(ParameterizedType parameterizedType)Deprecated.default JavaType<T>createJavaType(ParameterizedType parameterizedType, TypeConfiguration typeConfiguration)Creates theJavaTypefor the givenParameterizedTypebased on thisJavaTyperegistered for the raw type.default intextractHashCode(T value)Extract a proper hash code for this value.default StringextractLoggableRepresentation(T value)Extract a loggable representation of the value.TfromString(CharSequence string)default StringgetCheckCondition(String columnName, JdbcType sqlType, Dialect dialect)The check constraint that should be added to the column definition in generated DDL.default Comparator<T>getComparator()Retrieve the natural comparator for this type.default longgetDefaultSqlLength(Dialect dialect, JdbcType jdbcType)The default column length when this Java type is mapped to a SQL data type which is parametrized by length, for exampleTypes.VARCHAR.default intgetDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType)The default column precision when this Java type is mapped to a SQL data type which is parametrized by precision, for exampleTypes.DECIMAL.default intgetDefaultSqlScale(Dialect dialect, JdbcType jdbcType)The default column scale when this Java type is mapped to a SQL data type which is parametrized by scale, for exampleTypes.DECIMAL.default TgetDefaultValue()Get this Java type's default value.default TypegetJavaType()Get the Java type (Type) describeddefault Class<T>getJavaTypeClass()Get the Java type (Class) describeddefault longgetLongSqlLength()The default column length when this Java type is mapped to a column of typeTypes.LONGVARCHARorTypes.LONGVARBINARY.default MutabilityPlan<T>getMutabilityPlan()Retrieve the mutability plan for this Java type.JdbcTypegetRecommendedJdbcType(JdbcTypeIndicators context)Obtain the "recommended" SQL type descriptor for this Java type.default TgetReplacement(T original, T target, SharedSessionContractImplementor session)default booleanisInstance(Object value)Is the given value an instance of the described type? Generally this comes down togetJavaTypeClass().isInstance(), though some descriptors (mainly the java.sql.Date, Time and Timestamp descriptors) might need different semanticsdefault booleanisWider(JavaType<?> javaType)Returns whether this java type is wider than the given type i.e.default StringtoString(T value)<X> Xunwrap(T value, Class<X> type, WrapperOptions options)Unwrap an instance of our handled Java type into the requested type.<X> Twrap(X value, WrapperOptions options)Wrap a value as our handled Java type.
-
-
-
Method Detail
-
getJavaType
default Type getJavaType()
Get the Java type (Type) described- See Also:
getJavaTypeClass()
-
getJavaTypeClass
default Class<T> getJavaTypeClass()
Get the Java type (Class) described- See Also:
getJavaType()
-
isInstance
default boolean isInstance(Object value)
Is the given value an instance of the described type? Generally this comes down togetJavaTypeClass().isInstance(), though some descriptors (mainly the java.sql.Date, Time and Timestamp descriptors) might need different semantics
-
getMutabilityPlan
default MutabilityPlan<T> getMutabilityPlan()
Retrieve the mutability plan for this Java type.
-
getReplacement
default T getReplacement(T original, T target, SharedSessionContractImplementor session)
-
getDefaultValue
default T getDefaultValue()
Get this Java type's default value.- Returns:
- The default value.
-
getRecommendedJdbcType
JdbcType getRecommendedJdbcType(JdbcTypeIndicators context)
Obtain the "recommended" SQL type descriptor for this Java type. The recommended aspect comes from the JDBC spec (mostly).- Parameters:
context- Contextual information- Returns:
- The recommended SQL type descriptor
-
getDefaultSqlLength
default long getDefaultSqlLength(Dialect dialect, JdbcType jdbcType)
The default column length when this Java type is mapped to a SQL data type which is parametrized by length, for exampleTypes.VARCHAR.- Returns:
Size.DEFAULT_LENGTHunless overridden
-
getLongSqlLength
default long getLongSqlLength()
The default column length when this Java type is mapped to a column of typeTypes.LONGVARCHARorTypes.LONGVARBINARY.- Returns:
Size.LONG_LENGTHunless overridden
-
getDefaultSqlPrecision
default int getDefaultSqlPrecision(Dialect dialect, JdbcType jdbcType)
The default column precision when this Java type is mapped to a SQL data type which is parametrized by precision, for exampleTypes.DECIMAL.- Returns:
Size.DEFAULT_PRECISIONunless overridden
-
getDefaultSqlScale
default int getDefaultSqlScale(Dialect dialect, JdbcType jdbcType)
The default column scale when this Java type is mapped to a SQL data type which is parametrized by scale, for exampleTypes.DECIMAL.- Returns:
Size.DEFAULT_SCALEunless overridden
-
getComparator
default Comparator<T> getComparator()
Retrieve the natural comparator for this type.
-
extractHashCode
default int extractHashCode(T value)
Extract a proper hash code for this value.- Parameters:
value- The value for which to extract a hash code.- Returns:
- The extracted hash code.
-
areEqual
default boolean areEqual(T one, T another)
Determine if two instances are equal- Parameters:
one- One instanceanother- The other instance- Returns:
- True if the two are considered equal; false otherwise.
-
extractLoggableRepresentation
default String extractLoggableRepresentation(T value)
Extract a loggable representation of the value.- Parameters:
value- The value for which to extract a loggable representation.- Returns:
- The loggable representation
-
fromString
T fromString(CharSequence string)
-
unwrap
<X> X unwrap(T value, Class<X> type, WrapperOptions options)
Unwrap an instance of our handled Java type into the requested type. As an example, if this is aJavaType<Integer>and we are asked to unwrap theInteger valueas aLongwe would return something likeLong.valueOf( value.longValue() ). Intended use is duringPreparedStatementbinding.- Type Parameters:
X- The conversion type.- Parameters:
value- The value to unwraptype- The type as which to unwrapoptions- The options- Returns:
- The unwrapped value.
-
wrap
<X> T wrap(X value, WrapperOptions options)
Wrap a value as our handled Java type. Intended use is duringResultSetextraction.- Type Parameters:
X- The conversion type.- Parameters:
value- The value to wrap.options- The options- Returns:
- The wrapped value.
-
isWider
default boolean isWider(JavaType<?> javaType)
Returns whether this java type is wider than the given type i.e. if the given type can be widened to this java type.
-
coerce
default <X> T coerce(X value, JavaType.CoercionContext coercionContext)
-
getCheckCondition
default String getCheckCondition(String columnName, JdbcType sqlType, Dialect dialect)
The check constraint that should be added to the column definition in generated DDL.
-
createJavaType
@Deprecated(since="6.1") default JavaType<T> createJavaType(ParameterizedType parameterizedType)
Deprecated.Creates theJavaTypefor the givenParameterizedTypebased on thisJavaTyperegistered for the raw type.
-
createJavaType
default JavaType<T> createJavaType(ParameterizedType parameterizedType, TypeConfiguration typeConfiguration)
Creates theJavaTypefor the givenParameterizedTypebased on thisJavaTyperegistered for the raw type.- Since:
- 6.1
-
-