T - type of reference.java.lang.AutoCloseable, java.util.function.Supplier<T>, CallableRaisingIOE<T>public class LazyAutoCloseableReference<T extends java.lang.AutoCloseable> extends LazyAtomicReference<T> implements java.lang.AutoCloseable
LazyAtomicReference which
holds an AutoCloseable reference and calls close()
when it itself is closed.| Constructor | Description |
|---|---|
LazyAutoCloseableReference(CallableRaisingIOE<? extends T> constructor) |
Constructor for this instance.
|
| Modifier and Type | Method | 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 java.lang.AutoCloseable> |
lazyAutoCloseablefromSupplier(java.util.function.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 java.io.IOException
eval in class LazyAtomicReference<T extends java.lang.AutoCloseable>java.lang.IllegalStateException - if the reference is closed.java.io.IOException - on any evaluation failurepublic boolean isClosed()
public void close()
throws java.lang.Exception
close in interface java.lang.AutoCloseablejava.lang.Exception - failure to close.public static <T extends java.lang.AutoCloseable> LazyAutoCloseableReference<T> lazyAutoCloseablefromSupplier(java.util.function.Supplier<T> supplier)
T - type of referencesupplier - supplier implementation.Copyright © 2008–2025 Apache Software Foundation. All rights reserved.