Package org.ovirt.engine.api.extensions
Class ExtMap
- java.lang.Object
-
- org.ovirt.engine.api.extensions.ExtMap
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Cloneable
,java.util.concurrent.ConcurrentMap<ExtKey,java.lang.Object>
,java.util.Map<ExtKey,java.lang.Object>
public class ExtMap extends java.lang.Object implements java.util.concurrent.ConcurrentMap<ExtKey,java.lang.Object>, java.lang.Cloneable, java.io.Serializable
Type safe map. Keys are bundle of uuid and type, each value added is checked against key type.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.concurrent.ConcurrentMap<ExtKey,java.lang.Object>
map
Wrapped map.private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description ExtMap()
Constructs an empty ExtMap with the default initial capacity (16) and the default load factor (0.75).ExtMap(int initialCapacity)
Constructs an empty ExtMap with the specified initial capacity and the default load factor (0.75).ExtMap(int initialCapacity, float loadFactor)
Constructs an empty ExtMap with the specified initial capacity and load factor.ExtMap(java.util.Map<ExtKey,java.lang.Object> m)
Constructs a new ExtMap with the same mappings as the specified Map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
checkKeyValue(ExtKey key, java.lang.Object value)
Check if value matches key type.void
clear()
ExtMap
clone()
boolean
containsKey(java.lang.Object key)
boolean
containsValue(java.lang.Object value)
java.util.Set<java.util.Map.Entry<ExtKey,java.lang.Object>>
entrySet()
boolean
equals(java.lang.Object obj)
java.lang.Object
get(java.lang.Object key)
<T> T
get(ExtKey key)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.<T> T
get(ExtKey key, java.lang.Class<T> type)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.<T> T
get(ExtKey key, java.lang.Class<T> type, T defaultValue)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.<T> T
get(ExtKey key, java.lang.Object defaultValue)
Returns the value to which the specified key is mapped, or default.int
hashCode()
boolean
isEmpty()
java.util.Set<ExtKey>
keySet()
ExtMap
mput(java.util.Map<? extends ExtKey,? extends java.lang.Object> m)
Multiple putAll.ExtMap
mput(ExtKey key, java.lang.Object value)
Multiple put.java.lang.Object
put(ExtKey key, java.lang.Object value)
void
putAll(java.util.Map<? extends ExtKey,? extends java.lang.Object> m)
java.lang.Object
putIfAbsent(ExtKey key, java.lang.Object value)
java.lang.Object
remove(java.lang.Object key)
boolean
remove(java.lang.Object key, java.lang.Object value)
java.lang.Object
replace(ExtKey key, java.lang.Object value)
boolean
replace(ExtKey key, java.lang.Object oldValue, java.lang.Object newValue)
int
size()
java.lang.String
toString()
java.util.Collection<java.lang.Object>
values()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
map
private java.util.concurrent.ConcurrentMap<ExtKey,java.lang.Object> map
Wrapped map. Wrapper and not inhertence per assumption of future exposure if interface changes.
-
-
Constructor Detail
-
ExtMap
public ExtMap(int initialCapacity, float loadFactor)
Constructs an empty ExtMap with the specified initial capacity and load factor.- Parameters:
initialCapacity
- the initial capacity.loadFactor
- the load factor.- Throws:
java.lang.IllegalArgumentException
- if the initial capacity is negative or the load factor is nonpositive.
-
ExtMap
public ExtMap(int initialCapacity)
Constructs an empty ExtMap with the specified initial capacity and the default load factor (0.75).- Parameters:
initialCapacity
- the initial capacity.- Throws:
java.lang.IllegalArgumentException
- if the initial capacity is negative or the load factor is nonpositive.
-
ExtMap
public ExtMap()
Constructs an empty ExtMap with the default initial capacity (16) and the default load factor (0.75).
-
ExtMap
public ExtMap(java.util.Map<ExtKey,java.lang.Object> m)
Constructs a new ExtMap with the same mappings as the specified Map. The ExtMap is created with default load factor (0.75) and an initial capacity sufficient to hold the mappings in the specified Map.- Parameters:
m
- the map whose mappings are to be placed in this map.- Throws:
java.lang.NullPointerException
- if the specified map is null.
-
-
Method Detail
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equals
in interfacejava.util.Map<ExtKey,java.lang.Object>
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfacejava.util.Map<ExtKey,java.lang.Object>
- Overrides:
hashCode
in classjava.lang.Object
-
clone
public ExtMap clone()
- Overrides:
clone
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKey
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValue
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
entrySet
public java.util.Set<java.util.Map.Entry<ExtKey,java.lang.Object>> entrySet()
- Specified by:
entrySet
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
get
public java.lang.Object get(java.lang.Object key)
- Specified by:
get
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
keySet
public java.util.Set<ExtKey> keySet()
- Specified by:
keySet
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
put
public java.lang.Object put(ExtKey key, java.lang.Object value)
- Specified by:
put
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
putAll
public void putAll(java.util.Map<? extends ExtKey,? extends java.lang.Object> m)
- Specified by:
putAll
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
remove
public java.lang.Object remove(java.lang.Object key)
- Specified by:
remove
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
size
public int size()
- Specified by:
size
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
values
public java.util.Collection<java.lang.Object> values()
- Specified by:
values
in interfacejava.util.Map<ExtKey,java.lang.Object>
-
putIfAbsent
public java.lang.Object putIfAbsent(ExtKey key, java.lang.Object value)
-
remove
public boolean remove(java.lang.Object key, java.lang.Object value)
-
replace
public java.lang.Object replace(ExtKey key, java.lang.Object value)
-
replace
public boolean replace(ExtKey key, java.lang.Object oldValue, java.lang.Object newValue)
-
mput
public ExtMap mput(ExtKey key, java.lang.Object value)
Multiple put. Usable for adding multiple entries:ExtMap = new ExtMap().mput(key1, value1).mput(key2, value2);
- Parameters:
key
- key with which the specified value is to be associated.value
- value to be associated with the specified key.- Returns:
- this.
-
mput
public ExtMap mput(java.util.Map<? extends ExtKey,? extends java.lang.Object> m)
Multiple putAll. Usable for adding multiple entries:ExtMap = new ExtMap().mputAll(map1).mputAll(map2);
- Parameters:
m
- map to add.- Returns:
- this.
-
get
public <T> T get(ExtKey key, java.lang.Class<T> type, T defaultValue)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. Safe version of get().Integer i = <Integer> map.get(key1, Integer);
- Type Parameters:
T
- type of return and default value, inferred- Parameters:
key
- key with which the specified value is to be associated.type
- expected type.defaultValue
- default value to return.- Returns:
- Value.
-
get
public <T> T get(ExtKey key, java.lang.Class<T> type)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. Safe version of get().- Type Parameters:
T
- type of return value, inferred- Parameters:
key
- key with which the specified value is to be associated.type
- expected type.- Returns:
- Value.
- See Also:
get(ExtKey key, Class type, Object defaultValue)
-
get
public <T> T get(ExtKey key)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. Unsafe method of get with cast.Integer i = <Integer> map.get(key1);
- Type Parameters:
T
- type of return value- Parameters:
key
- key.- Returns:
- Value.
-
get
public <T> T get(ExtKey key, java.lang.Object defaultValue)
Returns the value to which the specified key is mapped, or default. Unsafe method of get with cast.Integer i = <Integer> map.get(key1, 5);
- Type Parameters:
T
- type of return and default value, inferred- Parameters:
key
- key.defaultValue
- default value.- Returns:
- Value.
-
checkKeyValue
private void checkKeyValue(ExtKey key, java.lang.Object value)
Check if value matches key type.
-
-