Class DbColumnBase

java.lang.Object
io.helidon.dbclient.DbColumnBase
All Implemented Interfaces:
Value<Object>, DbColumn

public abstract class DbColumnBase extends Object implements DbColumn
Base DbColumn implementation.
  • Constructor Details

    • DbColumnBase

      protected DbColumnBase(Object value, MapperManager mapperManager, String... mappingQualifiers)
      Create a new instance.
      Parameters:
      value - value
      mapperManager - mapper manager
      mappingQualifiers - mapping qualifiers
  • Method Details

    • rawValue

      protected Object rawValue()
      Get raw value of the database column.
      Returns:
      raw value of the column
    • get

      public <T> T get(Class<T> type) throws MapperException
      Description copied from interface: DbColumn
      Typed value of this column. This method can return a correct result only if the type is the same as DbColumn.javaType() or there is a Mapper registered that can map it.
      Specified by:
      get in interface DbColumn
      Specified by:
      get in interface Value<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 underlying DbColumn.javaType() and there is no mapper registered for it
    • get

      public <T> T get(io.helidon.common.GenericType<T> type) throws MapperException
      Description copied from interface: DbColumn
      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 a Mapper registered that can map underlying DbColumn.javaType() to the type requested.
      Specified by:
      get in interface DbColumn
      Specified by:
      get in interface Value<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
    • as

      public <N> Value<N> as(Class<N> type) throws MapperException
      Specified by:
      as in interface Value<Object>
      Throws:
      MapperException
    • as

      public <N> Value<N> as(io.helidon.common.GenericType<N> type) throws MapperException
      Specified by:
      as in interface Value<Object>
      Throws:
      MapperException
    • as

      public <N> Value<N> as(Function<? super Object,? extends N> mapper)
      Specified by:
      as in interface Value<Object>
    • asOptional

      public Optional<Object> asOptional() throws MapperException
      Specified by:
      asOptional in interface Value<Object>
      Throws:
      MapperException
    • asBoolean

      public Value<Boolean> asBoolean()
      Specified by:
      asBoolean in interface Value<Object>
    • asString

      public Value<String> asString()
      Specified by:
      asString in interface Value<Object>
    • asInt

      public Value<Integer> asInt()
      Specified by:
      asInt in interface Value<Object>
    • asLong

      public Value<Long> asLong()
      Specified by:
      asLong in interface Value<Object>
    • asDouble

      public Value<Double> asDouble()
      Specified by:
      asDouble in interface Value<Object>
    • map

      protected <SRC, T> T map(SRC value, io.helidon.common.GenericType<T> type)
      Map value to target type using Mapper.
      Type Parameters:
      SRC - type of the source value
      T - type of the target value
      Parameters:
      value - source value
      type - target type
      Returns:
      result of the mapping
      Throws:
      MapperException - in case the mapper was not found or failed
    • map

      protected <SRC, T> T map(SRC value, Class<T> type)
      Map value to target type using Mapper. String.valueOf(Object) is used as fallback option when Mapper fails.
      Type Parameters:
      SRC - type of the source value
      T - type of the target value
      Parameters:
      value - source value
      type - target type
      Returns:
      result of the mapping