Package org.aksw.commons.util.ref
Class ResourceHolderImpl<T>
- java.lang.Object
-
- org.aksw.commons.util.ref.ResourceHolderImpl<T>
-
- Type Parameters:
T-
- All Implemented Interfaces:
AutoCloseable,ResourceHolder<T>
public class ResourceHolderImpl<T> extends Object implements ResourceHolder<T>
Associate a resource with a closing mechanism- Author:
- raven
-
-
Field Summary
Fields Modifier and Type Field Description protected AutoCloseablecloseActionprotected booleancloseActionRunprotected Tvalue
-
Constructor Summary
Constructors Constructor Description ResourceHolderImpl(T value, AutoCloseable closeAction)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()Tget()booleanisValid()A resource holder is valid as long as it was not closed.
-
-
-
Field Detail
-
value
protected T value
-
closeActionRun
protected boolean closeActionRun
-
closeAction
protected AutoCloseable closeAction
-
-
Constructor Detail
-
ResourceHolderImpl
public ResourceHolderImpl(T value, AutoCloseable closeAction)
-
-
Method Detail
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
isValid
public boolean isValid()
Description copied from interface:ResourceHolderA resource holder is valid as long as it was not closed. Note, that the underlying resource may yet be closed.- Specified by:
isValidin interfaceResourceHolder<T>- Returns:
-
get
public T get()
- Specified by:
getin interfaceResourceHolder<T>
-
-