Interface DisposableContainer
- All Superinterfaces:
AutoCloseable, Disposable
- All Known Implementing Classes:
CompositeDisposable, DisposableContainer.NeverDisposableContainer
Common interface to add and remove disposables from a container.
- Since:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordImplementation of a never disposable container. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DisposableContainerThe container implementation that just ignores everything, for cases where the dispose signal has no side-effects to work with. -
Method Summary
Modifier and TypeMethodDescriptionbooleanadd(Disposable d) Adds 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.booleandelete(Disposable d) Removes but does not dispose the given disposable if it is part of this container.default DisposableRegisters aDisposablewith this container so that it can be removed and disposed via a simpleDisposable.dispose()call to the returned Disposable.booleanremove(Disposable d) Removes and disposes the given disposable if it is part of this container.voidreset()Removes all containedDisposables without disposing them, making this container fresh.default DisposableRegisters aDisposablewith this container so that it can be deleted, not disposed via a simpleDisposable.dispose()call to the returned Disposable.Methods inherited from interface Disposable
close, dispose, isDisposed
-
Field Details
-
NEVER
The container implementation that just ignores everything, for cases where the dispose signal has no side-effects to work with.- Since:
- 4.0.0
-
-
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. -
register
Registers aDisposablewith this container so that it can be removed and disposed via a simpleDisposable.dispose()call to the returned Disposable.- Parameters:
d- the disposable to register- Returns:
- the Disposable to trigger a
remove(Disposable) - Since:
- 4.0.0
- See Also:
-
subscribe
Registers aDisposablewith this container so that it can be deleted, not disposed via a simpleDisposable.dispose()call to the returned Disposable.- Parameters:
d- the disposable to register- Returns:
- the Disposable to trigger a
remove(Disposable) - Since:
- 4.0.0
- See Also:
-