Record Class TsvProperty<T,U>

java.lang.Object
java.lang.Record
net.tangly.gleam.model.TsvProperty<T,U>
Type Parameters:
T - class owning the Java property
U - type of the property
Record Components:
columns - an ordered list of columns in the TSV file used to encode the property. Simple fields have one column, complex fields mapped on multiple columns have multiple values
getter - getter function to retrieve the property from a Java entity instance
setter - optional setter function to set the property of a Java entity instance. It is not needed for read-only properties
reader - extracts function to read and transform the set of TSV columns into a property value. Factory methods are provided to simplify the conversion in the case where only one TSV column is used.
writer - inserts function to transform a property value into a set of TSV columns and write them. Factory methods are provided to simplify the * definition of conversion in the case only one TSV column is used.

public record TsvProperty<T,U>(List<String> columns, Function<T,U> getter, BiConsumer<T,U> setter, Function<org.apache.commons.csv.CSVRecord,U> reader, BiConsumer<U,org.apache.commons.csv.CSVPrinter> writer) extends Record
The TSV property defines the mapping between a Java property and one or multiple cells in a TSV file. Two scenarios are supported. The simple case is the mapping of a Java property to exactly one cell in a TSV file. For example, the mapping of a local date property to the textual ISO conforms representation in one TSV cell. The more complex case is the mapping of a Java property to multiple cells in a TSV file. For example, a Java address object has to be mapped so that each element of the address is stored in a specific cell. Both scenarios are supported through the same abstraction.

The decision to use one or multiple cells is delegated to the developer. A TSV cell contains always either a string or a null value.