Module jonix

Interface FieldTabulator<P>

All Known Implementing Classes:
SimpleFieldTabulator

public interface FieldTabulator<P>
An interface for representing a logical field within an ONIX Product.

Such logical field may consist of a single column (e.g. ISBN field) or a set of connected columns (e.g. Price field, which bundles together 3 columns: amount, currency and type).

In order to represent a field, an implementing class needs to return two things:

  • a header(), which is a list of Strings, where each String gives the i-th column its display-name
  • a rowSupplier(), which is function (i.e. FunctionalInterface), that, given an ONIX product, knows how to extract data from it in the form of Strings list, whose length is equal to the amount of columns returned by header() (as each column-header pertains to exactly one column-value)
Initially header() is obtained, then, if not empty, the rowSupplier() is invoked to return a FieldRowSupplier in which FieldRowSupplier.setRowFromProduct(List, Object) will be called repeatedly, once per each ONIX Product, to get the values from that Product.

Note that for performance boosting, FieldRowSupplier.setRowFromProduct(List, Object) is actually being called with a pre-initialized all-null list of Strings, which it needs to fill, rather than allocate and return a new list.

  • Method Summary

    Modifier and Type
    Method
    Description
    default List<String>
    extractFrom(P product)
    Canonical implementation for tabulating the field from an ONIX Product.
    returns a column header for each value that will be extracted from the ONIX Product by rowSupplier().
    returns a function to be executed in order to extract values from an ONIX Product.
  • Method Details

    • header

      List<String> header()
      returns a column header for each value that will be extracted from the ONIX Product by rowSupplier(). the length of the returned list determines the length of the (empty) row passed to FieldRowSupplier.setRowFromProduct(List, Object).
    • rowSupplier

      FieldRowSupplier<P> rowSupplier()
      returns a function to be executed in order to extract values from an ONIX Product. see FieldRowSupplier for more information.
    • extractFrom

      default List<String> extractFrom(P product)
      Canonical implementation for tabulating the field from an ONIX Product. It is not recommended to use this implementation when extracting many fields from a single ONIX record. See Tabulation.row(Object) for "batch-type" tabulation.