Class DbColumnBase
java.lang.Object
io.helidon.dbclient.DbColumnBase
- All Implemented Interfaces:
OptionalValue<Object>, Value<Object>, DbColumn
- Direct Known Subclasses:
MongoDbColumn
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedDbColumnBase(Object value, Mappers 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 Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DbColumn
dbType, get, javaType, name, precision, scaleModifier and TypeMethodDescriptiondbType()Type of the column in the language of the database.default Objectget()Untyped value of this column, returns java type as provided by the underlying database driver.Class<?> javaType()Type of the column as would be returned by the underlying database driver.name()Column name.Precision of this column.scale()Scale of this column.Methods inherited from interface OptionalValue
ifPresent, ifPresentOrElse, isEmpty, isPresent, map, or, orElse, orElseGet, orElseThrow, orElseThrowModifier and TypeMethodDescriptiondefault voidIf a value is present, invoke the specified consumer with the value, otherwise do nothing.default voidifPresentOrElse(Consumer<Object> action, Runnable emptyAction) If a value is present, performs the given action with the value, otherwise performs the given empty-based action.default booleanisEmpty()Returnfalseif there is a value present, otherwisetrue.default booleanReturntrueif there is a value present, otherwisefalse.default <U> Optional<U> If a value is present, apply the provided mapping function to it, and if the result is non-null, return anOptionaldescribing the result.If the underlyingOptionaldoes not have a value, set it to theOptionalproduced by the supplying function.default ObjectReturn the value if present, otherwise returnother.default ObjectReturn the value if present, otherwise invokeotherand return the result of that invocation.default ObjectIf a value is present, returns the value, otherwise throwsNoSuchElementException.orElseThrow(Supplier<? extends X> exceptionSupplier) Return the contained value, if present, otherwise throw an exception to be created by the provided supplier.Methods inherited from interface Value
filter, flatMap, getBoolean, getDouble, getInt, getLong, getString, streamModifier and TypeMethodDescriptionIf a value is present, and the value matches the given predicate, return anOptionaldescribing the value, otherwise return an emptyOptional.default <U> Optional<U> Apply the providedOptional-bearing mapping function to this value, return that result.default booleanBoolean typed value.default doubleDouble typed value.default intgetInt()Integer typed value.default longgetLong()Long typed value.default StringString typed value.stream()If a value is present, returns a sequentialStreamcontaining only that value, otherwise returns an emptyStream.
-
Constructor Details
-
DbColumnBase
-
-
Method Details
-
rawValue
-
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
-