de.innovationgate.utils
public class UserHashMap<KeyType,ValueType> extends java.lang.Object implements java.util.Map<KeyType,ValueType>
The UserHashMap may be regarded a "ThreadLocal" Map where every thread may have it's own private map. Main difference to ThreadLoval: Every thread may choose from a list of available maps where each map belongs to a single user.
UserHashMaps belong to UserHashMapGroup
objects. A UserHashMapGroup collects UserHashMaps that
should switch to the same users map at the same time. The UserHashMapGroup hosts methods for creating
new UserHashMaps (UserHashMapGroup.newUserHashMap(String)
) and for switching all of the maps
in the group to a specified user (UserHashMapGroup.fetchAllMapsForUser(String)
).
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears all entries from all users maps.
|
void |
clearUser()
Clears the entries of the current users map.
|
boolean |
containsKey(java.lang.Object key) |
boolean |
containsValue(java.lang.Object value) |
java.util.Set<java.util.Map.Entry<KeyType,ValueType>> |
entrySet() |
ValueType |
get(java.lang.Object key) |
java.util.Map<KeyType,ValueType> |
getCurrentUserMap()
Returns the currently served map as a single map.
|
UserHashMapGroup |
getGroup()
Returns the parent UserHashMapGroup object
|
java.util.Map<KeyType,ValueType> |
getMapForUser(java.lang.String user)
Returns the map for a specific user without switching the methods of the normal map interface to this map.
|
long |
getMapLatency()
Returns the map latency in milliseconds.
|
int |
getUserCount()
Returns the number of users who have own hashmaps
|
java.util.Map<java.lang.String,de.innovationgate.utils.UserHashMap.SingleUserMap> |
getUserMaps()
Returns a map of user's hash maps.
|
boolean |
isEmpty() |
java.util.Set<KeyType> |
keySet() |
ValueType |
put(KeyType key,
ValueType value) |
void |
putAll(java.util.Map<? extends KeyType,? extends ValueType> t) |
ValueType |
remove(java.lang.Object key) |
void |
removeFromAllUsers(KeyType key)
Removes a map key from all users maps
|
void |
removeFromAllUsers(KeyType key,
ValueType value)
Removes a map key from all users maps
If parameter value is given it only removes those keys that map equal values.
|
void |
setMapLatency(long mapLatency)
Sets the latency of the map.
|
int |
size() |
java.util.Collection<ValueType> |
values() |
public java.util.Map<KeyType,ValueType> getMapForUser(java.lang.String user)
user
- public java.util.Map<KeyType,ValueType> getCurrentUserMap()
public ValueType get(java.lang.Object key)
public boolean containsKey(java.lang.Object key)
public void clear()
public void clearUser()
public boolean containsValue(java.lang.Object value)
public boolean isEmpty()
public java.util.Set<KeyType> keySet()
public void removeFromAllUsers(KeyType key, ValueType value)
key
- The key to removevalue
- A value that must match the value mapped to key if the key should be removed. Specify null to remove the key in any case.public void removeFromAllUsers(KeyType key)
key
- The key to removepublic ValueType remove(java.lang.Object key)
public int size()
public java.util.Collection<ValueType> values()
public int getUserCount()
public UserHashMapGroup getGroup()
public java.util.Map<java.lang.String,de.innovationgate.utils.UserHashMap.SingleUserMap> getUserMaps()
public long getMapLatency()
public void setMapLatency(long mapLatency)
mapLatency
-