T - the resource typepublic final class ListCompositeResource<T> extends java.lang.Object implements CompositeResource<T>, Disposable
| Constructor and Description |
|---|
ListCompositeResource(Consumer<? super T> disposer) |
ListCompositeResource(Consumer<? super T> disposer,
java.lang.Iterable<? extends T> initialResources) |
ListCompositeResource(Consumer<? super T> disposer,
T... initialResources) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(T newResource)
Adds a new resource to this composite or disposes it if the composite has been disposed.
|
boolean |
delete(T resource)
Removes the given resource if contained within this composite but doesn't call the disposer for it.
|
void |
dispose()
Dispose the resource, the operation should be idempotent.
|
boolean |
isDisposed() |
boolean |
remove(T resource)
Removes the given resource from this composite and calls the disposer if the resource
was indeed in the composite.
|
public ListCompositeResource(Consumer<? super T> disposer, T... initialResources)
public boolean add(T newResource)
add in interface CompositeResource<T>newResource - the new resource to add, not-null (not checked)public boolean remove(T resource)
remove in interface CompositeResource<T>resource - the resource to remove, not-null (not verified)public boolean delete(T resource)
delete in interface CompositeResource<T>resource - the resource to delete, not-null (not verified)public void dispose()
Disposabledispose in interface Disposablepublic boolean isDisposed()