Class DefaultDataType<T>
- java.lang.Object
-
- org.jooq.impl.DefaultDataType<T>
-
- All Implemented Interfaces:
java.io.Serializable,DataType<T>
@Internal public class DefaultDataType<T> extends java.lang.Object implements DataType<T>
A common base class for data types.This also acts as a static data type registry for jOOQ internally.
This type is for JOOQ INTERNAL USE only. Do not reference directly
- Author:
- Lukas Eder
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description DefaultDataType(SQLDialect dialect, java.lang.Class<T> type, java.lang.String typeName)DefaultDataType(SQLDialect dialect, java.lang.Class<T> type, java.lang.String typeName, java.lang.String castTypeName)DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, java.lang.String typeName)DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, java.lang.String typeName, java.lang.String castTypeName)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description <A extends ArrayRecord<?>>
DataType<A>asArrayDataType(java.lang.Class<A> arrayDataType)Retrieve the data type for an Oracle-style ARRAY of this data type.<U> DataType<U>asConvertedDataType(Binding<? super T,U> newBinding)Retrieve the data type for a given binding.<U> DataType<U>asConvertedDataType(Converter<? super T,U> converter)Retrieve the data type for a given converter.<E extends EnumType>
DataType<E>asEnumDataType(java.lang.Class<E> enumDataType)Retrieve the data type for a given enum data type.CharacterSetcharacterSet()Get the character set of this data type, ornullif there is no character set, or if the default character set applies.DataType<T>characterSet(CharacterSet c)Return a new data type like this, with a new character set.Collationcollation()Get the collation of this data type, ornullif there is no collation, or if the default collation applies.DataType<T>collation(Collation c)Return a new data type like this, with a new collation.Tconvert(java.lang.Object object)Convert an arbitrary object into<T>.T[]convert(java.lang.Object... objects)Convert an arbitrary set of objects into<T>.java.util.List<T>convert(java.util.Collection<?> objects)Convert an arbitrary set of objects into<T>.Field<T>default_()The expression to be applied as theDEFAULTvalue for this data type.DataType<T>default_(Field<T> d)Specify an expression to be applied as theDEFAULTvalue for this data type.DataType<T>default_(T d)Specify an expression to be applied as theDEFAULTvalue for this data type.booleandefaulted()Get the defaultability of this data type.DataType<T>defaulted(boolean d)Deprecated.Field<T>defaultValue()The expression to be applied as theDEFAULTvalue for this data type.DataType<T>defaultValue(Field<T> d)Specify an expression to be applied as theDEFAULTvalue for this data type.DataType<T>defaultValue(T d)Specify an expression to be applied as theDEFAULTvalue for this data type.booleanequals(java.lang.Object obj)DataType<T[]>getArrayDataType()Retrieve the data type for an ARRAY of this data type.java.lang.Class<T[]>getArrayType()Retrieve the Java type associated with ARRAYs of this data type.Binding<?,T>getBinding()Get the data type binding associated with this data type.java.lang.StringgetCastTypeName()Retrieve the dialect-specific type name associated with this data type used for casting.java.lang.StringgetCastTypeName(Configuration configuration)Retrieve the dialect-specific type name associated with this data type used for casting.Converter<?,T>getConverter()Get the converter associated with this data type.DataType<T>getDataType(Configuration configuration)The dialect-specific data type representing this data type.static <T> DataType<T>getDataType(SQLDialect dialect, java.lang.Class<T> type)static <T> DataType<T>getDataType(SQLDialect dialect, java.lang.Class<T> type, DataType<T> fallbackDataType)static DataType<?>getDataType(SQLDialect dialect, java.lang.String typeName)static DataType<?>getDataType(SQLDialect dialect, java.lang.String t, int p, int s)Convert a type name (using precision and scale) into a Java classstatic DataType<java.lang.Object>getDefaultDataType(java.lang.String typeName)static DataType<java.lang.Object>getDefaultDataType(SQLDialect dialect, java.lang.String typeName)SQLDialectgetDialect()Retrieve the underlyingSQLDialect.DataType<T>getSQLDataType()Get the standard SQL data type of this (dialect-specific) data type if available.intgetSQLType()Get JDBCTypesvalue.intgetSQLType(Configuration configuration)Get the dialect-specific JDBCTypesvalue.java.lang.Class<T>getType()Retrieve the Java type associated with this data type.static java.lang.Class<?>getType(SQLDialect dialect, java.lang.String t, int p, int s)Convert a type name (using precision and scale) into a Java classjava.lang.StringgetTypeName()Retrieve the dialect-specific type name associated with this data type.java.lang.StringgetTypeName(Configuration configuration)Retrieve the dialect-specific type name associated with this data type.inthashCode()booleanhasLength()Whether this data type has a length.booleanhasPrecision()Whether this data type has a precision.booleanhasScale()Whether this data type has a scale.booleanidentity()Get the identity flag of this data type.DataType<T>identity(boolean i)Return a new data type like this, with a new identity flag.booleanisArray()Whether this data type is an array type.booleanisBinary()Whether this data type is any binary type.booleanisDate()Whether this data type is any date type.booleanisDateTime()Whether this data type is any date or time type.booleanisEnum()Whether this data type is an enum type.booleanisInterval()Whether this data type is any interval type.booleanisLob()Whether this data type is best deserialised as aLOB.booleanisNumeric()Whether this data type is any numeric data type.booleanisString()Whether this data type is any character data type.booleanisTemporal()Whether this data type is any date or time type.booleanisTime()Whether this data type is any time type.booleanisTimestamp()Whether this data type is any timestamp type.booleanisUDT()Whether this data type is a UDT type.intlength()Get the length of this data type.DataType<T>length(int l)Return a new data type like this, with a new length value.static java.lang.Stringnormalise(java.lang.String typeName)Nullabilitynullability()Get the nullability of this data type.DataType<T>nullability(Nullability n)Return a new data type like this, with a new nullability.booleannullable()Get the nullability of this data type.DataType<T>nullable(boolean n)Return a new data type like this, with a new nullability.intprecision()Get the precision of this data type.DataType<T>precision(int p)Return a new data type like this, with a new precision value.DataType<T>precision(int p, int s)Return a new data type like this, with a new precision and scale value.intscale()Get the scale of this data type.DataType<T>scale(int s)Return a new data type like this, with a new scale value.java.lang.StringtoString()
-
-
-
Constructor Detail
-
DefaultDataType
public DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, java.lang.String typeName)
-
DefaultDataType
public DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, java.lang.String typeName, java.lang.String castTypeName)
-
DefaultDataType
public DefaultDataType(SQLDialect dialect, java.lang.Class<T> type, java.lang.String typeName)
-
DefaultDataType
public DefaultDataType(SQLDialect dialect, java.lang.Class<T> type, java.lang.String typeName, java.lang.String castTypeName)
-
-
Method Detail
-
nullability
public final DataType<T> nullability(Nullability n)
Description copied from interface:DataTypeReturn a new data type like this, with a new nullability.[#5709] A
nullablecolumn cannot have anDataType.identity().- Specified by:
nullabilityin interfaceDataType<T>- Parameters:
n- The new nullability- Returns:
- The new data type
-
nullability
public final Nullability nullability()
Description copied from interface:DataTypeGet the nullability of this data type.- Specified by:
nullabilityin interfaceDataType<T>- Returns:
- The nullability
-
nullable
public final DataType<T> nullable(boolean n)
Description copied from interface:DataTypeReturn a new data type like this, with a new nullability.This is the same as calling
DataType.nullability(Nullability)with any ofNullability.NULLorNullability.NOT_NULLas an argument.[#5709] A
nullablecolumn cannot have anDataType.identity().
-
nullable
public final boolean nullable()
Description copied from interface:DataTypeGet the nullability of this data type.This returns
trueby default, i.e. ifDataType.nullability()isNullability.DEFAULT.
-
collation
public final DataType<T> collation(Collation c)
Description copied from interface:DataTypeReturn a new data type like this, with a new collation.
-
collation
public final Collation collation()
Description copied from interface:DataTypeGet the collation of this data type, ornullif there is no collation, or if the default collation applies.
-
characterSet
public final DataType<T> characterSet(CharacterSet c)
Description copied from interface:DataTypeReturn a new data type like this, with a new character set.- Specified by:
characterSetin interfaceDataType<T>
-
characterSet
public final CharacterSet characterSet()
Description copied from interface:DataTypeGet the character set of this data type, ornullif there is no character set, or if the default character set applies.- Specified by:
characterSetin interfaceDataType<T>
-
identity
public final DataType<T> identity(boolean i)
Description copied from interface:DataTypeReturn a new data type like this, with a new identity flag.[#5709] The IDENTITY flag imposes a NOT NULL constraint, and removes all DEFAULT values.
-
identity
public final boolean identity()
Description copied from interface:DataTypeGet the identity flag of this data type.
-
defaultValue
public final DataType<T> defaultValue(T d)
Description copied from interface:DataTypeSpecify an expression to be applied as theDEFAULTvalue for this data type.[#5709] A
defaultedcolumn cannot have anDataType.identity().This is an alias for
DataType.default_(Object).- Specified by:
defaultValuein interfaceDataType<T>- See Also:
DataType.defaultValue(Field)
-
defaultValue
public final DataType<T> defaultValue(Field<T> d)
Description copied from interface:DataTypeSpecify an expression to be applied as theDEFAULTvalue for this data type.A default value of a data type applies to DDL statements, such as
CREATE TABLEALTER TABLE
The distinct types of possible
DEFAULTexpressions is defined by the underlying database. Please refer to your database manual to learn what expressions are possible.This is an alias for
DataType.default_(Field).- Specified by:
defaultValuein interfaceDataType<T>
-
defaultValue
public final Field<T> defaultValue()
Description copied from interface:DataTypeThe expression to be applied as theDEFAULTvalue for this data type.This is an alias for
DataType.default_().- Specified by:
defaultValuein interfaceDataType<T>- Returns:
- The default value if present, or
nullif no default value is specified for this data type. - See Also:
DataType.defaultValue(Field)
-
default_
public final DataType<T> default_(T d)
Description copied from interface:DataTypeSpecify an expression to be applied as theDEFAULTvalue for this data type.[#5709] A
defaultedcolumn cannot have anDataType.identity().- Specified by:
default_in interfaceDataType<T>- See Also:
DataType.defaultValue(Field)
-
default_
public final DataType<T> default_(Field<T> d)
Description copied from interface:DataTypeSpecify an expression to be applied as theDEFAULTvalue for this data type.A default value of a data type applies to DDL statements, such as
CREATE TABLEALTER TABLE
The distinct types of possible
DEFAULTexpressions is defined by the underlying database. Please refer to your database manual to learn what expressions are possible.
-
default_
public final Field<T> default_()
Description copied from interface:DataTypeThe expression to be applied as theDEFAULTvalue for this data type.- Specified by:
default_in interfaceDataType<T>- Returns:
- The default value if present, or
nullif no default value is specified for this data type. - See Also:
DataType.defaultValue(Field)
-
defaulted
@Deprecated public final DataType<T> defaulted(boolean d)
Deprecated.Description copied from interface:DataTypeReturn a new data type like this, with a new defaultability.
-
defaulted
public final boolean defaulted()
Description copied from interface:DataTypeGet the defaultability of this data type.
-
precision
public final DataType<T> precision(int p)
Description copied from interface:DataTypeReturn a new data type like this, with a new precision value.This will have no effect if
DataType.hasPrecision()isfalseThis is the same as calling
DataType.precision(int, int)withscale == 0
-
precision
public final DataType<T> precision(int p, int s)
Description copied from interface:DataTypeReturn a new data type like this, with a new precision and scale value.This will have no effect if
DataType.hasPrecision()isfalse, or ifscale > 0andDataType.hasScale()isfalse
-
precision
public final int precision()
Description copied from interface:DataTypeGet the precision of this data type.
-
hasPrecision
public final boolean hasPrecision()
Description copied from interface:DataTypeWhether this data type has a precision.- Specified by:
hasPrecisionin interfaceDataType<T>- Returns:
- Whether this data type has a precision
-
scale
public final DataType<T> scale(int s)
Description copied from interface:DataTypeReturn a new data type like this, with a new scale value.This will have no effect if
DataType.hasScale()isfalse
-
scale
public final int scale()
Description copied from interface:DataTypeGet the scale of this data type.
-
hasScale
public final boolean hasScale()
Description copied from interface:DataTypeWhether this data type has a scale.
-
length
public final DataType<T> length(int l)
Description copied from interface:DataTypeReturn a new data type like this, with a new length value.This will have no effect if
DataType.hasLength()isfalse
-
length
public final int length()
Description copied from interface:DataTypeGet the length of this data type.
-
hasLength
public final boolean hasLength()
Description copied from interface:DataTypeWhether this data type has a length.
-
getSQLDataType
public final DataType<T> getSQLDataType()
Description copied from interface:DataTypeGet the standard SQL data type of this (dialect-specific) data type if available.- Specified by:
getSQLDataTypein interfaceDataType<T>
-
getDataType
public final DataType<T> getDataType(Configuration configuration)
Description copied from interface:DataTypeThe dialect-specific data type representing this data type.- Specified by:
getDataTypein interfaceDataType<T>
-
getSQLType
public int getSQLType()
Description copied from interface:DataTypeGet JDBCTypesvalue.- Specified by:
getSQLTypein interfaceDataType<T>
-
getSQLType
public final int getSQLType(Configuration configuration)
Description copied from interface:DataTypeGet the dialect-specific JDBCTypesvalue.- Specified by:
getSQLTypein interfaceDataType<T>
-
getType
public final java.lang.Class<T> getType()
Description copied from interface:DataTypeRetrieve the Java type associated with this data type.
-
getBinding
public final Binding<?,T> getBinding()
Description copied from interface:DataTypeGet the data type binding associated with this data type.- Specified by:
getBindingin interfaceDataType<T>
-
getConverter
public final Converter<?,T> getConverter()
Description copied from interface:DataTypeGet the converter associated with this data type.- Specified by:
getConverterin interfaceDataType<T>
-
getArrayType
public final java.lang.Class<T[]> getArrayType()
Description copied from interface:DataTypeRetrieve the Java type associated with ARRAYs of this data type.- Specified by:
getArrayTypein interfaceDataType<T>
-
getTypeName
public final java.lang.String getTypeName()
Description copied from interface:DataTypeRetrieve the dialect-specific type name associated with this data type.- Specified by:
getTypeNamein interfaceDataType<T>
-
getTypeName
public java.lang.String getTypeName(Configuration configuration)
Description copied from interface:DataTypeRetrieve the dialect-specific type name associated with this data type.- Specified by:
getTypeNamein interfaceDataType<T>
-
getCastTypeName
public final java.lang.String getCastTypeName()
Description copied from interface:DataTypeRetrieve the dialect-specific type name associated with this data type used for casting.This is useful for some dialects that have specialised type names for cast expressions. Other dialects require type-length binding when casting, (e.g. VARCHAR(32767))
- Specified by:
getCastTypeNamein interfaceDataType<T>
-
getCastTypeName
public java.lang.String getCastTypeName(Configuration configuration)
Description copied from interface:DataTypeRetrieve the dialect-specific type name associated with this data type used for casting.This is useful for some dialects that have specialised type names for cast expressions. Other dialects require type-length binding when casting, (e.g. VARCHAR(32767))
- Specified by:
getCastTypeNamein interfaceDataType<T>
-
getArrayDataType
public final DataType<T[]> getArrayDataType()
Description copied from interface:DataTypeRetrieve the data type for an ARRAY of this data type.- Specified by:
getArrayDataTypein interfaceDataType<T>
-
asArrayDataType
@Pro public final <A extends ArrayRecord<?>> DataType<A> asArrayDataType(java.lang.Class<A> arrayDataType)
Description copied from interface:DataTypeRetrieve the data type for an Oracle-style ARRAY of this data type.- Specified by:
asArrayDataTypein interfaceDataType<T>
-
asEnumDataType
public final <E extends EnumType> DataType<E> asEnumDataType(java.lang.Class<E> enumDataType)
Description copied from interface:DataTypeRetrieve the data type for a given enum data type.- Specified by:
asEnumDataTypein interfaceDataType<T>
-
asConvertedDataType
public <U> DataType<U> asConvertedDataType(Converter<? super T,U> converter)
Description copied from interface:DataTypeRetrieve the data type for a given converter.- Specified by:
asConvertedDataTypein interfaceDataType<T>
-
asConvertedDataType
public <U> DataType<U> asConvertedDataType(Binding<? super T,U> newBinding)
Description copied from interface:DataTypeRetrieve the data type for a given binding.- Specified by:
asConvertedDataTypein interfaceDataType<T>
-
getDialect
public final SQLDialect getDialect()
Description copied from interface:DataTypeRetrieve the underlyingSQLDialect.- Specified by:
getDialectin interfaceDataType<T>
-
convert
public T convert(java.lang.Object object)
Description copied from interface:DataTypeConvert an arbitrary object into<T>.See
Convert.convert(Object, Class)for details about conversion rules.
-
convert
public final T[] convert(java.lang.Object... objects)
Description copied from interface:DataTypeConvert an arbitrary set of objects into<T>.See
Convert.convert(Object, Class)for details about conversion rules.
-
convert
public final java.util.List<T> convert(java.util.Collection<?> objects)
Description copied from interface:DataTypeConvert an arbitrary set of objects into<T>.See
Convert.convert(Object, Class)for details about conversion rules.
-
getDefaultDataType
public static final DataType<java.lang.Object> getDefaultDataType(java.lang.String typeName)
-
getDefaultDataType
public static final DataType<java.lang.Object> getDefaultDataType(SQLDialect dialect, java.lang.String typeName)
-
getDataType
public static final DataType<?> getDataType(SQLDialect dialect, java.lang.String typeName)
-
getDataType
public static final <T> DataType<T> getDataType(SQLDialect dialect, java.lang.Class<T> type)
-
getDataType
public static final <T> DataType<T> getDataType(SQLDialect dialect, java.lang.Class<T> type, DataType<T> fallbackDataType)
-
isNumeric
public final boolean isNumeric()
Description copied from interface:DataTypeWhether this data type is any numeric data type.This applies to any of these types:
-
isString
public final boolean isString()
Description copied from interface:DataTypeWhether this data type is any character data type.This applies to any of these types:
-
isDateTime
public final boolean isDateTime()
Description copied from interface:DataTypeWhether this data type is any date or time type.This applies to any of these types.
- Specified by:
isDateTimein interfaceDataType<T>- See Also:
DataType.isDate()
-
isDate
public final boolean isDate()
Description copied from interface:DataTypeWhether this data type is any date type.This applies to any of these types.
-
isTimestamp
public final boolean isTimestamp()
Description copied from interface:DataTypeWhether this data type is any timestamp type.This applies to any of these types.
- Specified by:
isTimestampin interfaceDataType<T>
-
isTime
public final boolean isTime()
Description copied from interface:DataTypeWhether this data type is any time type.This applies to any of these types.
-
isTemporal
public final boolean isTemporal()
Description copied from interface:DataTypeWhether this data type is any date or time type.This applies to any of these types.
-
SQLDataType.DATE -
SQLDataType.TIME -
SQLDataType.TIMESTAMP -
SQLDataType.LOCALDATE -
SQLDataType.LOCALTIME -
SQLDataType.LOCALDATETIME -
SQLDataType.OFFSETTIME -
SQLDataType.OFFSETDATETIME -
YearToSecond -
YearToMonth -
DayToSecond
This is a combination of
DataType.isDateTime()orDataType.isInterval()- Specified by:
isTemporalin interfaceDataType<T>
-
-
isInterval
public final boolean isInterval()
Description copied from interface:DataTypeWhether this data type is any interval type.This applies to any of these types.
- Specified by:
isIntervalin interfaceDataType<T>
-
isLob
public final boolean isLob()
Description copied from interface:DataTypeWhether this data type is best deserialised as aLOB.This applies to any of these types.
-
isBinary
public final boolean isBinary()
Description copied from interface:DataTypeWhether this data type is any binary type.This applies to any of these types.
-
isArray
public final boolean isArray()
Description copied from interface:DataTypeWhether this data type is an array type.
-
isUDT
public final boolean isUDT()
Description copied from interface:DataTypeWhether this data type is a UDT type.
-
isEnum
public final boolean isEnum()
Description copied from interface:DataTypeWhether this data type is an enum type.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
normalise
public static final java.lang.String normalise(java.lang.String typeName)
- Returns:
- The type name without all special characters and white spaces
-
getDataType
public static final DataType<?> getDataType(SQLDialect dialect, java.lang.String t, int p, int s) throws SQLDialectNotSupportedException
Convert a type name (using precision and scale) into a Java class- Throws:
SQLDialectNotSupportedException
-
getType
public static final java.lang.Class<?> getType(SQLDialect dialect, java.lang.String t, int p, int s) throws SQLDialectNotSupportedException
Convert a type name (using precision and scale) into a Java class- Throws:
SQLDialectNotSupportedException
-
-