just to give a practical example, when such Tuple can be helpful in a typical SaaS that needs to work with JSON-columns.
---
When a new "Report" entry is created, the column "reportContentJson" must be filled with a nested json object consisting of specific! (not all) data from multiple other tables.
There is already an existing Repository that collects all relevant nested data from the multiple other tables as "Nested DTOs"
But for backwards-compatibility reasons the nested json must be "frozen" in regards to specific content (it should not contain all content)
So there are additional Nested DTOs needed, that only contain the data that is relevant to save into the json.
And now, when i want to create the NestedDTOs for the JSON-column from the NestedDTOs that contain all data,
the Tuple1, Tuple2, ..., TupleN can help me to create static constructors for creating the objects.
For example
class ReportContentJson {
...
public static Nested1 create(Tuple2<SourceDTO, SubSourceDTO> rec) {
return new Nested1()
.setReportContentSourceJson(ReportContentSourceJson.from(rec.value1()))
.setReportContentSubSourceJson(ReportContentSubSource.from(rec.value2()));
}
}
class ReportContentSourceJson {
....
public static ReportContentSourceJson from(SourceDTO dto) {
return new ReportContentSourceJson()
.setField1(dto.getField1())
.setField2(dto.getField2());