# Class StreamingResponseAggregator

java.lang.Object
com.google.adk.models.springai.StreamingResponseAggregator

public class StreamingResponseAggregator extends Object
Aggregates streaming responses from Spring AI models.

This class helps manage the accumulation of partial responses in streaming mode, ensuring that text content is properly concatenated and tool calls are correctly handled.

Thread Safety: This class is thread-safe. All public methods are synchronized to ensure safe concurrent access. The internal state is protected using a combination of thread-safe data structures and synchronization locks.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StreamingResponseAggregator()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `int`
  `getAccumulatedTextLength()`
  Returns the current accumulated text length.
  `LlmResponse`
  `getFinalResponse()`
  Returns the final aggregated response and resets the aggregator.
  `boolean`
  `isEmpty()`
  Returns true if no content has been processed yet.
  `LlmResponse`
  `processStreamingResponse(LlmResponse response)`
  Processes a streaming LlmResponse and returns the current aggregated state.
  `void`
  `reset()`
  Resets the aggregator for reuse.

  ### Methods inherited from class Object

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

- ## Constructor Details

  - ### StreamingResponseAggregator

    public StreamingResponseAggregator()

- ## Method Details

  - ### processStreamingResponse

    public LlmResponse processStreamingResponse(LlmResponse response)
    Processes a streaming LlmResponse and returns the current aggregated state.
    Parameters:
      `response` - The streaming response to process
    Returns:
      The current aggregated LlmResponse

  - ### getFinalResponse

    public LlmResponse getFinalResponse()
    Returns the final aggregated response and resets the aggregator.
    Returns:
      The final complete response

  - ### reset

    public void reset()
    Resets the aggregator for reuse.

  - ### isEmpty

    public boolean isEmpty()
    Returns true if no content has been processed yet.

  - ### getAccumulatedTextLength

    public int getAccumulatedTextLength()
    Returns the current accumulated text length.