|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.collections4.map.AbstractIterableMap<K,V>
org.apache.commons.collections4.map.AbstractMapDecorator<K,V>
org.apache.commons.collections4.map.FixedSizeMap<K,V>
public class FixedSizeMap<K,V>
Decorates another Map
to fix the size, preventing add/remove.
Any action that would change the size of the map is disallowed. The put method is allowed to change the value associated with an existing key however.
If trying to remove or clear the map, an UnsupportedOperationException is thrown. If trying to put a new mapping into the map, an IllegalArgumentException is thrown. This is because the put method can succeed if the mapping's key already exists in the map, so the put method is not always unsupported.
Note that FixedSizeMap is not synchronized and is not thread-safe.
If you wish to use this map from multiple threads concurrently, you must use
appropriate synchronization. The simplest approach is to wrap this map
using Collections.synchronizedMap(Map)
. This class may throw
exceptions when accessed by concurrent threads without synchronization.
This class is Serializable from Commons Collections 3.1.
Constructor Summary | |
---|---|
protected |
FixedSizeMap(Map<K,V> map)
Constructor that wraps (not copies). |
Method Summary | ||
---|---|---|
void |
clear()
|
|
Set<Map.Entry<K,V>> |
entrySet()
|
|
static
|
fixedSizeMap(Map<K,V> map)
Factory method to create a fixed size map. |
|
boolean |
isFull()
Returns true if this map is full and no new elements can be added. |
|
Set<K> |
keySet()
|
|
int |
maxSize()
Gets the maximum size of the map (the bound). |
|
V |
put(K key,
V value)
Note that the return type is Object, rather than V as in the Map interface. |
|
void |
putAll(Map<? extends K,? extends V> mapToCopy)
|
|
V |
remove(Object key)
|
|
Collection<V> |
values()
|
Methods inherited from class org.apache.commons.collections4.map.AbstractMapDecorator |
---|
containsKey, containsValue, decorated, equals, get, hashCode, isEmpty, size, toString |
Methods inherited from class org.apache.commons.collections4.map.AbstractIterableMap |
---|
mapIterator |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.apache.commons.collections4.IterableGet |
---|
mapIterator |
Methods inherited from interface org.apache.commons.collections4.Get |
---|
containsKey, containsValue, get, isEmpty, size |
Constructor Detail |
---|
protected FixedSizeMap(Map<K,V> map)
map
- the map to decorate, must not be null
IllegalArgumentException
- if map is nullMethod Detail |
---|
public static <K,V> FixedSizeMap<K,V> fixedSizeMap(Map<K,V> map)
K
- the key typeV
- the value typemap
- the map to decorate, must not be null
IllegalArgumentException
- if map is nullpublic V put(K key, V value)
Put
put
in interface Map<K,V>
put
in interface Put<K,V>
put
in class AbstractMapDecorator<K,V>
Map.put(Object, Object)
public void putAll(Map<? extends K,? extends V> mapToCopy)
putAll
in interface Map<K,V>
putAll
in interface Put<K,V>
putAll
in class AbstractMapDecorator<K,V>
Map.putAll(Map)
public void clear()
clear
in interface Map<K,V>
clear
in interface Put<K,V>
clear
in class AbstractMapDecorator<K,V>
Map.clear()
public V remove(Object key)
remove
in interface Map<K,V>
remove
in interface Get<K,V>
remove
in class AbstractMapDecorator<K,V>
Map.remove(Object)
public Set<Map.Entry<K,V>> entrySet()
entrySet
in interface Map<K,V>
entrySet
in interface Get<K,V>
entrySet
in class AbstractMapDecorator<K,V>
Map.entrySet()
public Set<K> keySet()
keySet
in interface Map<K,V>
keySet
in interface Get<K,V>
keySet
in class AbstractMapDecorator<K,V>
Map.keySet()
public Collection<V> values()
values
in interface Map<K,V>
values
in interface Get<K,V>
values
in class AbstractMapDecorator<K,V>
Map.values()
public boolean isFull()
BoundedMap
isFull
in interface BoundedMap<K,V>
true
if the map is fullpublic int maxSize()
BoundedMap
maxSize
in interface BoundedMap<K,V>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |