- 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 byheader()
(as each column-header pertains to exactly one column-value)
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 TypeMethodDescriptionextractFrom
(P product) Canonical implementation for tabulating the field from an ONIX Product.header()
returns a column header for each value that will be extracted from the ONIX Product byrowSupplier()
.returns a function to be executed in order to extract values from an ONIX Product.
-
Method Details
-
header
returns a column header for each value that will be extracted from the ONIX Product byrowSupplier()
. the length of the returned list determines the length of the (empty) row passed toFieldRowSupplier.setRowFromProduct(List, Object)
. -
rowSupplier
FieldRowSupplier<P> rowSupplier()returns a function to be executed in order to extract values from an ONIX Product. seeFieldRowSupplier
for more information. -
extractFrom
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. SeeTabulation.row(Object)
for "batch-type" tabulation.
-