public interface Content extends Flow.Publisher<DataChunk>
publisher of chunks with specific
features.
onError().
DataChunk provided by onNext() method must be consumed in this
method call. Buffer can be reused by network infrastructure as soon as onNext() method returns.
This behavior can be inconvenient yet it helps to provide excellent performance.
registerFilter(Function) method. It can be used to wrap or replace previously registered (or default) publisher.
CompletionStage of a single entity using
registerReader(Class, Reader) or registerReader(Predicate, Reader) methods. It
is then possible to use as(Class) method to obtain such entity.| Modifier and Type | Method and Description |
|---|---|
<T> CompletionStage<T> |
as(Class<T> type)
Consumes and converts the request content into a completion stage of the requested type.
|
void |
registerFilter(Function<Flow.Publisher<DataChunk>,Flow.Publisher<DataChunk>> function)
Registers a filter that allows a control of the original publisher.
|
<T> void |
registerReader(Class<T> type,
Reader<T> reader)
Registers a reader for a later use with an appropriate
as(Class) method call. |
<T> void |
registerReader(Predicate<Class<?>> predicate,
Reader<T> reader)
Registers a reader for a later use with an appropriate
as(Class) method call. |
void |
subscribe(Flow.Subscriber<? super DataChunk> subscriber)
If possible, adds the given Subscriber to this publisher.
|
void subscribe(Flow.Subscriber<? super DataChunk> subscriber)
registerFilter(Function).
Note that the original publisher allows only a single subscriber and requires the passed
DataChunk in the Flow.Subscriber#onNext(Object) call
to be consumed before the method completes as specified by the Default Publisher Contract.
subscribe in interface Flow.Publisher<DataChunk>subscriber - the subscriberNullPointerException - if subscriber is nullvoid registerFilter(Function<Flow.Publisher<DataChunk>,Flow.Publisher<DataChunk>> function)
The provided function is evaluated upon calling either of subscribe(Flow.Subscriber)
or as(Class).
The first evaluation of the function transforms the original publisher to a new publisher.
Any subsequent evaluation receives the publisher transformed by the last previously
registered filter.
It is up to the implementor of the given function to respect the contract of both the original
publisher and the previously registered ones.
function - a function that transforms a given publisher (that is either the original
publisher or the publisher transformed by the last previously registered filter).<T> void registerReader(Class<T> type, Reader<T> reader)
as(Class) method call.
The reader must transform the published byte buffers into a completion stage of the requested type.
Upon calling as(Class) a matching reader is searched in the same order as the
readers were registered. If no matching reader is found, or when the function throws
an exception, the resulting completion stage ends exceptionally.
T - the requested typetype - the requested type the completion stage is be associated with.reader - the reader as a function that transforms a publisher into completion stage.
If an exception is thrown, the resulting completion stage of
as(Class) method call ends exceptionally.<T> void registerReader(Predicate<Class<?>> predicate, Reader<T> reader)
as(Class) method call.
The reader must transform the published byte buffers into a completion stage of the requested type.
Upon calling as(Class) a matching reader is searched in the same order as the
readers were registered. If no matching reader is found or when the predicate throws
an exception, or when the function throws an exception, the resulting completion stage
ends exceptionally.
T - the requested typepredicate - the predicate that determines whether the registered reader can handle
the requested type. If an exception is thrown, the resulting completion
stage of as(Class) method call ends exceptionally.reader - the reader as a function that transforms a publisher into completion stage.
If an exception is thrown, the resulting completion stage of
as(Class) method call ends exceptionally.<T> CompletionStage<T> as(Class<T> type)
The conversion requires an appropriate reader to be already registered
(see registerReader(Predicate, Reader)). If no such reader is found, the
resulting completion stage ends exceptionally.
T - the requested typetype - the requested type classCopyright © 2018, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.