Class Recycler<T extends AutoCloseable,E extends Exception>
- java.lang.Object
-
- io.github.lukehutch.fastclasspathscanner.utils.Recycler<T,E>
-
- All Implemented Interfaces:
AutoCloseable
public abstract class Recycler<T extends AutoCloseable,E extends Exception> extends Object implements AutoCloseable
Recycle instances of type T. The method T#close() is called when this class' own close() method is called. Use RuntimeException for type E if the newInstance() method does not throw an exception.
-
-
Constructor Summary
Constructors Constructor Description Recycler()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description T
acquire()
Acquire or allocate an instance.void
close()
Call this only after all instances have been released.abstract T
newInstance()
Create a new instance.void
release(T instance)
Release/recycle an instance.
-