Interface Reader<R>

    • 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 of Content.as(Class) method call ends exceptionally.
        Specified by:
        apply in interface BiFunction<Flow.Publisher<DataChunk>,​Class<? super R>,​CompletionStage<? extends R>>
        Parameters:
        publisher - the publisher to transform
        clazz - 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
      • applyAndCast

        default <T extends RCompletionStage<? 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 of Content.as(Class) method call ends exceptionally.

        The default implementation calls apply(Flow.Publisher, Class) with Object as the class parameter.

        Type Parameters:
        T - the desired type to cast the guarantied R type to
        Parameters:
        publisher - the publisher to transform
        type - the desired type to cast the guarantied R type to
        Returns:
        the result as a completion stage which might end exceptionally with ClassCastException if the R type wasn't possible to cast to T