Interface RowSource

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface RowSource

表格列的來源

開啟前不得持有任何需要釋放的資源。 renderer 在排到該表格時才呼叫 open(),並在成功、失敗與取消時 都關閉取得的游標;因此建構失敗、文件從未 render,或 render 在該表格之前就失敗時,沒有東西需要釋放。 同一份文件可重複 render,每次 render 都重新開啟。

RowSource.of(rows);                                   // 記憶體中的列,可重複開啟
RowSource.lazy(() -> repository.streamLines(query));  // 開啟時才查詢,游標關閉時關閉串流

資料來自 JPA/JDBC 串流時,交易必須涵蓋整個 render,這是應用的協調責任。

Since:
4.0.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static RowSource
    lazy(Supplier<? extends Stream<TableRow>> rows)
    延遲取得的串流:每次 open() 才呼叫 rows,游標關閉時關閉該串流
    不開啟游標即可取得的全部列;只有記憶體中的來源會回傳值,供建構時驗證使用
    static RowSource
    of(List<TableRow> rows)
    記憶體中的列,可重複開啟
    開啟新的游標;呼叫者負責關閉
  • Method Details

    • open

      RowCursor open()
      開啟新的游標;呼叫者負責關閉
      Returns:
      游標
    • materializedRows

      default Optional<List<TableRow>> materializedRows()
      不開啟游標即可取得的全部列;只有記憶體中的來源會回傳值,供建構時驗證使用
      Returns:
      記憶體中的列;延遲來源為空
    • of

      static RowSource of(List<TableRow> rows)
      記憶體中的列,可重複開啟
      Parameters:
      rows - 列(會被複製)
      Returns:
      列來源
    • lazy

      static RowSource lazy(Supplier<? extends Stream<TableRow>> rows)
      延遲取得的串流:每次 open() 才呼叫 rows,游標關閉時關閉該串流
      Parameters:
      rows - 串流提供者
      Returns:
      列來源