- java.lang.Object
 - 
- com.github.robtimus.pool.PoolableObject<None>
 - 
- com.github.robtimus.pool.ObjectWrapper<T>
 
 
 
- 
- Type Parameters:
 T- The type of wrapped objects.
- All Implemented Interfaces:
 AutoCloseable
public final class ObjectWrapper<T> extends PoolableObject<None> implements AutoCloseable
A poolable object that wraps a single value. Instances will always be considered valid and have no resources to release. This class implementsAutoCloseable, which allows instances to be used in try-with-resources blocks; when an instance is closed it is returned to the pool.- Author:
 - Rob Spoor
 
 
- 
- 
Nested Class Summary
- 
Nested classes/interfaces inherited from class com.github.robtimus.pool.PoolableObject
PoolableObject.Reference<X extends Exception> 
 - 
 
- 
Constructor Summary
Constructors Constructor Description ObjectWrapper(T value)Creates a new object wrapper. 
- 
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()static <T> Pool<ObjectWrapper<T>,None>newPool(PoolConfig config, Supplier<T> supplier, PoolLogger logger)Creates a new pool ofObjectWrapperinstances.protected voidreleaseResources()Releases any resources associated with this object.StringtoString()protected booleanvalidate()Checks whether or not this object is still valid.Tvalue()The wrapped value.- 
Methods inherited from class com.github.robtimus.pool.PoolableObject
addReference, isEnabled, logEvent, logEvent, logEvent, logEvent, release 
 - 
 
 - 
 
- 
- 
Constructor Detail
- 
ObjectWrapper
public ObjectWrapper(T value)
Creates a new object wrapper.- Parameters:
 value- The value to wrap.
 
 - 
 
- 
Method Detail
- 
value
public T value()
The wrapped value.- Returns:
 - The wrapped value.
 
 
- 
validate
protected boolean validate()
Description copied from class:PoolableObjectChecks whether or not this object is still valid. Invalid object will be removed from the pool instead of being returned fromPool.acquire()orPool.acquireNow(). They will also have their resources released.- Specified by:
 validatein classPoolableObject<None>- Returns:
 trueif this object is still valid, orfalseotherwise.
 
- 
releaseResources
protected void releaseResources()
Description copied from class:PoolableObjectReleases any resources associated with this object.- Specified by:
 releaseResourcesin classPoolableObject<None>
 
- 
close
public void close()
- Specified by:
 closein interfaceAutoCloseable
 
- 
newPool
public static <T> Pool<ObjectWrapper<T>,None> newPool(PoolConfig config, Supplier<T> supplier, PoolLogger logger)
Creates a new pool ofObjectWrapperinstances.- Type Parameters:
 T- The type of objects wrapped byObjectWrapperinstances in the pool.- Parameters:
 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.- Returns:
 - The created pool.
 - Throws:
 NullPointerException- If the given configuration, supplier or logger isnull.
 
 - 
 
 -