Class MultiSplitter<T,​K extends java.lang.Enum<K>>

  • Type Parameters:
    T - the items type
    K - the enumeration type

    public class MultiSplitter<T,​K extends java.lang.Enum<K>>
    extends java.lang.Object
    Splits a Multi into several co-operating Multi.

    Each split Multi receives items based on a function that maps each item to a key from an enumeration.

    The demand of each split Multi is independent. Items flow when all keys from the enumeration have a split subscriber, and until either one of the split has a 0 demand, or when one of the split subscriber cancels. The flow resumes when all keys have a subscriber again, and when the demand for each split is strictly positive.

    Calls to get(Enum) result in new Multi objects, but given a key K then there can be only one active subscription. If there is already a subscriber for K then any subscription request to a Multi for key K results in a terminal failure. Note that when a subscriber for K has cancelled then a request to subscribe for a Multi for K can succeed.

    If the upstream Multi has already completed or failed, then any new subscriber will receive the terminal signal (see MultiSubscriber.onCompletion() and MultiSubscriber.onFailure(Throwable)).

    Note on Context support: it is assumed that all split subscribers share the same Context instance, if any. The Context is passed to the upstream Multi when the first split subscription happens. When disjoint Context are in use by the different split subscribers then the behavior of your code will be most likely incorrect.

    • Constructor Summary

      Constructors 
      Constructor Description
      MultiSplitter​(Multi<? extends T> upstream, java.lang.Class<K> keyType, java.util.function.Function<T,​K> splitter)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Multi<T> get​(K key)
      Get a Multi for a given key.
      java.lang.Class<K> keyType()
      Get the (enum) key type.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultiSplitter

        public MultiSplitter​(Multi<? extends T> upstream,
                             java.lang.Class<K> keyType,
                             java.util.function.Function<T,​K> splitter)
    • Method Detail

      • get

        @CheckReturnValue
        public Multi<T> get​(K key)
        Get a Multi for a given key.
        Parameters:
        key - the key
        Returns:
        a new Multi
      • keyType

        public java.lang.Class<K> keyType()
        Get the (enum) key type.
        Returns:
        the key type