Class Response
- All Implemented Interfaces:
com.yahoo.component.provider.Freezable
,com.yahoo.component.provider.ListenableFreezable
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
ConstructorDescriptionCreates a request containing an empty array data listResponse
(Request request, ErrorMessage errorMessage) Convenience constructor which adds the given error message to the given requestCreates a response containing a list of data -
Method Summary
Modifier and TypeMethodDescriptiondata()
Returns the top level list of data items of this responsevoid
Processors which merges another request into this must call this method to notify the response.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
Creates a request containing an empty array data list -
Response
Creates a response containing a list of data -
Response
Convenience constructor which adds the given error message to the given request
-
-
Method Details
-
mergeWith
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
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
-