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>

@Beta 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 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 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