T - type of reference.public class LazyAutoCloseableReference<T extends AutoCloseable> extends LazyAtomicReference<T> implements AutoCloseable
LazyAtomicReference which
holds an AutoCloseable reference and calls close()
when it itself is closed.| Constructor and Description |
|---|
LazyAutoCloseableReference(CallableRaisingIOE<? extends T> constructor)
Constructor for this instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Close the reference value if it is non-null.
|
T |
eval()
Get the value, constructing it if needed.
|
boolean |
isClosed()
Is the reference closed?
|
static <T extends AutoCloseable> |
lazyAutoCloseablefromSupplier(Supplier<T> supplier)
Create from a supplier.
|
apply, get, getConstructor, getReference, isSet, lazyAtomicReferenceFromSupplier, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waituncheckedpublic LazyAutoCloseableReference(CallableRaisingIOE<? extends T> constructor)
constructor - method to invoke to actually construct the inner object.public T eval() throws IOException
eval in class LazyAtomicReference<T extends AutoCloseable>IllegalStateException - if the reference is closed.IOException - on any evaluation failurepublic boolean isClosed()
public void close()
throws Exception
close in interface AutoCloseableException - failure to close.public static <T extends AutoCloseable> LazyAutoCloseableReference<T> lazyAutoCloseablefromSupplier(Supplier<T> supplier)
T - type of referencesupplier - supplier implementation.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.