|
case class TableHeader(titles: List[String]) { |
|
def ||(title: String) = copy(titles = this.titles :+ title) |
|
def |(title: String) = copy(titles = this.titles :+ title) |
|
def |[T1](row: DataRow1[T1]) = new Table1(titles, List(row)) |
|
def |>[T1](row: DataRow1[T1]) = new Table1(titles, List(row), execute = true) |
|
def |[T1, T2](row: DataRow2[T1,T2]) = new Table2(titles, List(row)) |
|
def |>[T1, T2](row: DataRow2[T1,T2]) = new Table2(titles, List(row), execute = true) |
|
def |[T1, T2, T3](row: DataRow3[T1,T2,T3]) = new Table3(titles, List(row)) |
|
def |>[T1, T2, T3](row: DataRow3[T1,T2,T3]) = new Table3(titles, List(row), execute = true) |
|
def |[T1, T2, T3, T4](row: DataRow4[T1,T2,T3,T4]) = new Table4(titles, List(row)) |
|
def |>[T1, T2, T3, T4](row: DataRow4[T1,T2,T3,T4]) = new Table4(titles, List(row), execute = true) |
|
def |[T1, T2, T3, T4, T5](row: DataRow5[T1,T2,T3,T4,T5]) = new Table5(titles, List(row)) |
|
def |>[T1, T2, T3, T4, T5](row: DataRow5[T1,T2,T3,T4,T5]) = new Table5(titles, List(row), execute = true) |
|
def |[T1, T2, T3, T4, T5, T6](row: DataRow6[T1,T2,T3,T4,T5,T6]) = new Table6(titles, List(row)) |
|
def |>[T1, T2, T3, T4, T5, T6](row: DataRow6[T1,T2,T3,T4,T5,T6]) = new Table6(titles, List(row), execute = true) |
|
def |[T1, T2, T3, T4, T5, T6, T7](row: DataRow7[T1,T2,T3,T4,T5,T6,T7]) = new Table7(titles, List(row)) |
|
def |>[T1, T2, T3, T4, T5, T6, T7](row: DataRow7[T1,T2,T3,T4,T5,T6,T7]) = new Table7(titles, List(row), execute = true) |
|
def |[T1, T2, T3, T4, T5, T6, T7, T8](row: DataRow8[T1,T2,T3,T4,T5,T6,T7,T8]) = new Table8(titles, List(row)) |
|
def |>[T1, T2, T3, T4, T5, T6, T7, T8](row: DataRow8[T1,T2,T3,T4,T5,T6,T7,T8]) = new Table8(titles, List(row), execute = true) |
|
def |[T1, T2, T3, T4, T5, T6, T7, T8, T9](row: DataRow9[T1,T2,T3,T4,T5,T6,T7,T8,T9]) = new Table9(titles, List(row)) |
|
def |>[T1, T2, T3, T4, T5, T6, T7, T8, T9](row: DataRow9[T1,T2,T3,T4,T5,T6,T7,T8,T9]) = new Table9(titles, List(row), execute = true) |
|
def |[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](row: DataRow10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10]) = new Table10(titles, List(row)) |
|
def |>[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10](row: DataRow10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10]) = new Table10(titles, List(row), execute = true) |
|
} |
|
case class Table1(override val titles: List[String], rows: List[DataRow1[T1]], override val execute: Boolean = true) extends Table(titles, execute) { |
|
def |(row: DataRow1[T1]) = Table1(titles, outer.rows :+ row, execute) |
|
def |[R <% Result](f: T1 => R) = executeRow(f, execute) |
|
def |>[R <% Result](f: T1 => R) = executeRow(f, true) |
|
def executeRow[R <% Result](f: T1 => R, exec: Boolean): DecoratedResult[DataTable] = { |
|
if (exec) collect(rows map { (d: DataRow1[T1]) => |
|
(d.showCells, implicitly[R => Result].apply(f(d.t1)).execute) |
|
}) |
|
else DecoratedResult(DataTable(titles, Seq(), Success("ok"))) |
|
} |
|
} |
|
case class Table2(override val titles: List[String], rows: List[DataRow2[T1,T2]], override val execute: Boolean = true) extends Table(titles, execute) { |
|
def |[S1 >: T1, S2 >: T2](row: DataRow2[T1,T2]) = Table2(titles, outer.rows :+ row, execute) |
|
def |[R <% Result](f: (T1, T2) => R) = executeRow(f, execute) |
|
def |>[R <% Result](f: (T1, T2) => R) = executeRow(f, true) |
|
def executeRow[R <% Result](f: (T1, T2) => R, exec: Boolean): DecoratedResult[DataTable] = { |
|
if (exec) collect(rows map { (d: DataRow2[T1,T2]) => |
|
(d.showCells, implicitly[R => Result].apply(f(d.t1, d.t2)).execute) |
|
}) |
|
else DecoratedResult(DataTable(titles, Seq(), Success("ok"))) |
|
} |
|
} |
|
case class Table3(override val titles: List[String], rows: List[DataRow3[T1,T2,T3]], override val execute: Boolean = true) extends Table(titles, execute) { |
|
def |[S1 >: T1, S2 >: T2, S3 >: T3](row: DataRow3[T1,T2,T3]) = Table3(titles, outer.rows :+ row, execute) |
|
def |[R <% Result](f: (T1, T2, T3) => R) = executeRow(f, execute) |
|
def |>[R <% Result](f: (T1, T2, T3) => R) = executeRow(f, true) |
|
def executeRow[R <% Result](f: (T1, T2, T3) => R, exec: Boolean): DecoratedResult[DataTable] = { |
|
if (exec) collect(rows map { (d: DataRow3[T1,T2,T3]) => |
|
(d.showCells, implicitly[R => Result].apply(f(d.t1, d.t2, d.t3)).execute) |
|
}) |
|
else DecoratedResult(DataTable(titles, Seq(), Success("ok"))) |
|
} |
|
} |
|
case class Table4(override val titles: List[String], rows: List[DataRow4[T1,T2,T3,T4]], override val execute: Boolean = true) extends Table(titles, execute) { |
|
def |[S1 >: T1, S2 >: T2, S3 >: T3, S4 >: T4](row: DataRow4[T1,T2,T3,T4]) = Table4(titles, outer.rows :+ row, execute) |
|
def |[R <% Result](f: (T1, T2, T3, T4) => R) = executeRow(f, execute) |
|
def |>[R <% Result](f: (T1, T2, T3, T4) => R) = executeRow(f, true) |
|
def executeRow[R <% Result](f: (T1, T2, T3, T4) => R, exec: Boolean): DecoratedResult[DataTable] = { |
|
if (exec) collect(rows map { (d: DataRow4[T1,T2,T3,T4]) => |
|
(d.showCells, implicitly[R => Result].apply(f(d.t1, d.t2, d.t3, d.t4)).execute) |
|
}) |
|
else DecoratedResult(DataTable(titles, Seq(), Success("ok"))) |
|
} |
|
} |
|
case class Table5(override val titles: List[String], rows: List[DataRow5[T1,T2,T3,T4,T5]], override val execute: Boolean = true) extends Table(titles, execute) { |
|
def |[S1 >: T1, S2 >: T2, S3 >: T3, S4 >: T4, S5 >: T5](row: DataRow5[T1,T2,T3,T4,T5]) = Table5(titles, outer.rows :+ row, execute) |
|
def |[R <% Result](f: (T1, T2, T3, T4, T5) => R) = executeRow(f, execute) |
|
def |>[R <% Result](f: (T1, T2, T3, T4, T5) => R) = executeRow(f, true) |
|
def executeRow[R <% Result](f: (T1, T2, T3, T4, T5) => R, exec: Boolean): DecoratedResult[DataTable] = { |
|
if (exec) collect(rows map { (d: DataRow5[T1,T2,T3,T4,T5]) => |
|
(d.showCells, implicitly[R => Result].apply(f(d.t1, d.t2, d.t3, d.t4, d.t5)).execute) |
|
}) |
|
else DecoratedResult(DataTable(titles, Seq(), Success("ok"))) |
|
} |
|
} |
|
case class Table6(override val titles: List[String], rows: List[DataRow6[T1,T2,T3,T4,T5,T6]], override val execute: Boolean = true) extends Table(titles, execute) { |
|
def |[S1 >: T1, S2 >: T2, S3 >: T3, S4 >: T4, S5 >: T5, S6 >: T6](row: DataRow6[T1,T2,T3,T4,T5,T6]) = Table6(titles, outer.rows :+ row, execute) |
|
def |[R <% Result](f: (T1, T2, T3, T4, T5, T6) => R) = executeRow(f, execute) |
|
def |>[R <% Result](f: (T1, T2, T3, T4, T5, T6) => R) = executeRow(f, true) |
|
def executeRow[R <% Result](f: (T1, T2, T3, T4, T5, T6) => R, exec: Boolean): DecoratedResult[DataTable] = { |
|
if (exec) collect(rows map { (d: DataRow6[T1,T2,T3,T4,T5,T6]) => |
|
(d.showCells, implicitly[R => Result].apply(f(d.t1, d.t2, d.t3, d.t4, d.t5, d.t6)).execute) |
|
}) |
|
else DecoratedResult(DataTable(titles, Seq(), Success("ok"))) |
|
} |
|
} |
|
case class Table7(override val titles: List[String], rows: List[DataRow7[T1,T2,T3,T4,T5,T6,T7]], override val execute: Boolean = true) extends Table(titles, execute) { |
|
def |[S1 >: T1, S2 >: T2, S3 >: T3, S4 >: T4, S5 >: T5, S6 >: T6, S7 >: T7](row: DataRow7[T1,T2,T3,T4,T5,T6,T7]) = Table7(titles, outer.rows :+ row, execute) |
|
def |[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7) => R) = executeRow(f, execute) |
|
def |>[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7) => R) = executeRow(f, true) |
|
def executeRow[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7) => R, exec: Boolean): DecoratedResult[DataTable] = { |
|
if (exec) collect(rows map { (d: DataRow7[T1,T2,T3,T4,T5,T6,T7]) => |
|
(d.showCells, implicitly[R => Result].apply(f(d.t1, d.t2, d.t3, d.t4, d.t5, d.t6, d.t7)).execute) |
|
}) |
|
else DecoratedResult(DataTable(titles, Seq(), Success("ok"))) |
|
} |
|
} |
|
case class Table8(override val titles: List[String], rows: List[DataRow8[T1,T2,T3,T4,T5,T6,T7,T8]], override val execute: Boolean = true) extends Table(titles, execute) { |
|
def |[S1 >: T1, S2 >: T2, S3 >: T3, S4 >: T4, S5 >: T5, S6 >: T6, S7 >: T7, S8 >: T8](row: DataRow8[T1,T2,T3,T4,T5,T6,T7,T8]) = Table8(titles, outer.rows :+ row, execute) |
|
def |[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7, T8) => R) = executeRow(f, execute) |
|
def |>[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7, T8) => R) = executeRow(f, true) |
|
def executeRow[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7, T8) => R, exec: Boolean): DecoratedResult[DataTable] = { |
|
if (exec) collect(rows map { (d: DataRow8[T1,T2,T3,T4,T5,T6,T7,T8]) => |
|
(d.showCells, implicitly[R => Result].apply(f(d.t1, d.t2, d.t3, d.t4, d.t5, d.t6, d.t7, d.t8)).execute) |
|
}) |
|
else DecoratedResult(DataTable(titles, Seq(), Success("ok"))) |
|
} |
|
} |
|
case class Table9(override val titles: List[String], rows: List[DataRow9[T1,T2,T3,T4,T5,T6,T7,T8,T9]], override val execute: Boolean = true) extends Table(titles, execute) { |
|
def |[S1 >: T1, S2 >: T2, S3 >: T3, S4 >: T4, S5 >: T5, S6 >: T6, S7 >: T7, S8 >: T8, S9 >: T9](row: DataRow9[T1,T2,T3,T4,T5,T6,T7,T8,T9]) = Table9(titles, outer.rows :+ row, execute) |
|
def |[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9) => R) = executeRow(f, execute) |
|
def |>[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9) => R) = executeRow(f, true) |
|
def executeRow[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9) => R, exec: Boolean): DecoratedResult[DataTable] = { |
|
if (exec) collect(rows map { (d: DataRow9[T1,T2,T3,T4,T5,T6,T7,T8,T9]) => |
|
(d.showCells, implicitly[R => Result].apply(f(d.t1, d.t2, d.t3, d.t4, d.t5, d.t6, d.t7, d.t8, d.t9)).execute) |
|
}) |
|
else DecoratedResult(DataTable(titles, Seq(), Success("ok"))) |
|
} |
|
} |
|
case class Table10(override val titles: List[String], rows: List[DataRow10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10]], override val execute: Boolean = true) extends Table(titles, execute) { |
|
def |[S1 >: T1, S2 >: T2, S3 >: T3, S4 >: T4, S5 >: T5, S6 >: T6, S7 >: T7, S8 >: T8, S9 >: T9, S10 >: T10](row: DataRow10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10]) = Table10(titles, outer.rows :+ row, execute) |
|
def |[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R) = executeRow(f, execute) |
|
def |>[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R) = executeRow(f, true) |
|
def executeRow[R <% Result](f: (T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) => R, exec: Boolean): DecoratedResult[DataTable] = { |
|
if (exec) collect(rows map { (d: DataRow10[T1,T2,T3,T4,T5,T6,T7,T8,T9,T10]) => |
|
(d.showCells, implicitly[R => Result].apply(f(d.t1, d.t2, d.t3, d.t4, d.t5, d.t6, d.t7, d.t8, d.t9, d.t10)).execute) |
|
}) |
|
else DecoratedResult(DataTable(titles, Seq(), Success("ok"))) |
|
} |
|
} |
|
abstract class DataRow[+T1, +T2, +T3, +T4, +T5, +T6, +T7, +T8, +T9, +T10] extends Product { |
|
def show = productIterator.mkString("|", "|", "|") |
|
def showCells = productIterator.map(_.toString).toSeq |
|
} |
|
case class DataRow1[T1, Any, Any, Any, Any, Any, Any, Any, Any, Any] { |
|
def  = DataRow2(t1, t2) |
|
def ! = DataRow2(t1, t2) |
|
} |
|
case class DataRow2[T1, T2, Any, Any, Any, Any, Any, Any, Any, Any] { |
|
def  = DataRow3(t1, t2, t3) |
|
def ! = DataRow3(t1, t2, t3) |
|
} |
|
case class DataRow3[T1, T2, T3, Any, Any, Any, Any, Any, Any, Any] { |
|
def  = DataRow4(t1, t2, t3, t4) |
|
def ! = DataRow4(t1, t2, t3, t4) |
|
} |
|
case class DataRow4[T1, T2, T3, T4, Any, Any, Any, Any, Any, Any] { |
|
def  = DataRow5(t1, t2, t3, t4, t5) |
|
def ! = DataRow5(t1, t2, t3, t4, t5) |
|
} |
|
case class DataRow5[T1, T2, T3, T4, T5, Any, Any, Any, Any, Any] { |
|
def  = DataRow6(t1, t2, t3, t4, t5, t6) |
|
def ! = DataRow6(t1, t2, t3, t4, t5, t6) |
|
} |
|
case class DataRow6[T1, T2, T3, T4, T5, T6, Any, Any, Any, Any] { |
|
def  = DataRow7(t1, t2, t3, t4, t5, t6, t7) |
|
def ! = DataRow7(t1, t2, t3, t4, t5, t6, t7) |
|
} |
|
case class DataRow7[T1, T2, T3, T4, T5, T6, T7, Any, Any, Any] { |
|
def  = DataRow8(t1, t2, t3, t4, t5, t6, t7, t8) |
|
def ! = DataRow8(t1, t2, t3, t4, t5, t6, t7, t8) |
|
} |
|
case class DataRow8[T1, T2, T3, T4, T5, T6, T7, T8, Any, Any] { |
|
def  = DataRow9(t1, t2, t3, t4, t5, t6, t7, t8, t9) |
|
def ! = DataRow9(t1, t2, t3, t4, t5, t6, t7, t8, t9) |
|
} |
|
case class DataRow9[T1, T2, T3, T4, T5, T6, T7, T8, T9, Any] { |
|
def  = DataRow10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) |
|
def ! = DataRow10(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10) |
|
} |
|
case class DataRow10[T1, T2, T3, T4, T5, T6, T7, T8, T9, T10] { |
|
() |
|
} |