public class ClassLocal<E> extends Object
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.
Constructor and Description |
---|
ClassLocal()
Create a new
ClassLocal object. |
Modifier and Type | Method and Description |
---|---|
E |
get(Object instance)
Get 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 |
set(Object instance,
E object)
Store an object and associate it with the class
of the specified instance.
|
public E get(Object instance)
instance
- An object instance of the classThreadLocal.get()
public void set(Object instance, E object)
instance
- An object instance of the classobject
- The object to storeThreadLocal.set(Object)