-
- All Known Implementing Classes:
MongoDbColumn
public interface DbColumn
Column data and metadata.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <T> T
as(GenericType<T> type)
Value of this column as a generic type.<T> T
as(Class<T> type)
Typed value of this column.String
dbType()
Type of the column in the language of the database.Class<?>
javaType()
Type of the column as would be returned by the underlying database driver.String
name()
Column name.default Optional<Integer>
precision()
Precision of this column.default Optional<Integer>
scale()
Scale of this column.default Object
value()
Untyped value of this column, returns java type as provided by the underlying database driver.
-
-
-
Method Detail
-
as
<T> T as(Class<T> type) throws MapperException
Typed value of this column. This method can return a correct result only if the type is the same asjavaType()
or there is aMapper
registered that can map it.- Type Parameters:
T
- type of the returned value- Parameters:
type
- class of the type that should be returned (must be supported by the underlying data type)- Returns:
- value of this column correctly typed
- Throws:
MapperException
- in case the type is not the underlyingjavaType()
and there is no mapper registered for it
-
as
<T> T as(GenericType<T> type) throws MapperException
Value of this column as a generic type. This method can return a correct result only if the type represents a class, or if there is aMapper
registered that can map underlyingjavaType()
to the type requested.- Type Parameters:
T
- type of the returned value- Parameters:
type
- requested type- Returns:
- value mapped to the expected type if possible
- Throws:
MapperException
- in case the mapping cannot be done
-
value
default Object value()
Untyped value of this column, returns java type as provided by the underlying database driver.- Returns:
- value of this column
-
javaType
Class<?> javaType()
Type of the column as would be returned by the underlying database driver.- Returns:
- class of the type
- See Also:
dbType()
-
dbType
String dbType()
Type of the column in the language of the database.Example for SQL - if a column is declared as
VARCHAR(256)
in the database, this method would returnVARCHAR
and methodjavaType()
would returnString
.- Returns:
- column type as the database understands it
-
name
String name()
Column name.- Returns:
- name of this column
-
precision
default Optional<Integer> precision()
Precision of this column.Precision depends on data type:
- Numeric: The maximal number of digits of the number
- String/Character: The maximal length
- Binary: The maximal number of bytes
- Other: Implementation specific
- Returns:
- precision of this column or
empty
if precision is not available
-
-