T
- The type of wrapped objects.public final class ObjectWrapper<T> extends PoolableObject<None> implements AutoCloseable
AutoCloseable
, which allows instances to be used in try-with-resources
blocks; when an instance is closed it is returned to the pool.Constructor and Description |
---|
ObjectWrapper(T value)
Creates a new object wrapper.
|
Modifier and Type | Method and Description |
---|---|
void |
close() |
static <T> Pool<ObjectWrapper<T>,None> |
newPool(PoolConfig config,
Supplier<T> supplier,
PoolLogger logger)
Creates a new pool of
ObjectWrapper instances. |
protected void |
releaseResources()
Releases any resources associated with this object.
|
String |
toString() |
protected boolean |
validate()
Checks whether or not this object is still valid.
|
T |
value()
The wrapped value.
|
addReference, isEnabled, logEvent, logEvent, logEvent, logEvent, release, removeReference
public ObjectWrapper(T value)
value
- The value to wrap.public T value()
protected boolean validate()
PoolableObject
Pool.acquire()
or Pool.acquireNow()
.
They will also have their resources released.validate
in class PoolableObject<None>
true
if this object is still valid, or false
otherwise.protected void releaseResources()
PoolableObject
releaseResources
in class PoolableObject<None>
public void close()
close
in interface AutoCloseable
public static <T> Pool<ObjectWrapper<T>,None> newPool(PoolConfig config, Supplier<T> supplier, PoolLogger logger)
ObjectWrapper
instances.T
- The type of objects wrapped by ObjectWrapper
instances in the pool.config
- The configuration to use.supplier
- A supplier to serve as factory for wrapped objects.logger
- The logger to use to log events triggered by the pool or pooled objects.NullPointerException
- If the given configuration, supplier or logger is null
.Copyright © 2022. All rights reserved.