Top Description Inners Fields Constructors Methods
rx.internal.operators

public final Class OnSubscribeToMultimap<T, K, V>

extends Object
implements Observable.OnSubscribe<Map<K, Collection<V>>>, Func0<Map<K, Collection<V>>>
Class Inheritance
All Implemented Interfaces
rx.functions.Func0, java.util.concurrent.Callable, rx.functions.Function, rx.Observable.OnSubscribe, rx.functions.Action1, rx.functions.Action
Type Parameters
<T>
the value type of the input
<K>
the multimap-key type
<V>
the multimap-value type
Imports
java.util.ArrayList, .Collection, .HashMap, .Map, rx.Observable, .Observable.OnSubscribe, .Subscriber, rx.exceptions.Exceptions, rx.functions.Func0, .Func1

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
OnSubscribeToMultimap.DefaultMultimapCollectionFactory<
the key type
K
,
the value type
V
>

The default collection factory for a key in the multimap returning an ArrayList independent of the key.

private static class

Field Summary

Modifier and TypeField and Description
private final Func1<? super K, ? extends Collection<V>>
private final Func1<? super T, ? extends K>
private final Func0<? extends Map<K, Collection<V>>>
private final Observable<T>
private final Func1<? super T, ? extends V>

Constructor Summary

AccessConstructor and Description
public
OnSubscribeToMultimap(Observable<T>
the source Observable instance
source
,
Func1<? super T, ? extends K>
the function extracting the map-key from the main value
keySelector
,
Func1<? super T, ? extends V>
the function extracting the map-value from the main value
valueSelector
)

ToMultimap with key selector, custom value selector, default HashMap factory and default ArrayList collection factory.

public
OnSubscribeToMultimap(Observable<T>
the source Observable instance
source
,
Func1<? super T, ? extends K>
the function extracting the map-key from the main value
keySelector
,
Func1<? super T, ? extends V>
the function extracting the map-value from the main value
valueSelector
,
Func0<? extends Map<K, Collection<V>>>
function that returns a Map instance to store keys and values into
mapFactory
)

ToMultimap with key selector, custom value selector, custom Map factory and default ArrayList collection factory.

public
OnSubscribeToMultimap(Observable<T>
the observable source
source
,
Func1<? super T, ? extends K>
the function extracting the map-key from the main value
keySelector
,
Func1<? super T, ? extends V>
the function extracting the map-value from the main value
valueSelector
,
Func0<? extends Map<K, Collection<V>>>
function that returns a Map instance to store keys and values into
mapFactory
,
Func1<? super K, ? extends Collection<V>>
function that returns a Collection for a particular key to store values into
collectionFactory
)

ToMultimap with key selector, custom value selector, custom Map factory and custom collection factory.

Method Summary

Modifier and TypeMethod and Description
public Map<K, Collection<V>>
call()

Implements rx.functions.Func0.call.

Computes a result, or throws an exception if unable to do so.
public void
call(final Subscriber<? super Map<K, Collection<V>>> subscriber)

Implements rx.functions.Action1.call.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

collectionFactoryback to summary
private final Func1<? super K, ? extends Collection<V>> collectionFactory
keySelectorback to summary
private final Func1<? super T, ? extends K> keySelector
mapFactoryback to summary
private final Func0<? extends Map<K, Collection<V>>> mapFactory
sourceback to summary
private final Observable<T> source
valueSelectorback to summary
private final Func1<? super T, ? extends V> valueSelector

Constructor Detail

