org.clazzes.util.lifecycle.impl
Class RecyclableImpl<T>

java.lang.Object
  extended by org.clazzes.util.lifecycle.impl.RecyclableImpl<T>
All Implemented Interfaces:
java.io.Serializable, ObjectCreatable<T>, Recyclable<T>
Direct Known Subclasses:
RecyclableObjectWrapper

public class RecyclableImpl<T>
extends java.lang.Object
implements Recyclable<T>, java.io.Serializable

A basic example implementation of Recyclable.

It will simply store key and objectFactory.
A call to recycle() will result in a call to Recycler.pushBack(Object, ObjectCreatable) with this as second argument.

The objectFactory will be tested whether it implements the Recycler interface before a call to Recycler.pushBack(Object, ObjectCreatable) is performed.

Author:
rbreuss
See Also:
Serialized Form

Field Summary
protected  T key
           
protected  ObjectFactory<T> objectFactory
           
 
Constructor Summary
RecyclableImpl()
           
 
Method Summary
 void recycle()
          When the lifecycle of an object is over, this method must be called to return it to the Recycler for later use.
 void setKey(T key)
          Specify key for the object.
 void setObjectFactory(ObjectFactory<T> factory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

key

protected T key

objectFactory

protected ObjectFactory<T> objectFactory
Constructor Detail

RecyclableImpl

public RecyclableImpl()
Method Detail

recycle

public void recycle()
Description copied from interface: Recyclable
When the lifecycle of an object is over, this method must be called to return it to the Recycler for later use.

Specified by:
recycle in interface Recyclable<T>

setKey

public void setKey(T key)
Description copied from interface: Recyclable
Specify key for the object.

Specified by:
setKey in interface Recyclable<T>
Parameters:
key - The key used to create the object from the factory.

setObjectFactory

public void setObjectFactory(ObjectFactory<T> factory)
Specified by:
setObjectFactory in interface ObjectCreatable<T>


Copyright © 2010. All Rights Reserved.