Package org.bsc.async

Record Class AsyncGenerator.Data<E>

java.lang.Object
java.lang.Record
org.bsc.async.AsyncGenerator.Data<E>
Type Parameters:
E - the type of the data element
Enclosing interface:
AsyncGenerator<E>

public static record AsyncGenerator.Data<E>(CompletableFuture<E> future, AsyncGenerator.Embed<E> embed, Object resultValue) extends Record
Represents a data element in the AsyncGenerator.
  • Constructor Details

    • Data

      public Data(CompletableFuture<E> future, AsyncGenerator.Embed<E> embed, Object resultValue)
      Creates an instance of a Data record class.
      Parameters:
      future - the value for the future record component
      embed - the value for the embed record component
      resultValue - the value for the resultValue record component
  • Method Details

    • isDone

      public boolean isDone()
    • isError

      public boolean isError()
    • of

      public static <E> AsyncGenerator.Data<E> of(CompletableFuture<E> future)
    • of

      public static <E> AsyncGenerator.Data<E> of(E data)
    • composeWith

      public static <E> AsyncGenerator.Data<E> composeWith(AsyncGenerator<E> generator, AsyncGenerator.EmbedCompletionHandler onCompletion)
    • done

      public static <E> AsyncGenerator.Data<E> done()
    • done

      public static <E> AsyncGenerator.Data<E> done(Object resultValue)
    • error

      public static <E> AsyncGenerator.Data<E> error(Throwable exception)
    • 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.
    • future

      public CompletableFuture<E> future()
      Returns the value of the future record component.
      Returns:
      the value of the future record component
    • embed

      public AsyncGenerator.Embed<E> embed()
      Returns the value of the embed record component.
      Returns:
      the value of the embed record component
    • resultValue

      public Object resultValue()
      Returns the value of the resultValue record component.
      Returns:
      the value of the resultValue record component