Class ResponseStream

java.lang.Object
org.forgerock.opendj.server.core.ResponseStream

public final class ResponseStream extends Object
A stream of LDAP response messages.
  • Method Details

    • of

      public static ResponseStream of()
      Returns an empty response stream.
      Returns:
      An empty response stream.
    • of

      public static ResponseStream of(Response response)
      Returns a response stream containing a single response.
      Parameters:
      response - The single response.
      Returns:
      A response stream containing a single response.
    • ofList

      public static ResponseStream ofList(List<? extends Response> responses)
      Returns a response stream containing a list of responses.
      Parameters:
      responses - The responses.
      Returns:
      A response stream containing a list of responses.
    • ofIterator

      public static ResponseStream ofIterator(Iterator<? extends Response> responses)
      Returns a response stream containing a sequence of responses.
      Parameters:
      responses - The responses.
      Returns:
      A response stream containing a sequence of responses.
    • ofQueue

      public static ResponseStream ofQueue(BlockingQueue<? extends Response> queue)
      Returns a response stream that will poll responses from the provided blocking queue. Calling next() will block indefinitely until a response is available. If the thread is interrupted then the method will continue to wait and re-interrupt the current thread when it finally has a response.
      Parameters:
      queue - The queue of responses.
      Returns:
      A response stream that will poll responses from the provided blocking queue.
    • ofError

      public static ResponseStream ofError(Throwable t)
      Returns a response stream containing an LDAP error obtained from the provided Throwable.
      Parameters:
      t - The error.
      Returns:
      A response stream containing an LDAP error.
    • concat

      public static ResponseStream concat(List<ResponseStream> streams)
      Returns a response stream containing all of the responses in list of streams, in order.
      Parameters:
      streams - The list of response streams.
      Returns:
      The concatenated response stream.
    • filter

      public ResponseStream filter(Predicate<Response> predicate)
      Returns a response stream which contains only the responses which match the provided predicate.
      Parameters:
      predicate - The predicate.
      Returns:
      A filtered response stream.
    • map

      public ResponseStream map(Function<Response,Response> mapper)
      Returns a response stream containing responses transformed by the provided mapping function.
      Parameters:
      mapper - The mapping function.
      Returns:
      A transformed response stream.
    • mapOptional

      public ResponseStream mapOptional(Function<Response,Response> mapper)
      Returns a response stream whose responses have been mapped or filtered by the provided optional mapping function. The functional should return {code null} to indicate that the response should be filtered.
      Parameters:
      mapper - The mapping function, which should return {code null} to indicate that the response should be filtered.
      Returns:
      A transformed and filtered response stream.
    • concatWith

      public ResponseStream concatWith(ResponseStream other)
      Returns a response stream containing all of the responses in this stream followed by all of the responses in the other stream.
      Parameters:
      other - The response streams to be appended to this response stream.
      Returns:
      The concatenated response stream.
    • tryNext

      public Response tryNext()
      Returns the next response if it can be obtained without blocking, otherwise null.
      Returns:
      The next response, or null if there are no responses available.
    • next

      public Response next()
      Returns the next response, waiting if necessary until one becomes available, or returns null if no more responses are expected.
      Returns:
      The next response, or returns null if no more responses are expected.
    • forEach

      public void forEach(Consumer<? super Response> action)
      Performs an action for each response in this stream blocking until there are no more responses or a Result has been observed.
      Parameters:
      action - An action to perform on each response.