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 listResponse(Request request, ErrorMessage errorMessage)
Convenience constructor which adds the given error message to the given requestResponse(DataList<?> data)
Creates a response containing a list of data
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DataList
data()
Returns the top level list of data items of this responsevoid
mergeWith(Response other)
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)
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
-
-
-
-
Constructor Detail
-
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 Detail
-
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
-
recursiveComplete
public static <D extends Data> com.google.common.util.concurrent.ListenableFuture<DataList<D>> recursiveComplete(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
-
-