Interface TypedApiEntityConsumer<T>

Type Parameters:
T - the type of the entity expected in the successful response
All Known Implementing Classes:
TypedApiEntityConsumer.JsonApiEntityConsumer, TypedApiEntityConsumer.RawApiEntityConsumer

public interface TypedApiEntityConsumer<T>
A generic interface for consuming API entities from an asynchronous data stream. This interface defines the basic operations required by ApiEntityConsumer to handle different types of API responses, including JSON and raw byte data.
  • Method Details

    • generateContent

      ApiEntity<T> generateContent() throws IOException
      Generates the final content after all data has been consumed.
      Returns:
      an ApiEntity containing the deserialized content, or null if no data was consumed
      Throws:
      IOException
    • consumeData

      void consumeData(ByteBuffer src, boolean endOfStream) throws IOException
      Consumes data from the provided ByteBuffer. This method is called as data becomes available and can be invoked multiple times as more data is streamed.
      Parameters:
      src - the ByteBuffer containing the data to be consumed
      endOfStream - a flag indicating whether this is the last chunk of data
      Throws:
      IOException
    • releaseResources

      void releaseResources()
      Releases any resources associated with this consumer. This method should be called once the consumer is no longer needed, such as after the response has been fully processed.
    • getBufferedBytes

      int getBufferedBytes()
      Returns the number of bytes currently buffered by this consumer.
      Returns:
      the number of buffered bytes