Record Class RenderOptions

java.lang.Object
java.lang.Record
io.leandev.appfuse.report.RenderOptions
Record Components:
cancelRequested - 是否要求取消
clock - 時鐘
onPage - 頁數進度回呼
filename - 產物的建議檔名;null 時取文件標題,再無則為 report

public record RenderOptions(BooleanSupplier cancelRequested, Clock clock, IntConsumer onPage, String filename) extends Record

單次 render 的選項

取消:cancelRequested 回傳 true 或執行緒被中斷時,renderer 在產生階段的檢查點停止,丟出 ReportRenderCancelledException;進入寫出階段後不再響應取消。

時間:文件 metadata 未提供 createdAt 時,PDF 的建立時間取自 clock。要求位元組層級的可重現輸出時, 必須固定其中之一。這是文件時間,不用於保存期限(見 StoredReport.storedAt())。

進度:onPage 在每頁繪製完成後於 render 執行緒同步呼叫,參數為已完成頁數;丟出例外即中止 render。

Since:
4.0.0
  • Constructor Details

    • RenderOptions

      public RenderOptions(BooleanSupplier cancelRequested, Clock clock, IntConsumer onPage, String filename)
      Creates an instance of a RenderOptions record class.
      Parameters:
      cancelRequested - the value for the cancelRequested record component
      clock - the value for the clock record component
      onPage - the value for the onPage record component
      filename - the value for the filename record component
  • Method Details

    • defaults

      public static RenderOptions defaults()
      不可取消、使用系統時鐘、不回報進度
      Returns:
      預設選項
    • cancelWhen

      public RenderOptions cancelWhen(BooleanSupplier cancelRequested)
      Parameters:
      cancelRequested - 是否要求取消
      Returns:
      新選項
    • clock

      public RenderOptions clock(Clock clock)
      Parameters:
      clock - 時鐘;metadata 未提供 createdAt 時使用
      Returns:
      新選項
    • onPage

      public RenderOptions onPage(IntConsumer onPage)
      Parameters:
      onPage - 每完成一頁呼叫,參數為已完成頁數;必須輕量、不可阻塞
      Returns:
      新選項
    • filename

      public RenderOptions filename(String filename)
      Parameters:
      filename - 產物的建議檔名;未含 .pdf 時自動加上
      Returns:
      新選項
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • cancelRequested

      public BooleanSupplier cancelRequested()
      Returns the value of the cancelRequested record component.
      Returns:
      the value of the cancelRequested record component
    • clock

      public Clock clock()
      Returns the value of the clock record component.
      Returns:
      the value of the clock record component
    • onPage

      public IntConsumer onPage()
      Returns the value of the onPage record component.
      Returns:
      the value of the onPage record component
    • filename

      public String filename()
      Returns the value of the filename record component.
      Returns:
      the value of the filename record component