at.molindo.utils.concurrent
Class ObjectPool<T>
java.lang.Object
at.molindo.utils.concurrent.ObjectPool<T>
public abstract class ObjectPool<T>
- extends Object
|
Method Summary |
protected abstract T |
create()
|
static
|
create(Class<T> cls,
int capacity)
create an ObjectPool that uses the default constructor of the passed
class |
T |
get()
|
void |
put(T o)
|
T |
refresh(T o)
|
protected boolean |
reset(T object)
reset an object, e.g. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ObjectPool
public ObjectPool(int capacity)
create
public static <T> ObjectPool<T> create(Class<T> cls,
int capacity)
- create an ObjectPool that uses the default constructor of the passed
class
get
public T get()
- Returns:
- object from stack or newly created one
put
public void put(T o)
- Parameters:
put - object back on stack
create
@Nonnull
protected abstract T create()
- Returns:
- a newly created object
reset
protected boolean reset(T object)
- reset an object, e.g. call
Collection.clear()
- Parameters:
object -
- Returns:
false if object shouldn't be reused
refresh
public T refresh(T o)
Copyright © 2013 Molindo GmbH. All Rights Reserved.