|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectfulmine.util.reference.AutoCreatingStore<KEY,TYPE>
KEY - The type of the key used to access objects in this storeTYPE - The type of canonical objects this returnspublic final class AutoCreatingStore<KEY,TYPE>
This implementation manages a Map of objects against their key. When
the store is requested for an object, identified by its key, it returns the
cached object. The store uses an internal IObjectBuilder to create
instances of objects that do not exist.
This is thread safe; all methods are synchronized and return a copy of the collection where appropriate.
| Constructor Summary | |
|---|---|
AutoCreatingStore(IObjectBuilder<KEY,TYPE> builder)
Standard constructor |
|
| Method Summary | |
|---|---|
void |
clear()
Clear all keys and values from the store. |
boolean |
containsKey(KEY key)
Find out if there is an object held against the key. |
void |
destroy()
This is called when the object is being removed from application use. |
boolean |
equals(Object obj)
|
TYPE |
get(KEY key)
Get the object for the key. |
int |
hashCode()
|
Set<KEY> |
keySet()
Get a copy collection of all the keys in this store. |
TYPE |
remove(KEY key)
Remove the object associated with the key. |
String |
toString()
|
Collection<TYPE> |
values()
Get a copy collection of the values held in this store. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AutoCreatingStore(IObjectBuilder<KEY,TYPE> builder)
builder - the builder to use when constructing new canonical object
instances| Method Detail |
|---|
public TYPE get(KEY key)
IAutoCreatingStoreObject.equals(Object) method.
get in interface IAutoCreatingStore<KEY,TYPE>key - the key representation of the object
public TYPE remove(KEY key)
IAutoCreatingStoreIAutoCreatingStore.get(Object) for the same key
may create a new object instance. Keys are matched based on
the Object.equals(Object) method.
remove in interface IAutoCreatingStore<KEY,TYPE>key - the key identifying the object that will be removed
null if there was no objectpublic boolean containsKey(KEY key)
IAutoCreatingStoreObject.equals(Object) method.
containsKey in interface IAutoCreatingStore<KEY,TYPE>key - the key to find
true if there is an object held against the keypublic void clear()
IAutoCreatingStore
clear in interface IAutoCreatingStore<KEY,TYPE>public Set<KEY> keySet()
IAutoCreatingStore
keySet in interface IAutoCreatingStore<KEY,TYPE>public Collection<TYPE> values()
IAutoCreatingStore
values in interface IAutoCreatingStore<KEY,TYPE>public void destroy()
IDestroyable
This method must not throw a RuntimeException.
destroy in interface IDestroyablepublic String toString()
toString in class Objectpublic int hashCode()
hashCode in class Objectpublic boolean equals(Object obj)
equals in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||