Module storm

Interface ModelMapper<T extends Record,ID>

Type Parameters:
T - the record type.
ID - the primary key type.

public interface ModelMapper<T extends Record,ID>
Maps a record to a set of columns.
Since:
1.2
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns true if the given primary key is the default value, false otherwise.
    map(Column column, T record)
    Extracts the value for the specified column for the given record.
    map(T record)
    Maps the values from the given record to a set of columns.
    map(T record, Predicate<Column> columnFilter)
    Maps the values from the given record to a set of columns.
    static <T extends Record, ID>
    ModelMapper<T,ID>
    of(Model<T,ID> model)
    Creates a new instance of the model mapper for the given model.
  • Method Details

    • of

      static <T extends Record, ID> ModelMapper<T,ID> of(@Nonnull Model<T,ID> model)
      Creates a new instance of the model mapper for the given model.
      Type Parameters:
      T - the record type.
      ID - the primary key type.
      Parameters:
      model - the model to map.
      Returns:
      a new instance of the model mapper.
    • isDefaultValue

      boolean isDefaultValue(@Nullable ID pk)
      Returns true if the given primary key is the default value, false otherwise.
      Parameters:
      pk - the primary key to check.
      Returns:
      true if the given primary key is the default value, false otherwise.
    • map

      Object map(@Nonnull Column column, @Nonnull T record) throws SqlTemplateException
      Extracts the value for the specified column for the given record.
      Parameters:
      column - the column to extract the value for.
      record - the record to extract the value from.
      Returns:
      the value for the specified column for the given record.
      Throws:
      SqlTemplateException - if an error occurs while extracting the value.
    • map

      default SequencedMap<Column,Object> map(@Nonnull T record) throws SqlTemplateException
      Maps the values from the given record to a set of columns.
      Parameters:
      record - the record to map.
      Returns:
      the values from the given record to a set of columns.
      Throws:
      SqlTemplateException - if an error occurs while extracting the values.
    • map

      SequencedMap<Column,Object> map(@Nonnull T record, @Nonnull Predicate<Column> columnFilter) throws SqlTemplateException
      Maps the values from the given record to a set of columns.
      Parameters:
      record - the record to map.
      columnFilter - the filter to determine which columns to include.
      Returns:
      the values from the given record to a set of columns.
      Throws:
      SqlTemplateException - if an error occurs while extracting the values.