Add TableBuilder API, which is a Java-shim over Picnic's Table.Builder
API. Unfortunately Table.Builder is not accessible from Scala (and
probably other JVM-based languages). The Scala incompatibility of
Table.Builder comes from the fact that Scala does not seem to
understand Kotlins @set:JvmSynthetic annotation. And since this
annotation is used in Picnic to hide Kotlin setter methods from
Java (and, in turn from Scala), the Scala compiler failes to resolve a
method reference:
[error] Example.scala:37:14: ambiguous reference to overloaded definition,
[error] both method setColumnSpan in class TableBuilder of type (x$1: Int): jakewharton.picnic.Cell.Builder
[error] and method setColumnSpan in class TableBuilder of type (x$1: Int): Unit
[error] match argument types (Int)
[error] .setColumnSpan(4)
As additional benefit, the new TableBuilder API creates much less noisy
code compared to the existing Table.Builder, since it avoids the 'new'
keyword and nexted builders.
Compare Table.Builder
.setHeader(new TableSection.Builder()
.setCellStyle(new CellStyle.Builder()
.setBorder(true)
.setAlignment(BottomLeft)
.build())
.addRow(new Row.Builder()
.addCell(new Cell.Builder("APK")
.setRowSpan(2)
.build())
.addCell(new Cell.Builder("compressed")
.setColumnSpan(3)
.setStyle(new CellStyle.Builder()
.setAlignment(BottomCenter)
.build())
.build())
.addCell(new Cell.Builder("uncompressed")
.setColumnSpan(3)
.setStyle(new CellStyle.Builder()
.setAlignment(BottomCenter)
.build())
.build())
.build())
with TableBuilder
.withHeader()
.withCellStyle()
.setBorder(true)
.setAlignment(BottomLeft)
.endCellStyle()
.addRow()
.addCell("APK")
.setRowSpan(2)
.endCell()
.addCell("compressed")
.setColumnSpan(3)
.withCellStyle()
.setAlignment(BottomCenter)
.endCellStyle()
.endCell()
.addCell("uncompressed")
.setColumnSpan(3)
.withCellStyle()
.setAlignment(BottomCenter)
.endCellStyle()
.endCell()
.endRow()
.addRow("old", "new", "diff", "old", "new", "diff")
.endHeader()