public class Resource<T,E extends java.lang.Exception>
extends java.lang.Object
implements java.lang.AutoCloseable
Try util in case original
resource doesn't implements AutoCloseable. This class provides functionality to wrap existing resource
and store operation for it's proper closing and then it will be delegated from AutoCloseable.close().create(Object, DangerousConsumer),
getValue()| Modifier and Type | Method and Description |
|---|---|
void |
close() |
static <T,E extends java.lang.Exception> |
create(T value,
DangerousConsumer<T,E> close)
Create new resource wrapper for specified actual resource and specified close operation for the resource.
|
DangerousConsumer<T,E> |
getClose() |
T |
getValue()
Returns actual resource.
|
public static <T,E extends java.lang.Exception> Resource<T,E> create(T value, DangerousConsumer<T,E> close)
public T getValue()
public DangerousConsumer<T,E> getClose()