Record Class Trampoline.Done<T>

java.lang.Object
java.lang.Record
cloud.opencode.base.functional.monad.Trampoline.Done<T>
Type Parameters:
T - result type - 结果类型
Record Components:
result - the computed result - 计算结果
All Implemented Interfaces:
Trampoline<T>
Enclosing interface:
Trampoline<T>

public static record Trampoline.Done<T>(T result) extends Record implements Trampoline<T>
Completed Trampoline with a result. 包含结果的已完成 Trampoline。
Since:
JDK 25, opencode-base-functional V1.0.0
Author:
Leon Soo www.LeonSoo.com
  • Constructor Details

    • Done

      public Done(T result)
      Creates an instance of a Done record class.
      Parameters:
      result - the value for the result record component
  • Method Details

    • isDone

      public boolean isDone()
      Description copied from interface: Trampoline
      Check if the Trampoline is complete. 检查 Trampoline 是否完成。
      Specified by:
      isDone in interface Trampoline<T>
      Returns:
      true if done - 如果完成返回 true
    • flatMap

      public <U> Trampoline<U> flatMap(Function<? super T, Trampoline<U>> f)
      Description copied from interface: Trampoline
      Chain another Trampoline computation. 链接另一个 Trampoline 计算。

      Enables composition of multiple trampolined computations.

      启用多个蹦床计算的组合。

      Specified by:
      flatMap in interface Trampoline<T>
      Type Parameters:
      U - result type - 结果类型
      Parameters:
      f - function producing the next Trampoline - 产生下一个 Trampoline 的函数
      Returns:
      chained Trampoline
    • toString

      public 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.
    • result

      public T result()
      Returns the value of the result record component.
      Returns:
      the value of the result record component