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>
Parses incoming JSON responses and handles any errors.

For internal use only.

Since:
1.2.0
  • Constructor Details

    • ClientStreamingHandler

      public ClientStreamingHandler(@Nonnull Class<D> deltaType, @Nonnull Class<? extends R> errorType, @Nonnull ClientExceptionFactory<E,R> exceptionFactory)
      For internal SDK usage only. 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 public ClientStreamingHandler<D,R,E> objectMapper(@Nonnull com.fasterxml.jackson.databind.ObjectMapper jackson)
      For internal SDK usage only. 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
      For internal SDK usage only. 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.