OnSubscribeToMultimapback to summary
public OnSubscribeToMultimap(Observable<T> source, 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
source:Observable<T>

the source Observable instance

keySelector:Func1<? super T, ? extends K>

the function extracting the map-key from the main value

valueSelector:Func1<? super T, ? extends V>

the function extracting the map-value from the main value

OnSubscribeToMultimapback to summary
public OnSubscribeToMultimap(Observable<T> source, Func1<? super T, ? extends K> keySelector, Func1<? super T, ? extends V> valueSelector, Func0<? extends Map<K, Collection<V>>> mapFactory)

ToMultimap with key selector, custom value selector, custom Map factory and default ArrayList collection factory.

Parameters
source:Observable<T>

the source Observable instance

keySelector:Func1<? super T, ? extends K>

the function extracting the map-key from the main value

valueSelector:Func1<? super T, ? extends V>

the function extracting the map-value from the main value

mapFactory:Func0<? extends Map<K, Collection<V>>>

function that returns a Map instance to store keys and values into

OnSubscribeToMultimapback to summary
public OnSubscribeToMultimap(Observable<T> source, Func1<? super T, ? extends K> keySelector, Func1<? super T, ? extends V> valueSelector, Func0<? extends Map<K, Collection<V>>> mapFactory, Func1<? super K, ? extends Collection<V>> collectionFactory)

ToMultimap with key selector, custom value selector, custom Map factory and custom collection factory.

Parameters
source:Observable<T>

the observable source

keySelector:Func1<? super T, ? extends K>

the function extracting the map-key from the main value

valueSelector:Func1<? super T, ? extends V>

the function extracting the map-value from the main value

mapFactory:Func0<? extends Map<K, Collection<V>>>

function that returns a Map instance to store keys and values into

collectionFactory:Func1<? super K, ? extends Collection<V>>

function that returns a Collection for a particular key to store values into

Method Detail

callback to summary
public Map<K, Collection<V>> call()

Implements rx.functions.Func0.call.

Doc from java.util.concurrent.Callable.call.

Computes a result, or throws an exception if unable to do so.

Returns:Map<K, Collection<V>>

computed result

Annotations
@Override
callback to summary
public void call(final Subscriber<? super Map<K, Collection<V>>> subscriber)

Implements rx.functions.Action1.call.

Annotations
@Override
rx.internal.operators back to summary

private final Class OnSubscribeToMultimap.DefaultMultimapCollectionFactory<K, V>

extends Object
implements Func1<K, Collection<V>>
Class Inheritance
  • java.lang.Object
  • rx.internal.operators.OnSubscribeToMultimap.DefaultMultimapCollectionFactory
All Implemented Interfaces
rx.functions.Func1, rx.functions.Function
Type Parameters
<K>
the key type
<V>
the value type

The default collection factory for a key in the multimap returning an ArrayList independent of the key.

Field Summary

Modifier and TypeField and Description
private static final OnSubscribeToMultimap.DefaultMultimapCollectionFactory<Object, Object>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public Collection<V>
call(K t1)

Implements rx.functions.Func1.call.

pack-priv static <K, V> OnSubscribeToMultimap.DefaultMultimapCollectionFactory<K, V>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

INSTANCEback to summary
private static final OnSubscribeToMultimap.DefaultMultimapCollectionFactory<Object, Object> INSTANCE

Constructor Detail

DefaultMultimapCollectionFactoryback to summary
private DefaultMultimapCollectionFactory()

Method Detail

callback to summary
public Collection<V> call(K t1)

Implements rx.functions.Func1.call.

Annotations
@Override
instanceback to summary
pack-priv static <K, V> OnSubscribeToMultimap.DefaultMultimapCollectionFactory<K, V> instance()
Annotations
@SuppressWarnings:unchecked
rx.internal.operators back to summary

private final Class OnSubscribeToMultimap.ToMultimapSubscriber<T, K, V>

extends DeferredScalarSubscriberSafe<T, Map<K, Collection<V>>>
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final Func1<? super K, ? extends Collection<V>>
private final Func1<? super T, ? extends K>
private final Func1<? super T, ? extends V>
Inherited from rx.internal.operators.DeferredScalarSubscriberSafe:
done

Constructor Summary

AccessConstructor and Description
pack-priv
ToMultimapSubscriber(Subscriber<? super Map<K, Collection<V>>> subscriber, Map<K, Collection<V>> map, Func1<? super T, ? extends K> keySelector, Func1<? super T, ? extends V> valueSelector, Func1<? super K, ? extends Collection<V>> collectionFactory)

Method Summary

Modifier and TypeMethod and Description
public void
onNext(T
the item emitted by the Observable
t
)

Implements rx.Observer.onNext.

Provides the Observer with a new item to observe.
public void
onStart()

Overrides rx.Subscriber.onStart.

This method is invoked when the Subscriber and Observable have been connected but the Observable has not yet begun to emit items or send notifications to the Subscriber.
Inherited from rx.internal.operators.DeferredScalarSubscriberSafe:
onCompletedonError

Field Detail

collectionFactoryback to summary
private final Func1<? super K, ? extends Collection<V>> collectionFactory
keySelectorback to summary
private final Func1<? super T, ? extends K> keySelector
valueSelectorback to summary
private final Func1<? super T, ? extends V> valueSelector

Constructor Detail

ToMultimapSubscriberback to summary
pack-priv ToMultimapSubscriber(Subscriber<? super Map<K, Collection<V>>> subscriber, Map<K, Collection<V>> map, Func1<? super T, ? extends K> keySelector, Func1<? super T, ? extends V> valueSelector, Func1<? super K, ? extends Collection<V>> collectionFactory)

Method Detail

onNextback to summary
public void onNext(T t)

Implements rx.Observer.onNext.

Doc from rx.Observer.onNext.

Provides the Observer with a new item to observe.

The Observable may call this method 0 or more times.

The Observable will not call this method again after it calls either onCompleted or onError.

Parameters
t:T

the item emitted by the Observable

Annotations
@Override
onStartback to summary
public void onStart()

Overrides rx.Subscriber.onStart.

Doc from rx.Subscriber.onStart.

This method is invoked when the Subscriber and Observable have been connected but the Observable has not yet begun to emit items or send notifications to the Subscriber. Override this method to add any useful initialization to your subscription, for instance to initiate backpressure.

Annotations
@Override