Interface DbColumn
- All Superinterfaces:
OptionalValue<Object>, Value<Object>
- All Known Implementing Classes:
DbColumnBase, MongoDbColumn
Column may represent a null value. Get methods on this class would throw an exception if the
value is null, use Value.asOptional(), or one of the mapping methods that support optional values, such as
OptionalValue.ifPresent(java.util.function.Consumer) to consume such columns.
-
Method Summary
Modifier 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.<T> Tget(GenericType<T> type) Value of this column as a generic type.<T> TTyped value of this column.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
as, as, as, asBoolean, asDouble, asInt, asLong, asString, ifPresent, ifPresentOrElse, isEmpty, isPresent, map, or, orElse, orElseGet, orElseThrow, orElseThrowModifier 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.default OptionalValue<Boolean> Boolean typed value.default OptionalValue<Double> asDouble()Double typed value.default OptionalValue<Integer> asInt()Integer typed value.default OptionalValue<Long> asLong()Long typed value.default OptionalValue<String> asString()String typed value.default 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
asOptional, filter, flatMap, getBoolean, getDouble, getInt, getLong, getString, streamModifier and TypeMethodDescriptionTyped value asOptional.If 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.
-
Method Details
-
get
Typed value of this column. This method can return a correct result only if the type is the same asjavaType()or there is aMapperregistered that can map it.- 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 underlyingjavaType()and there is no mapper registered for it
-
get
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 aMapperregistered that can map underlyingjavaType()to the type requested.- Specified by:
getin interfaceValue<Object>- 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
-
get
Untyped value of this column, returns java type as provided by the underlying database driver.WARNING: for backward compatibility, this method MAY return
nullif the underlying column value is null. As this is not aligned with Helidon APIs, which forbid returns ofnull, this will change in future versions. If you need support fornullablecolumns, use the optional-like methods on this type, such asOptionalValue.isEmpty(),OptionalValue.isPresent(),OptionalValue.ifPresent(java.util.function.Consumer)etc. to handle {code null} values. -
javaType
Class<?> javaType()Type of the column as would be returned by the underlying database driver.- Returns:
- class of the type
- See Also:
-
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 returnVARCHARand methodjavaType()would returnString.- Returns:
- column type as the database understands it
-
name
-
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
emptyif precision is not available
-
scale
-