Class OperatorToMultimap<T,​K,​V>

  • Type Parameters:
    T - the value type of the input
    K - the multimap-key type
    V - the multimap-value type
    All Implemented Interfaces:
    Func1<Subscriber<? super java.util.Map<K,​java.util.Collection<V>>>,​Subscriber<? super T>>, Function, Observable.Operator<java.util.Map<K,​java.util.Collection<V>>,​T>

    public final class OperatorToMultimap<T,​K,​V>
    extends java.lang.Object
    implements Observable.Operator<java.util.Map<K,​java.util.Collection<V>>,​T>
    Maps the elements of the source observable into a multimap (Map<K, Collection<V>>) where each key entry has a collection of the source's values.
    See Also:
    Issue #97
    • Constructor Summary

      Constructors 
      Constructor Description
      OperatorToMultimap​(Func1<? super T,​? extends K> keySelector, Func1<? super T,​? extends V> valueSelector)
      ToMultimap with key selector, custom value selector, default HashMap factory and default ArrayList collection factory.
      OperatorToMultimap​(Func1<? super T,​? extends K> keySelector, Func1<? super T,​? extends V> valueSelector, Func0<? extends java.util.Map<K,​java.util.Collection<V>>> mapFactory)
      ToMultimap with key selector, custom value selector, custom Map factory and default ArrayList collection factory.
      OperatorToMultimap​(Func1<? super T,​? extends K> keySelector, Func1<? super T,​? extends V> valueSelector, Func0<? extends java.util.Map<K,​java.util.Collection<V>>> mapFactory, Func1<? super K,​? extends java.util.Collection<V>> collectionFactory)
      ToMultimap with key selector, custom value selector, custom Map factory and custom collection factory.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Subscriber<? super T> call​(Subscriber<? super java.util.Map<K,​java.util.Collection<V>>> subscriber)  
      • Methods inherited from class java.lang.Object

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

      • keySelector

        final Func1<? super T,​? extends K> keySelector
      • valueSelector

        final Func1<? super T,​? extends V> valueSelector
      • mapFactory

        private final Func0<? extends java.util.Map<K,​java.util.Collection<V>>> mapFactory
      • collectionFactory

        final Func1<? super K,​? extends java.util.Collection<V>> collectionFactory
    • Constructor Detail

      • OperatorToMultimap

        public OperatorToMultimap​(Func1<? super T,​? extends K> keySelector,
                                  Func1<? super T,​? extends V> valueSelector)
        ToMultimap with key selector, custom value selector, default HashMap factory and default ArrayList collection factory.
        Parameters:
        keySelector - the function extracting the map-key from the main value
        valueSelector - the function extracting the map-value from the main value
      • OperatorToMultimap

        public OperatorToMultimap​(Func1<? super T,​? extends K> keySelector,
                                  Func1<? super T,​? extends V> valueSelector,
                                  Func0<? extends java.util.Map<K,​java.util.Collection<V>>> mapFactory)
        ToMultimap with key selector, custom value selector, custom Map factory and default ArrayList collection factory.
        Parameters:
        keySelector - the function extracting the map-key from the main value
        valueSelector - the function extracting the map-value from the main value
        mapFactory - function that returns a Map instance to store keys and values into
      • OperatorToMultimap

        public OperatorToMultimap​(Func1<? super T,​? extends K> keySelector,
                                  Func1<? super T,​? extends V> valueSelector,
                                  Func0<? extends java.util.Map<K,​java.util.Collection<V>>> mapFactory,
                                  Func1<? super K,​? extends java.util.Collection<V>> collectionFactory)
        ToMultimap with key selector, custom value selector, custom Map factory and custom collection factory.
        Parameters:
        keySelector - the function extracting the map-key from the main value
        valueSelector - the function extracting the map-value from the main value
        mapFactory - function that returns a Map instance to store keys and values into
        collectionFactory - function that returns a Collection for a particular key to store values into
    • Method Detail

      • call

        public Subscriber<? super T> call​(Subscriber<? super java.util.Map<K,​java.util.Collection<V>>> subscriber)
        Specified by:
        call in interface Func1<T,​K>