info.magnolia.registry
Class RegistryMap<K,V>
java.lang.Object
info.magnolia.registry.RegistryMap<K,V>
- Type Parameters:
K
- the type of keys maintained by this mapV
- the type of mapped values
public class RegistryMap<K,V>
- extends Object
Thread safe map intended to be used for registries. Provides an atomic operation removeAndPutAll
that is
used to remove a set of previously added values before adding a collection of new ones. Read operations are blocked
until it completes guaranteeing proper visibility.
It is common for entities in registries to also hold their identifier. The method keyFormValue
can be
overridden to get the identifier from the value. This removes the need to package a set of entities that should be
added in a Map before calling removeAndPutAll(java.util.Collection, java.util.Map)
.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
RegistryMap
public RegistryMap()
get
public V get(K key)
getRequired
public V getRequired(K key)
throws RegistrationException
- Throws:
RegistrationException
put
public void put(K key,
V value)
put
public void put(V value)
remove
public void remove(K key)
removeAndPutAll
public void removeAndPutAll(Collection<K> toRemove,
Map<K,V> toPut)
removeAndPutAll
public Set<K> removeAndPutAll(Collection<K> toRemove,
Collection<V> toPut)
keySet
public Collection<K> keySet()
values
public Collection<V> values()
keyFromValue
protected K keyFromValue(V value)
Copyright © 2003-2014 Magnolia International Ltd.. All Rights Reserved.