com.amazon.ion.impl.bin.utf8.Poolable Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ion-java Show documentation
Show all versions of ion-java Show documentation
A Java implementation of the Amazon Ion data notation.
The newest version!
package com.amazon.ion.impl.bin.utf8;
import java.io.Closeable;
/**
* Base class for types that may be pooled.
* @param the concrete type.
*/
abstract class Poolable> implements Closeable {
// The pool to which this object is linked.
private final Pool pool;
/**
* @param pool the pool to which the object will be returned upon {@link #close()}.
*/
Poolable(Pool pool) {
this.pool = pool;
}
/**
* Attempts to return this instance to the pool with which it is associated, if any.
*
* Do not continue to use this instance after calling this method.
*/
@Override
public void close() {
pool.returnToPool((T) this);
}
}