Package rx.internal.util
Class SubscriptionList
- java.lang.Object
-
- rx.internal.util.SubscriptionList
-
- All Implemented Interfaces:
Subscription
public final class SubscriptionList extends java.lang.Object implements Subscription
Subscription that represents a group of Subscriptions that are unsubscribed together.- See Also:
- Rx.Net equivalent CompositeDisposable
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<Subscription>
subscriptions
private boolean
unsubscribed
-
Constructor Summary
Constructors Constructor Description SubscriptionList()
Constructs an empty SubscriptionList.SubscriptionList(Subscription s)
Constructs a SubscriptionList with the given initial child subscription.SubscriptionList(Subscription... subscriptions)
Constructs a SubscriptionList with the given initial child subscriptions.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(Subscription s)
void
clear()
boolean
hasSubscriptions()
Returns true if this composite is not unsubscribed and contains subscriptions.boolean
isUnsubscribed()
Indicates whether thisSubscription
is currently unsubscribed.void
remove(Subscription s)
void
unsubscribe()
Unsubscribe from all of the subscriptions in the list, which stops the receipt of notifications on the associatedSubscriber
.private static void
unsubscribeFromAll(java.util.Collection<Subscription> subscriptions)
-
-
-
Field Detail
-
subscriptions
private java.util.List<Subscription> subscriptions
-
unsubscribed
private volatile boolean unsubscribed
-
-
Constructor Detail
-
SubscriptionList
public SubscriptionList()
Constructs an empty SubscriptionList.
-
SubscriptionList
public SubscriptionList(Subscription... subscriptions)
Constructs a SubscriptionList with the given initial child subscriptions.- Parameters:
subscriptions
- the array of subscriptions to start with
-
SubscriptionList
public SubscriptionList(Subscription s)
Constructs a SubscriptionList with the given initial child subscription.- Parameters:
s
- the initial subscription instance
-
-
Method Detail
-
isUnsubscribed
public boolean isUnsubscribed()
Description copied from interface:Subscription
Indicates whether thisSubscription
is currently unsubscribed.- Specified by:
isUnsubscribed
in interfaceSubscription
- Returns:
true
if thisSubscription
is currently unsubscribed,false
otherwise
-
add
public void add(Subscription s)
Adds a newSubscription
to thisSubscriptionList
if theSubscriptionList
is not yet unsubscribed. If theSubscriptionList
is unsubscribed,add
will indicate this by explicitly unsubscribing the newSubscription
as well.- Parameters:
s
- theSubscription
to add
-
remove
public void remove(Subscription s)
-
unsubscribe
public void unsubscribe()
Unsubscribe from all of the subscriptions in the list, which stops the receipt of notifications on the associatedSubscriber
.- Specified by:
unsubscribe
in interfaceSubscription
-
unsubscribeFromAll
private static void unsubscribeFromAll(java.util.Collection<Subscription> subscriptions)
-
clear
public void clear()
-
hasSubscriptions
public boolean hasSubscriptions()
Returns true if this composite is not unsubscribed and contains subscriptions.- Returns:
true
if this composite is not unsubscribed and contains subscriptions.
-
-