The @DataTableType
annotation can mark a method which is able to take a Map<String, String>
row from a data table and transform it to a stronger type. The example from here is:
@DataTableType
public Book bookEntryTransformer(Map<String, String> row) {
return new Book(
row.get("title"),
row.get("author"),
Integer.parseInt(row.get("yearOfPublishing"))
);
}
How can I take an entire data table rather than a row and transform that to a type which is representing the whole data table?
The use case is I want to process blanks as inheriting the value from the first cell above it which has a value. Example nonsensical illustration:
| title | author | yearOfPublishing |
| To kill a mockingbird | Harper Lee | 1960 |
| The catcher in the rye | J.D. Salinger | 1951 |
| | F. Scott Fitzgerald | 1925 |
So this data table would be transformed into a new one where the only difference would be the blank cell would have the value The catcher in the rye
.
I have written the code to do this – everything works fine when testing but I am coming across problems trying to use it using annotations.