zinger.util.recycling
Interface ObjectGenerator
- All Known Implementing Classes:
- StringBufferGenerator, ArrayGenerator, ClassInstanceGenerator
- public interface ObjectGenerator
An interface for a simple instance factory. This is used by ObjectRecycler
.
- See Also:
ObjectRecycler
Method Summary |
java.lang.Object |
newObject()
Creates a new instance. |
boolean |
prepareObject(java.lang.Object obj,
java.lang.Object arg)
Prepares the instance for use (reuse) according to the argument passed. |
newObject
public java.lang.Object newObject()
- Creates a new instance.
prepareObject
public boolean prepareObject(java.lang.Object obj,
java.lang.Object arg)
throws java.lang.IllegalArgumentException
- Prepares the instance for use (reuse) according to the argument passed.
Since we can't absolutely be sure that the object being worked on is in valid state or
even that it was generated by this instance, we have a chance to refuse to prepare it
by returning
false
.
- Returns:
true
if the preparation succeeded
false
if there is something
wrong with the object passed- Throws:
java.lang.IllegalArgumentException
- if the argument passed for preparation is inappropriate