Module id.xfunction

Class TransformPublisher<T,R>

Object
TransformPublisher<T,R>
Type Parameters:
T - input type (type of a Publisher)
R - output type (type of an existing Subscriber)
All Implemented Interfaces:
Flow.Publisher<R>

public class TransformPublisher<T,R> extends Object implements Flow.Publisher<R>
Transformer Flow.Publisher allows to subscribe existing Flow.Subscriber of type R to a Flow.Publisher of type T.

The transformation of items from T to R is done with a transformer Function

This publisher class is based on TransformSubscriber and every subscribe(Subscriber) call it wraps into TransformSubscriber and then subscribes it to the target publisher.

  • Constructor Details

    • TransformPublisher

      public TransformPublisher(Flow.Publisher<T> targetPublisher, Function<T,Optional<R>> transformer)
      Parameters:
      transformer - Transforms input messages from the target Flow.Publisher and publishes them to subscribers. If transformer returns empty message it will be ignored and not published.
  • Method Details