Interface DisposableContainer
- All Superinterfaces:
Disposable
- All Known Implementing Classes:
CompositeDisposable
Common interface to add and remove
Disposables from a container.- Since:
- 2.0
-
Method Summary
Modifier and TypeMethodDescriptionbooleanAdds a disposable to this container or disposes it if the container has been disposed.voidclear()Removes and disposes all containedDisposables, making this container fresh without disposing the entire container.booleanRemoves but does not dispose the given disposable if it is part of this container.booleanRemoves and disposes the given disposable if it is part of this container.voidreset()Removes all containedDisposables without disposing them, making this container fresh.Methods inherited from interface Disposable
asAutoCloseable, dispose, isDisposedModifier and TypeMethodDescriptiondefault @NonNull AutoCloseableWraps thisDisposableinto anAutoCloseableinstance that can be used with try-with-resources constructs.voiddispose()Dispose the resource, the operation should be idempotent.booleanReturns true if this resource has been disposed.
-
Method Details
-
add
Adds a disposable to this container or disposes it if the container has been disposed.- Parameters:
d- the disposable to add, not null- Returns:
- true if successful, false if this container has been disposed
-
remove
Removes and disposes the given disposable if it is part of this container.- Parameters:
d- the disposable to remove and dispose, not null- Returns:
- true if the operation was successful
-
delete
Removes but does not dispose the given disposable if it is part of this container.- Parameters:
d- the disposable to remove, not null- Returns:
- true if the operation was successful
-
reset
void reset()Removes all containedDisposables without disposing them, making this container fresh.- Since:
- 4.0.0
-
clear
void clear()Removes and disposes all containedDisposables, making this container fresh without disposing the entire container.
-