Record Class JsonBodyHandler<T>

java.lang.Object
java.lang.Record
meteordevelopment.meteorclient.utils.network.JsonBodyHandler<T>
All Implemented Interfaces:
HttpResponse.BodySubscriber<T>, Flow.Subscriber<List<ByteBuffer>>

public record JsonBodyHandler<T>(HttpResponse.BodySubscriber<InputStream> delegate, com.google.gson.Gson gson, Type type) extends Record implements HttpResponse.BodySubscriber<T>
  • Constructor Details

    • JsonBodyHandler

      public JsonBodyHandler(HttpResponse.BodySubscriber<InputStream> delegate, com.google.gson.Gson gson, Type type)
      Creates an instance of a JsonBodyHandler record class.
      Parameters:
      delegate - the value for the delegate record component
      gson - the value for the gson record component
      type - the value for the type record component
  • Method Details

    • ofJson

      public static <T> HttpResponse.BodyHandler<T> ofJson(com.google.gson.Gson gson, Type type)
    • getBody

      public CompletionStage<T> getBody()
      Specified by:
      getBody in interface HttpResponse.BodySubscriber<T>
    • onSubscribe

      public void onSubscribe(Flow.Subscription subscription)
      Specified by:
      onSubscribe in interface Flow.Subscriber<T>
    • onNext

      public void onNext(List<ByteBuffer> item)
      Specified by:
      onNext in interface Flow.Subscriber<T>
    • onError

      public void onError(Throwable throwable)
      Specified by:
      onError in interface Flow.Subscriber<T>
    • onComplete

      public void onComplete()
      Specified by:
      onComplete in interface Flow.Subscriber<T>
    • 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.
    • delegate

      Returns the value of the delegate record component.
      Returns:
      the value of the delegate record component
    • gson

      public com.google.gson.Gson gson()
      Returns the value of the gson record component.
      Returns:
      the value of the gson record component
    • type

      public Type type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component