- java.lang.Object
-
- org.jooq.impl.DefaultDataType<T>
-
- All Implemented Interfaces:
Serializable
,DataType<T>
@Internal public class DefaultDataType<T> extends 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, Class<T> type, String typeName)
DefaultDataType(SQLDialect dialect, Class<T> type, String typeName, String castTypeName)
DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, String typeName)
DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, String typeName, 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(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(Class<E> enumDataType)
Retrieve the data type for a given enum data type.CharacterSet
characterSet()
Get the character set of this data type, ornull
if 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.Collation
collation()
Get the collation of this data type, ornull
if 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.T
convert(Object object)
Convert an arbitrary object into<T>
.T[]
convert(Object... objects)
Convert an arbitrary set of objects into<T>
.List<T>
convert(Collection<?> objects)
Convert an arbitrary set of objects into<T>
.Field<T>
default_()
The expression to be applied as theDEFAULT
value for this data type.DataType<T>
default_(Field<T> d)
Specify an expression to be applied as theDEFAULT
value for this data type.DataType<T>
default_(T d)
Specify an expression to be applied as theDEFAULT
value for this data type.boolean
defaulted()
Get the defaultability of this data type.DataType<T>
defaulted(boolean d)
Deprecated.Field<T>
defaultValue()
The expression to be applied as theDEFAULT
value for this data type.DataType<T>
defaultValue(Field<T> d)
Specify an expression to be applied as theDEFAULT
value for this data type.DataType<T>
defaultValue(T d)
Specify an expression to be applied as theDEFAULT
value for this data type.boolean
equals(Object obj)
DataType<T[]>
getArrayDataType()
Retrieve the data type for an ARRAY of this data type.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.String
getCastTypeName()
Retrieve the dialect-specific type name associated with this data type used for casting.String
getCastTypeName(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, Class<T> type)
static <T> DataType<T>
getDataType(SQLDialect dialect, Class<T> type, DataType<T> fallbackDataType)
static DataType<?>
getDataType(SQLDialect dialect, String typeName)
static DataType<?>
getDataType(SQLDialect dialect, String t, int p, int s)
Convert a type name (using precision and scale) into a Java classstatic DataType<Object>
getDefaultDataType(String typeName)
static DataType<Object>
getDefaultDataType(SQLDialect dialect, String typeName)
SQLDialect
getDialect()
Retrieve the underlyingSQLDialect
.DataType<T>
getSQLDataType()
Get the standard SQL data type of this (dialect-specific) data type if available.int
getSQLType()
Get JDBCTypes
value.int
getSQLType(Configuration configuration)
Get the dialect-specific JDBCTypes
value.Class<T>
getType()
Retrieve the Java type associated with this data type.static Class<?>
getType(SQLDialect dialect, String t, int p, int s)
Convert a type name (using precision and scale) into a Java classString
getTypeName()
Retrieve the dialect-specific type name associated with this data type.String
getTypeName(Configuration configuration)
Retrieve the dialect-specific type name associated with this data type.int
hashCode()
boolean
hasLength()
Whether this data type has a length.boolean
hasPrecision()
Whether this data type has a precision.boolean
hasScale()
Whether this data type has a scale.boolean
identity()
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.boolean
isArray()
Whether this data type is an array type.boolean
isBinary()
Whether this data type is any binary type.boolean
isDate()
Whether this data type is any date type.boolean
isDateTime()
Whether this data type is any date or time type.boolean
isEnum()
Whether this data type is an enum type.boolean
isInterval()
Whether this data type is any interval type.boolean
isLob()
Whether this data type is best deserialised as aLOB
.boolean
isNumeric()
Whether this data type is any numeric data type.boolean
isString()
Whether this data type is any character data type.boolean
isTemporal()
Whether this data type is any date or time type.boolean
isTime()
Whether this data type is any time type.boolean
isTimestamp()
Whether this data type is any timestamp type.boolean
isUDT()
Whether this data type is a UDT type.int
length()
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 String
normalise(String typeName)
Nullability
nullability()
Get the nullability of this data type.DataType<T>
nullability(Nullability n)
Return a new data type like this, with a new nullability.boolean
nullable()
Get the nullability of this data type.DataType<T>
nullable(boolean n)
Return a new data type like this, with a new nullability.int
precision()
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.int
scale()
Get the scale of this data type.DataType<T>
scale(int s)
Return a new data type like this, with a new scale value.String
toString()
-
-
-
Constructor Detail
-
DefaultDataType
public DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, String typeName)
-
DefaultDataType
public DefaultDataType(SQLDialect dialect, DataType<T> sqlDataType, String typeName, String castTypeName)
-
DefaultDataType
public DefaultDataType(SQLDialect dialect, Class<T> type, String typeName)
-
DefaultDataType
public DefaultDataType(SQLDialect dialect, Class<T> type, String typeName, String castTypeName)
-
-
Method Detail
-
nullability
public final DataType<T> nullability(Nullability n)
Description copied from interface:DataType
Return a new data type like this, with a new nullability.[#5709] A
nullable
column cannot have anDataType.identity()
.- Specified by:
nullability
in interfaceDataType<T>
- Parameters:
n
- The new nullability- Returns:
- The new data type
-
nullability
public final Nullability nullability()
Description copied from interface:DataType
Get the nullability of this data type.- Specified by:
nullability
in interfaceDataType<T>
- Returns:
- The nullability
-
nullable
public final DataType<T> nullable(boolean n)
Description copied from interface:DataType
Return a new data type like this, with a new nullability.This is the same as calling
DataType.nullability(Nullability)
with any ofNullability.NULL
orNullability.NOT_NULL
as an argument.[#5709] A
nullable
column cannot have anDataType.identity()
.
-
nullable
public final boolean nullable()
Description copied from interface:DataType
Get the nullability of this data type.This returns
true
by default, i.e. ifDataType.nullability()
isNullability.DEFAULT
.
-
collation
public final DataType<T> collation(Collation c)
Description copied from interface:DataType
Return a new data type like this, with a new collation.
-
collation
public final Collation collation()
Description copied from interface:DataType
Get the collation of this data type, ornull
if there is no collation, or if the default collation applies.
-
characterSet
public final DataType<T> characterSet(CharacterSet c)
Description copied from interface:DataType
Return a new data type like this, with a new character set.- Specified by:
characterSet
in interfaceDataType<T>
-
characterSet
public final CharacterSet characterSet()
Description copied from interface:DataType
Get the character set of this data type, ornull
if there is no character set, or if the default character set applies.- Specified by:
characterSet
in interfaceDataType<T>
-
identity
public final DataType<T> identity(boolean i)
Description copied from interface:DataType
Return 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:DataType
Get the identity flag of this data type.
-
defaultValue
public final DataType<T> defaultValue(T d)
Description copied from interface:DataType
Specify an expression to be applied as theDEFAULT
value for this data type.[#5709] A
defaulted
column cannot have anDataType.identity()
.This is an alias for
DataType.default_(Object)
.- Specified by:
defaultValue
in interfaceDataType<T>
- See Also:
DataType.defaultValue(Field)
-
defaultValue
public final DataType<T> defaultValue(Field<T> d)
Description copied from interface:DataType
Specify an expression to be applied as theDEFAULT
value for this data type.A default value of a data type applies to DDL statements, such as
CREATE TABLE
ALTER TABLE
The distinct types of possible
DEFAULT
expressions 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:
defaultValue
in interfaceDataType<T>
-
defaultValue
public final Field<T> defaultValue()
Description copied from interface:DataType
The expression to be applied as theDEFAULT
value for this data type.This is an alias for
DataType.default_()
.- Specified by:
defaultValue
in interfaceDataType<T>
- Returns:
- The default value if present, or
null
if 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:DataType
Specify an expression to be applied as theDEFAULT
value for this data type.[#5709] A
defaulted
column 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:DataType
Specify an expression to be applied as theDEFAULT
value for this data type.A default value of a data type applies to DDL statements, such as
CREATE TABLE
ALTER TABLE
The distinct types of possible
DEFAULT
expressions 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:DataType
The expression to be applied as theDEFAULT
value for this data type.- Specified by:
default_
in interfaceDataType<T>
- Returns:
- The default value if present, or
null
if 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:DataType
Return a new data type like this, with a new defaultability.
-
defaulted
public final boolean defaulted()
Description copied from interface:DataType
Get the defaultability of this data type.
-
precision
public final DataType<T> precision(int p)
Description copied from interface:DataType
Return a new data type like this, with a new precision value.This will have no effect if
DataType.hasPrecision()
isfalse
This 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:DataType
Return a new data type like this, with a new precision and scale value.This will have no effect if
DataType.hasPrecision()
isfalse
, or ifscale > 0
andDataType.hasScale()
isfalse
-
precision
public final int precision()
Description copied from interface:DataType
Get the precision of this data type.
-
hasPrecision
public final boolean hasPrecision()
Description copied from interface:DataType
Whether this data type has a precision.- Specified by:
hasPrecision
in interfaceDataType<T>
- Returns:
- Whether this data type has a precision
-
scale
public final DataType<T> scale(int s)
Description copied from interface:DataType
Return 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:DataType
Get the scale of this data type.
-
hasScale
public final boolean hasScale()
Description copied from interface:DataType
Whether this data type has a scale.
-
length
public final DataType<T> length(int l)
Description copied from interface:DataType
Return 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:DataType
Get the length of this data type.
-
hasLength
public final boolean hasLength()
Description copied from interface:DataType
Whether this data type has a length.
-
getSQLDataType
public final DataType<T> getSQLDataType()
Description copied from interface:DataType
Get the standard SQL data type of this (dialect-specific) data type if available.- Specified by:
getSQLDataType
in interfaceDataType<T>
-
getDataType
public final DataType<T> getDataType(Configuration configuration)
Description copied from interface:DataType
The dialect-specific data type representing this data type.- Specified by:
getDataType
in interfaceDataType<T>
-
getSQLType
public int getSQLType()
Description copied from interface:DataType
Get JDBCTypes
value.- Specified by:
getSQLType
in interfaceDataType<T>
-
getSQLType
public final int getSQLType(Configuration configuration)
Description copied from interface:DataType
Get the dialect-specific JDBCTypes
value.- Specified by:
getSQLType
in interfaceDataType<T>
-
getType
public final Class<T> getType()
Description copied from interface:DataType
Retrieve the Java type associated with this data type.
-
getBinding
public final Binding<?,T> getBinding()
Description copied from interface:DataType
Get the data type binding associated with this data type.- Specified by:
getBinding
in interfaceDataType<T>
-
getConverter
public final Converter<?,T> getConverter()
Description copied from interface:DataType
Get the converter associated with this data type.- Specified by:
getConverter
in interfaceDataType<T>
-
getArrayType
public final Class<T[]> getArrayType()
Description copied from interface:DataType
Retrieve the Java type associated with ARRAYs of this data type.- Specified by:
getArrayType
in interfaceDataType<T>
-
getTypeName
public final String getTypeName()
Description copied from interface:DataType
Retrieve the dialect-specific type name associated with this data type.- Specified by:
getTypeName
in interfaceDataType<T>
-
getTypeName
public String getTypeName(Configuration configuration)
Description copied from interface:DataType
Retrieve the dialect-specific type name associated with this data type.- Specified by:
getTypeName
in interfaceDataType<T>
-
getCastTypeName
public final String getCastTypeName()
Description copied from interface:DataType
Retrieve 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:
getCastTypeName
in interfaceDataType<T>
-
getCastTypeName
public String getCastTypeName(Configuration configuration)
Description copied from interface:DataType
Retrieve 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:
getCastTypeName
in interfaceDataType<T>
-
getArrayDataType
public final DataType<T[]> getArrayDataType()
Description copied from interface:DataType
Retrieve the data type for an ARRAY of this data type.- Specified by:
getArrayDataType
in interfaceDataType<T>
-
asArrayDataType
@Pro public final <A extends ArrayRecord<?>> DataType<A> asArrayDataType(Class<A> arrayDataType)
Description copied from interface:DataType
Retrieve the data type for an Oracle-style ARRAY of this data type.- Specified by:
asArrayDataType
in interfaceDataType<T>
-
asEnumDataType
public final <E extends EnumType> DataType<E> asEnumDataType(Class<E> enumDataType)
Description copied from interface:DataType
Retrieve the data type for a given enum data type.- Specified by:
asEnumDataType
in interfaceDataType<T>
-
asConvertedDataType
public <U> DataType<U> asConvertedDataType(Converter<? super T,U> converter)
Description copied from interface:DataType
Retrieve the data type for a given converter.- Specified by:
asConvertedDataType
in interfaceDataType<T>
-
asConvertedDataType
public <U> DataType<U> asConvertedDataType(Binding<? super T,U> newBinding)
Description copied from interface:DataType
Retrieve the data type for a given binding.- Specified by:
asConvertedDataType
in interfaceDataType<T>
-
getDialect
public final SQLDialect getDialect()
Description copied from interface:DataType
Retrieve the underlyingSQLDialect
.- Specified by:
getDialect
in interfaceDataType<T>
-
convert
public T convert(Object object)
Description copied from interface:DataType
Convert an arbitrary object into<T>
.See
Convert.convert(Object, Class)
for details about conversion rules.
-
convert
public final T[] convert(Object... objects)
Description copied from interface:DataType
Convert an arbitrary set of objects into<T>
.See
Convert.convert(Object, Class)
for details about conversion rules.
-
convert
public final List<T> convert(Collection<?> objects)
Description copied from interface:DataType
Convert an arbitrary set of objects into<T>
.See
Convert.convert(Object, Class)
for details about conversion rules.
-
getDefaultDataType
public static final DataType<Object> getDefaultDataType(SQLDialect dialect, String typeName)
-
getDataType
public static final DataType<?> getDataType(SQLDialect dialect, String typeName)
-
getDataType
public static final <T> DataType<T> getDataType(SQLDialect dialect, Class<T> type)
-
getDataType
public static final <T> DataType<T> getDataType(SQLDialect dialect, Class<T> type, DataType<T> fallbackDataType)
-
isNumeric
public final boolean isNumeric()
Description copied from interface:DataType
Whether this data type is any numeric data type.This applies to any of these types:
-
isString
public final boolean isString()
Description copied from interface:DataType
Whether this data type is any character data type.This applies to any of these types:
-
isDateTime
public final boolean isDateTime()
Description copied from interface:DataType
Whether this data type is any date or time type.This applies to any of these types.
- Specified by:
isDateTime
in interfaceDataType<T>
- See Also:
DataType.isDate()
-
isDate
public final boolean isDate()
Description copied from interface:DataType
Whether this data type is any date type.This applies to any of these types.
-
isTimestamp
public final boolean isTimestamp()
Description copied from interface:DataType
Whether this data type is any timestamp type.This applies to any of these types.
- Specified by:
isTimestamp
in interfaceDataType<T>
-
isTime
public final boolean isTime()
Description copied from interface:DataType
Whether this data type is any time type.This applies to any of these types.
-
isTemporal
public final boolean isTemporal()
Description copied from interface:DataType
Whether 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:
isTemporal
in interfaceDataType<T>
-
-
isInterval
public final boolean isInterval()
Description copied from interface:DataType
Whether this data type is any interval type.This applies to any of these types.
- Specified by:
isInterval
in interfaceDataType<T>
-
isLob
public final boolean isLob()
Description copied from interface:DataType
Whether this data type is best deserialised as aLOB
.This applies to any of these types.
-
isBinary
public final boolean isBinary()
Description copied from interface:DataType
Whether this data type is any binary type.This applies to any of these types.
-
isArray
public final boolean isArray()
Description copied from interface:DataType
Whether this data type is an array type.
-
isUDT
public final boolean isUDT()
Description copied from interface:DataType
Whether this data type is a UDT type.
-
isEnum
public final boolean isEnum()
Description copied from interface:DataType
Whether this data type is an enum type.
-
normalise
public static final String normalise(String typeName)
- Returns:
- The type name without all special characters and white spaces
-
getDataType
public static final DataType<?> getDataType(SQLDialect dialect, 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 Class<?> getType(SQLDialect dialect, String t, int p, int s) throws SQLDialectNotSupportedException
Convert a type name (using precision and scale) into a Java class- Throws:
SQLDialectNotSupportedException
-
-