java.lang.Object
io.helidon.dbclient.DbColumnBase
- All Implemented Interfaces:
OptionalValue<Object>,Value<Object>,DbColumn
- Direct Known Subclasses:
MongoDbColumn
Base
DbColumn implementation.-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDbColumnBase(Object value, MapperManager mapperManager, String... mappingQualifiers) Create a new instance. -
Method Summary
Modifier and TypeMethodDescription<N> OptionalValue<N> as(GenericType<N> type) Convert this value to a different type using a mapper.<N> OptionalValue<N> Convert this value to a different type using a mapper.<N> OptionalValue<N> Convert thisValueto a different type using a mapper function.Boolean typed value.asDouble()Double typed value.asInt()Integer typed value.asLong()Long typed value.Typed value asOptional.asString()String typed value.<T> Tget(GenericType<T> type) Value of this column as a generic type.<T> TTyped value of this column.protected <SRC,T> T map(SRC value, GenericType<T> type) Map value to target type usingMapper.protected <SRC,T> T Map value to target type usingMapper.protected ObjectrawValue()Get raw value of the database column.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.helidon.dbclient.DbColumn
dbType, get, javaType, name, precision, scaleMethods inherited from interface io.helidon.common.mapper.OptionalValue
ifPresent, ifPresentOrElse, isEmpty, isPresent, map, or, orElse, orElseGet, orElseThrow, orElseThrow
-
Constructor Details
-
DbColumnBase
Create a new instance.- Parameters:
value- valuemapperManager- mapper managermappingQualifiers- mapping qualifiers
-
-
Method Details
-
rawValue
Get raw value of the database column.- Returns:
- raw value of the column
-
get
Description copied from interface:DbColumnTyped value of this column. This method can return a correct result only if the type is the same asDbColumn.javaType()or there is aMapperregistered that can map it.- Specified by:
getin interfaceDbColumn- Specified by:
getin interfaceValue<Object>- 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 underlyingDbColumn.javaType()and there is no mapper registered for it
-
get
Description copied from interface:DbColumnValue 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 aMapperregistered that can map underlyingDbColumn.javaType()to the type requested. -
as
Description copied from interface:ValueConvert this value to a different type using a mapper.- Specified by:
asin interfaceOptionalValue<Object>- Specified by:
asin interfaceValue<Object>- Type Parameters:
N- type we expect- Parameters:
type- type to convert to- Returns:
- converted value
- Throws:
MapperException- in case the value cannot be converted
-
as
Description copied from interface:ValueConvert this value to a different type using a mapper.- Specified by:
asin interfaceOptionalValue<Object>- Specified by:
asin interfaceValue<Object>- Type Parameters:
N- type we expect- Parameters:
type- type to convert to- Returns:
- converted value
- Throws:
MapperException
-
as
Description copied from interface:ValueConvert thisValueto a different type using a mapper function. -
asOptional
Description copied from interface:ValueTyped value asOptional. Returns aemptyif this value does not have a backing value present. As this class implements all methods ofOptional, this is only a utility method if an actualOptionalinstance is needed (Optionalitself is {code final}).- Specified by:
asOptionalin interfaceValue<Object>- Returns:
- value as
Optional,emptyin case the value does not have a direct value - Throws:
MapperException- in case the value cannot be converted to the expected type- See Also:
-
asBoolean
Description copied from interface:ValueBoolean typed value. -
asString
Description copied from interface:ValueString typed value. -
asInt
Description copied from interface:ValueInteger typed value. -
asLong
Description copied from interface:ValueLong typed value. -
asDouble
Description copied from interface:ValueDouble typed value. -
map
Map value to target type usingMapper.- Type Parameters:
SRC- type of the source valueT- type of the target value- Parameters:
value- source valuetype- target type- Returns:
- result of the mapping
- Throws:
MapperException- in case the mapper was not found or failed
-
map
Map value to target type usingMapper.String.valueOf(Object)is used as fallback option whenMapperfails.- Type Parameters:
SRC- type of the source valueT- type of the target value- Parameters:
value- source valuetype- target type- Returns:
- result of the mapping
-