Record Class StreamOutcome

java.lang.Object
java.lang.Record
com.jsgalactic.axiom.http.StreamOutcome
Record Components:
kind - how the body ended
bytesWritten - body bytes accepted by the writer
elapsed - time from the moment the head was sent to the end of the body
failure - what the body threw (including a StreamAbortedException), or null when it returned; a body that swallowed an abort has no failure, but its kind is not StreamOutcome.Kind.COMPLETED

public record StreamOutcome(StreamOutcome.Kind kind, long bytesWritten, Duration elapsed, Throwable failure) extends Record
How a streamed response body ended, given to the observers registered with Response.onStreamEnd(java.util.function.Consumer<com.jsgalactic.axiom.http.StreamOutcome>). It describes the body only: the head was sent long before and the status cannot change.
  • Constructor Details

    • StreamOutcome

      public StreamOutcome(StreamOutcome.Kind kind, long bytesWritten, Duration elapsed, Throwable failure)
      Creates an outcome.
      Parameters:
      kind - how the body ended
      bytesWritten - body bytes accepted by the writer, not negative
      elapsed - time since the head was sent
      failure - what the body threw, or null
  • Method Details

    • completed

      public boolean completed()
      Reports whether the body ended normally and the client received a final chunk.
      Returns:
      true for StreamOutcome.Kind.COMPLETED
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      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.
    • kind

      public StreamOutcome.Kind kind()
      Returns the value of the kind record component.
      Returns:
      the value of the kind record component
    • bytesWritten

      public long bytesWritten()
      Returns the value of the bytesWritten record component.
      Returns:
      the value of the bytesWritten record component
    • elapsed

      public Duration elapsed()
      Returns the value of the elapsed record component.
      Returns:
      the value of the elapsed record component
    • failure

      public Throwable failure()
      Returns the value of the failure record component.
      Returns:
      the value of the failure record component