Package net.sf.basedb.util
Class ClassLocal<E>
java.lang.Object
net.sf.basedb.util.ClassLocal<E>
This class is a similar to the JDK
ThreadLocal
class,
but stores one object per class instead of one object per thread.
The main usage for this class is to allow a superclass to hold one object for each subclass that is extending it.
- Version:
- 2.0
- Author:
- Nicklas
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionGet the object associated with the class of the specified instance.protected E
initialValue
(Object instance) Subclasses may override this to initialize the object stored for that class.void
Store an object and associate it with the class of the specified instance.
-
Field Details
-
objects
-
-
Constructor Details
-
ClassLocal
public ClassLocal()Create a newClassLocal
object.
-
-
Method Details
-
get
Get the object associated with the class of the specified instance.- Parameters:
instance
- An object instance of the class- See Also:
-
set
Store an object and associate it with the class of the specified instance.- Parameters:
instance
- An object instance of the classobject
- The object to store- See Also:
-
initialValue
Subclasses may override this to initialize the object stored for that class.- Parameters:
instance
- An object instance of the class- Returns:
- The object to associate with the class
-