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
-
-
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 voidclear()ExtMapclone()booleancontainsKey(java.lang.Object key)booleancontainsValue(java.lang.Object value)java.util.Set<java.util.Map.Entry<ExtKey,java.lang.Object>>entrySet()booleanequals(java.lang.Object obj)java.lang.Objectget(java.lang.Object key)<T> Tget(ExtKey key)Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.<T> Tget(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> Tget(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> Tget(ExtKey key, java.lang.Object defaultValue)Returns the value to which the specified key is mapped, or default.inthashCode()booleanisEmpty()java.util.Set<ExtKey>keySet()ExtMapmput(java.util.Map<? extends ExtKey,? extends java.lang.Object> m)Multiple putAll.ExtMapmput(ExtKey key, java.lang.Object value)Multiple put.java.lang.Objectput(ExtKey key, java.lang.Object value)voidputAll(java.util.Map<? extends ExtKey,? extends java.lang.Object> m)java.lang.ObjectputIfAbsent(ExtKey key, java.lang.Object value)java.lang.Objectremove(java.lang.Object key)booleanremove(java.lang.Object key, java.lang.Object value)java.lang.Objectreplace(ExtKey key, java.lang.Object value)booleanreplace(ExtKey key, java.lang.Object oldValue, java.lang.Object newValue)intsize()java.lang.StringtoString()java.util.Collection<java.lang.Object>values()
-
-
-
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:
equalsin interfacejava.util.Map<ExtKey,java.lang.Object>- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Specified by:
hashCodein interfacejava.util.Map<ExtKey,java.lang.Object>- Overrides:
hashCodein classjava.lang.Object
-
clone
public ExtMap clone()
- Overrides:
clonein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Map<ExtKey,java.lang.Object>
-
containsKey
public boolean containsKey(java.lang.Object key)
- Specified by:
containsKeyin interfacejava.util.Map<ExtKey,java.lang.Object>
-
containsValue
public boolean containsValue(java.lang.Object value)
- Specified by:
containsValuein interfacejava.util.Map<ExtKey,java.lang.Object>
-
entrySet
public java.util.Set<java.util.Map.Entry<ExtKey,java.lang.Object>> entrySet()
- Specified by:
entrySetin interfacejava.util.Map<ExtKey,java.lang.Object>
-
get
public java.lang.Object get(java.lang.Object key)
- Specified by:
getin interfacejava.util.Map<ExtKey,java.lang.Object>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Map<ExtKey,java.lang.Object>
-
keySet
public java.util.Set<ExtKey> keySet()
- Specified by:
keySetin interfacejava.util.Map<ExtKey,java.lang.Object>
-
put
public java.lang.Object put(ExtKey key, java.lang.Object value)
- Specified by:
putin interfacejava.util.Map<ExtKey,java.lang.Object>
-
putAll
public void putAll(java.util.Map<? extends ExtKey,? extends java.lang.Object> m)
- Specified by:
putAllin interfacejava.util.Map<ExtKey,java.lang.Object>
-
remove
public java.lang.Object remove(java.lang.Object key)
- Specified by:
removein interfacejava.util.Map<ExtKey,java.lang.Object>
-
size
public int size()
- Specified by:
sizein interfacejava.util.Map<ExtKey,java.lang.Object>
-
values
public java.util.Collection<java.lang.Object> values()
- Specified by:
valuesin 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.
-
-