Class RecycleOnClose<T,E extends Exception>
java.lang.Object
nonapi.io.github.classgraph.recycler.RecycleOnClose<T,E>
- Type Parameters:
T
- the type to recycleE
- the exception type that may be thrown when a recyclable item is acquired.
- All Implemented Interfaces:
AutoCloseable
An AutoCloseable wrapper for a recyclable object instance. Obtained by calling
Recycler.acquireRecycleOnClose()
in a try-with-resources statement, so that when the try block exits, the
acquired instance is recycled.-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionRecycleOnClose
(Recycler<T, E> recycler, T instance) Acquire or allocate an instance. -
Method Summary
-
Field Details
-
recycler
The recycler. -
instance
The instance.
-
-
Constructor Details
-
RecycleOnClose
Acquire or allocate an instance.- Parameters:
recycler
- TheRecycler
.instance
- An object instance that was obtained by callingRecycler.acquire()
on the recycler.- Throws:
IllegalArgumentException
- IfRecycler.newInstance()
returned null.
-
-
Method Details
-
get
Get the object instance.- Returns:
- The object instance.
-
close
public void close()Recycle an instance. CallsResettable.reset()
if the instance implementsResettable
.- Specified by:
close
in interfaceAutoCloseable
-