Package com.sap.ai.sdk.core.common

# Class ClientStreamingHandler<D extends StreamedDelta,R extends ClientError,E extends ClientException>

java.lang.Object
com.sap.ai.sdk.core.common.ClientResponseHandler<D,R,E>
com.sap.ai.sdk.core.common.ClientStreamingHandler<D,R,E>

Type Parameters:
  `D` - The type of the response.
  `R` - The type of the error.
  `E` - The type of the exception to throw.

All Implemented Interfaces:
  `org.apache.hc.core5.http.io.HttpClientResponseHandler<D>`

public class ClientStreamingHandler<D extends StreamedDelta,R extends ClientError,E extends ClientException> extends ClientResponseHandler<D,R,E>
Parse incoming JSON responses and handles any errors. For internal use only.

Since:
  1.2.0

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `ClientStreamingHandler(Class<D> deltaType, Class<? extends R> errorType, ClientExceptionFactory<E,R> exceptionFactory)`
  Creates a new instance of the `ClientStreamingHandler`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Stream<D>`
  `handleStreamingResponse(org.apache.hc.core5.http.ClassicHttpResponse response)`
  Processes a `ClassicHttpResponse` and returns a `Stream` of deltas corresponding to that response.
  `ClientStreamingHandler<D,R,E>`
  `objectMapper(com.fasterxml.jackson.databind.ObjectMapper jackson)`
  Set the `ObjectMapper` to use for parsing JSON responses.

  ### Methods inherited from class com.sap.ai.sdk.core.common.ClientResponseHandler

  `buildAndThrowException, handleResponse, parseErrorResponseAndThrow`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### ClientStreamingHandler

    public ClientStreamingHandler(@Nonnull Class<D> deltaType, @Nonnull Class<? extends R> errorType, @Nonnull ClientExceptionFactory<E,R> exceptionFactory)
    Creates a new instance of the `ClientStreamingHandler`.
    Parameters:
      `deltaType` - The type of the response.
      `errorType` - The type of the error.
      `exceptionFactory` - The factory to create exceptions.

- ## Method Details

  - ### objectMapper

    @Nonnull @Beta public ClientStreamingHandler<D,R,E> objectMapper(@Nonnull com.fasterxml.jackson.databind.ObjectMapper jackson)
    Set the `ObjectMapper` to use for parsing JSON responses.
    Overrides:
      `objectMapper` in class `ClientResponseHandler<D extends StreamedDelta,R extends ClientError,E extends ClientException>`
    Parameters:
      `jackson` - The `ObjectMapper` to use
    Returns:
      the current instance of `ClientStreamingHandler` with the changed object mapper

  - ### handleStreamingResponse

    @Nonnull public Stream<D> handleStreamingResponse(@Nonnull org.apache.hc.core5.http.ClassicHttpResponse response) throws E
    Processes a `ClassicHttpResponse` and returns a `Stream` of deltas corresponding to that response.
    Parameters:
      `response` - The response to process
    Returns:
      A `Stream` of a model class instantiated from the response
    Throws:
      `E` - in case of a problem or the connection was aborted