K
- type of the keysV
- type of the values@Beta public abstract class Registry<K,V> extends Object
Note that null keys or values are not allowed.
Modifier and Type | Field and Description |
---|---|
protected static MessageBundle |
BUNDLE |
Modifier | Constructor and Description |
---|---|
protected |
Registry(com.google.common.base.Function<K,K> keyNormalizer,
ArgumentChecker<K> keyChecker,
com.google.common.base.Function<V,V> valueNormalizer,
ArgumentChecker<V> valueChecker)
Protected constructor
|
Modifier and Type | Method and Description |
---|---|
Map<K,V> |
build()
Build the map
|
protected abstract void |
checkEntry(K key,
V value)
Check the validity of the entry before submitting it
|
Registry<K,V> |
clear()
Clear all entries from this registry
|
Registry<K,V> |
put(K key,
V value)
Add a key/value pair in this registry
|
Registry<K,V> |
putAll(Map<K,V> otherMap)
Put the contents from another map into this map builder
|
Registry<K,V> |
remove(K key)
Remove one key and its associated value from the registry
|
protected static final MessageBundle BUNDLE
protected Registry(com.google.common.base.Function<K,K> keyNormalizer, ArgumentChecker<K> keyChecker, com.google.common.base.Function<V,V> valueNormalizer, ArgumentChecker<V> valueChecker)
keyNormalizer
- the key normalizerkeyChecker
- the key checkervalueNormalizer
- the value normalizervalueChecker
- the value checkerNullPointerException
- one normalizer or checker is nullpublic final Registry<K,V> put(K key, V value)
Both the keys and values are first normalized, then checked; finally, before insertion, the key/value pair is checked.
key
- the keyvalue
- the valueNullPointerException
- the key or value is nullIllegalArgumentException
- see ArgumentChecker
public final Registry<K,V> putAll(Map<K,V> otherMap)
This calls put(Object, Object)
on each key/value pair in the
map.
otherMap
- the mapNullPointerException
- map is nullpublic final Registry<K,V> remove(K key)
key
- the key to removepublic final Map<K,V> build()
The returned map is immutable.
ImmutableMap