DB_TYPE
- the type as it is represented in the JDBC driverJAVA_TYPE
- the type as it should be represented in generated codepublic interface TypeMapper<DB_TYPE,JAVA_TYPE>
TypeMapperComponent
.Modifier and Type | Interface and Description |
---|---|
static class |
TypeMapper.Category
Which category the
getJavaType(Column) result belong to. |
static class |
TypeMapper.Ordering
Indicates how the ordering of mapped vs un-mapped types relate to each
other.
|
Modifier and Type | Field and Description |
---|---|
static Comparator<TypeMapper<?,?>> |
COMPARATOR
The standard comparator to use for instances of the
TypeMapper
interface. |
Modifier and Type | Method and Description |
---|---|
Type |
getJavaType(Column column)
Returns a type describing the resulting java type when this mapper is
applied to a database result.
|
default TypeMapper.Category |
getJavaTypeCategory(Column column)
Returns the
TypeMapper.Category of the type returned by
getJavaType(Column) . |
String |
getLabel()
Returns the label for this mapper that should appear to the end user.
|
default TypeMapper.Ordering |
getOrdering()
Returns how the
TypeMapper.Ordering of mapped and un-mapped types relate
to each other. |
static <T> TypeMapper<T,T> |
identity()
Returns an identity type mapper.
|
static <T> TypeMapper<T,T> |
primitive()
Returns an primitive type mapper.
|
DB_TYPE |
toDatabaseType(JAVA_TYPE value)
Converts a value from the java domain to the database domain.
|
JAVA_TYPE |
toJavaType(Column column,
Class<?> entityType,
DB_TYPE value)
Converts a value from the database domain to the java domain.
|
static final Comparator<TypeMapper<?,?>> COMPARATOR
TypeMapper
interface. This comparator will use the name of the database type as
comparison index and if two mappers share the same database type, it will
use the label in alphabetical order.String getLabel()
Type getJavaType(Column column)
column
- the column that is being mappeddefault TypeMapper.Category getJavaTypeCategory(Column column)
TypeMapper.Category
of the type returned by
getJavaType(Column)
.column
- the columnJAVA_TYPE toJavaType(Column column, Class<?> entityType, DB_TYPE value)
column
- the column that is being mappedentityType
- the entity type that the mapping is forvalue
- the value to convertDB_TYPE toDatabaseType(JAVA_TYPE value)
value
- the value to convertdefault TypeMapper.Ordering getOrdering()
TypeMapper.Ordering
of mapped and un-mapped types relate
to each other.
Speedment is using this method to determine if certain optimizations of streams can be made. Make sure to implicitly specify the Ordering in any custom TypeMapper to allow maximum execution speed.
Specifying TypeMapper.Ordering.UNSPECIFIED
prevents some optimizations so
if possible, write a TypeMapper that RETAINS ordering.
TypeMapper.Ordering.RETAIN
,
TypeMapper.Ordering.INVERT
,
TypeMapper.Ordering.UNSPECIFIED
static <T> TypeMapper<T,T> identity()
T
- the type of the identity type mapperstatic <T> TypeMapper<T,T> primitive()
T
- the wrapper type of the primitive type mapperCopyright © 2019 Speedment, Inc.. All rights reserved.