Class RecycleOnClose<T, E extends Exception>

java.lang.Object
nonapi.io.github.classgraph.recycler.RecycleOnClose<T,E>
Type Parameters:
T - the type to recycle
E - the exception type that may be thrown when a recyclable item is acquired.
All Implemented Interfaces:
AutoCloseable

public class RecycleOnClose<T, E extends Exception> extends Object implements 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.
  • Method Details

    • get

      public T get()
      Get the object instance.
      Returns:
      The object instance.
    • close

      public void close()
      Recycle an instance. Calls Resettable.reset() if the instance implements Resettable.
      Specified by:
      close in interface AutoCloseable