Class Response

java.lang.Object
com.yahoo.component.provider.FreezableClass
com.yahoo.component.provider.ListenableFreezableClass
com.yahoo.processing.Response
All Implemented Interfaces:
com.yahoo.component.provider.Freezable, com.yahoo.component.provider.ListenableFreezable

public class Response extends com.yahoo.component.provider.ListenableFreezableClass
A Response to a Request.

A Response contains a list of Data items, which may (through Data implementations) contain payload data and/or further nested data lists.

Frameworks built on top of processing may subclass this to create a stricter definition of a response. Processors producing Responses should not create subclasses but should instead create additional instances/subclasses of Data. Such Processors should always create Response instances by calling execution.process(request), which will return an empty Response if there are no further processors in the chain.

Do not cache this as it may hold references to objects that should be garbage collected.

Author:
bratseth
  • Constructor Summary

    Constructors
    Constructor
    Description
    Response(Request request)
    Creates a request containing an empty array data list
    Response(Request request, ErrorMessage errorMessage)
    Convenience constructor which adds the given error message to the given request
    Response(DataList<?> data)
    Creates a response containing a list of data
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the top level list of data items of this response
    void
    Processors which merges another request into this must call this method to notify the response.
    static <D extends Data>
    com.google.common.util.concurrent.ListenableFuture<DataList<D>>
    recursiveComplete(DataList<D> rootDataList)
    Deprecated, for removal: This API element is subject to removal in a future version.
    static <D extends Data>
    CompletableFuture<DataList<D>>
    recursiveFuture(DataList<D> rootDataList)
    Returns a future in which the given data list and all lists nested within it are completed.

    Methods inherited from class com.yahoo.component.provider.ListenableFreezableClass

    addFreezeListener, clone, freeze

    Methods inherited from class com.yahoo.component.provider.FreezableClass

    ensureNotFrozen, isFrozen

    Methods inherited from class java.lang.Object

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

    Methods inherited from interface com.yahoo.component.provider.Freezable

    isFrozen
  • Constructor Details

    • Response

      public Response(Request request)
      Creates a request containing an empty array data list
    • Response

      public Response(DataList<?> data)
      Creates a response containing a list of data
    • Response

      public Response(Request request, ErrorMessage errorMessage)
      Convenience constructor which adds the given error message to the given request
  • Method Details

    • mergeWith

      public void mergeWith(Response other)
      Processors which merges another request into this must call this method to notify the response. This does not modify the data of either response.
    • data

      public DataList data()
      Returns the top level list of data items of this response
    • recursiveFuture

      public static <D extends Data> CompletableFuture<DataList<D>> recursiveFuture(DataList<D> rootDataList)
      Returns a future in which the given data list and all lists nested within it are completed. The only use of the returned future is to call a get() method on it to complete the given dataList and all dataLists nested below it recursively.

      Lists are completed in prefix, depth-first order. DataLists added after the point when this method is called will not be completed.

      Parameters:
      rootDataList - the list to complete recursively
      Returns:
      the future in which all data in and below this list is complete, as the given root dataList for convenience
    • recursiveComplete

      @Deprecated(forRemoval=true, since="7") public static <D extends Data> com.google.common.util.concurrent.ListenableFuture<DataList<D>> recursiveComplete(DataList<D> rootDataList)
      Deprecated, for removal: This API element is subject to removal in a future version.