Package io.helidon.common.http
Interface Reader<R>
-
- Type Parameters:
R- the requested type
- All Superinterfaces:
BiFunction<Flow.Publisher<DataChunk>,Class<? super R>,CompletionStage<? extends R>>
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
@FunctionalInterface public interface Reader<R> extends BiFunction<Flow.Publisher<DataChunk>,Class<? super R>,CompletionStage<? extends R>>
The Reader transforms aDataChunkpublisher into a completion stage of the associated type.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default CompletionStage<? extends R>apply(Flow.Publisher<DataChunk> publisher)Transforms a publisher into a completion stage.CompletionStage<? extends R>apply(Flow.Publisher<DataChunk> publisher, Class<? super R> clazz)Transforms a publisher into a completion stage.default <T extends R>
CompletionStage<? extends T>applyAndCast(Flow.Publisher<DataChunk> publisher, Class<T> type)Transforms a publisher into a completion stage.-
Methods inherited from interface java.util.function.BiFunction
andThen
-
-
-
-
Method Detail
-
apply
CompletionStage<? extends R> apply(Flow.Publisher<DataChunk> publisher, Class<? super R> clazz)
Transforms a publisher into a completion stage. If an exception is thrown, the resulting completion stage ofContent.as(Class)method call ends exceptionally.- Specified by:
applyin interfaceBiFunction<Flow.Publisher<DataChunk>,Class<? super R>,CompletionStage<? extends R>>- Parameters:
publisher- the publisher to transformclazz- the requested type to be returned as a completion stage. The purpose of this parameter is to know what the user of this Reader actually requested.- Returns:
- the result as a completion stage
-
apply
default CompletionStage<? extends R> apply(Flow.Publisher<DataChunk> publisher)
Transforms a publisher into a completion stage. If an exception is thrown, the resulting completion stage ofContent.as(Class)method call ends exceptionally.The default implementation calls
apply(Flow.Publisher, Class)withObjectas the class parameter.- Parameters:
publisher- the publisher to transform- Returns:
- the result as a completion stage
-
applyAndCast
default <T extends R> CompletionStage<? extends T> applyAndCast(Flow.Publisher<DataChunk> publisher, Class<T> type)
Transforms a publisher into a completion stage. If an exception is thrown, the resulting completion stage ofContent.as(Class)method call ends exceptionally.The default implementation calls
apply(Flow.Publisher, Class)withObjectas the class parameter.- Type Parameters:
T- the desired type to cast the guarantiedRtype to- Parameters:
publisher- the publisher to transformtype- the desired type to cast the guarantiedRtype to- Returns:
- the result as a completion stage which might end exceptionally with
ClassCastExceptionif theRtype wasn't possible to cast toT
-
-