Top Description Fields Constructors Methods
nonapi.io.github.classgraph.recycler

public Class RecycleOnClose<T, E extends Exception>

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Type Parameters
<T>
the type to recycle
<E>
the exception type that may be thrown when a recyclable item is acquired.

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

Modifier and TypeField and Description
private final T
instance

The instance.

private final Recycler<T, E>
recycler

The recycler.

Constructor Summary

AccessConstructor and Description
pack-priv
RecycleOnClose(final Recycler<T, E> recycler, final T
An object instance that was obtained by calling Recycler#acquire() on the recycler.
instance
)

Acquire or allocate an instance.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.lang.AutoCloseable.close.

Recycle an instance.

public T

Returns:

The object instance.
get
()

Get the object instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

instanceback to summary
private final T instance

The instance.

recyclerback to summary
private final Recycler<T, E> recycler

The recycler.

Constructor Detail

RecycleOnCloseback to summary
pack-priv RecycleOnClose(final Recycler<T, E> recycler, final T instance)

Acquire or allocate an instance.

Parameters
recycler:Recycler<T, E>

The Recycler.

instance:T

An object instance that was obtained by calling Recycler#acquire() on the recycler.

Exceptions
IllegalArgumentException:
If Recycler#newInstance() returned null.

Method Detail

closeback to summary
public void close()

Implements java.lang.AutoCloseable.close.

Recycle an instance. Calls Resettable#reset() if the instance implements Resettable.

Annotations
@Override
getback to summary
public T get()

Get the object instance.

Returns:T

The object instance.