T - entry type that should be closed if nop properly read.public final class SafeListBuilder<T extends Closeable> extends Object implements Closeable
build() is not called (eg: due to some exception) when close()
is called, then Closeable.close() method will be called on each inserted items.| Modifier and Type | Method and Description |
|---|---|
com.google.common.collect.ImmutableList.Builder<T> |
add(T element)
Adds
element to the ImmutableList. |
com.google.common.collect.ImmutableList.Builder<T> |
addAll(Iterable<? extends T> elements)
Adds each element of
elements to the ImmutableList. |
List<T> |
build()
Returns a newly-created
ImmutableList based on the contents of
the SafeListBuilder. |
static <T extends Closeable> |
builder()
Returns a new builder.
|
void |
close()
If
build() was not called yet, Closeable.close() method will be called on all items added
trough add(Closeable) and addAll(Iterable). |
public static final <T extends Closeable> SafeListBuilder<T> builder()
public com.google.common.collect.ImmutableList.Builder<T> add(T element)
element to the ImmutableList.element - the element to addBuilder objectNullPointerException - if element is nullpublic com.google.common.collect.ImmutableList.Builder<T> addAll(Iterable<? extends T> elements)
elements to the ImmutableList.elements - the Iterable to add to the ImmutableListBuilder objectNullPointerException - if elements is null or contains a
null elementpublic List<T> build()
ImmutableList based on the contents of
the SafeListBuilder.
After this call, close() wont have any effect on item of the list.
public void close()
throws IOException
build() was not called yet, Closeable.close() method will be called on all items added
trough add(Closeable) and addAll(Iterable).
If build() was already used, nothing will happen on the data of this builder.close in interface Closeableclose in interface AutoCloseableIOExceptionCopyright © 2011–2020. All rights reserved.