Package net.morimekta.providence.storage
Class InMemoryMessageListStore<K,M extends net.morimekta.providence.PMessage<M>>
- java.lang.Object
-
- net.morimekta.providence.storage.InMemoryMessageListStore<K,M>
-
- Type Parameters:
K- The key type.M- The stored message type.
- All Implemented Interfaces:
MessageListReadOnlyStore<K,M>,MessageListStore<K,M>,ReadOnlyStore<K,java.util.List<M>>,ReadWriteStore<K,java.util.List<M>>
public class InMemoryMessageListStore<K,M extends net.morimekta.providence.PMessage<M>> extends java.lang.Object implements MessageListStore<K,M>
Simple in-memory storage of lists providence messages. Uses a local hash map for storing the instances.The store is thread safe through using reentrand read-write mutex handling, so reading can happen in parallel.
-
-
Constructor Summary
Constructors Constructor Description InMemoryMessageListStore()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancontainsKey(K key)java.util.Map<K,java.util.List<M>>getAll(java.util.Collection<K> keys)Look up a set of keys from the storage.java.util.Collection<K>keys()Get a collection of all the keys in the store.voidputAll(java.util.Map<K,java.util.List<M>> values)voidremoveAll(java.util.Collection<K> keys)Remove the values for the given keys.intsize()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface net.morimekta.providence.storage.MessageListReadOnlyStore
getAllBuilders, getBuilders
-
Methods inherited from interface net.morimekta.providence.storage.MessageListStore
putAllBuilders, putBuilders
-
Methods inherited from interface net.morimekta.providence.storage.ReadOnlyStore
get
-
Methods inherited from interface net.morimekta.providence.storage.ReadWriteStore
put, remove
-
-
-
-
Method Detail
-
getAll
@Nonnull public java.util.Map<K,java.util.List<M>> getAll(@Nonnull java.util.Collection<K> keys)
Description copied from interface:ReadOnlyStoreLook up a set of keys from the storage.- Specified by:
getAllin interfaceReadOnlyStore<K,M extends net.morimekta.providence.PMessage<M>>- Parameters:
keys- The keys to look up.- Returns:
- Map of all the found key value pairs. Values not found should not have an entry in the result map (no key -> null mapping).
-
containsKey
public boolean containsKey(@Nonnull K key)- Specified by:
containsKeyin interfaceReadOnlyStore<K,M extends net.morimekta.providence.PMessage<M>>- Parameters:
key- The key to look up.- Returns:
- True if the key was contained in the map.
-
keys
@Nonnull public java.util.Collection<K> keys()
Description copied from interface:ReadOnlyStoreGet a collection of all the keys in the store.- Specified by:
keysin interfaceReadOnlyStore<K,M extends net.morimekta.providence.PMessage<M>>- Returns:
- Key collection.
-
size
public int size()
- Specified by:
sizein interfaceReadOnlyStore<K,M extends net.morimekta.providence.PMessage<M>>- Returns:
- Get the total number of entries in the store, same as the number of unique keys.
-
putAll
public void putAll(@Nonnull java.util.Map<K,java.util.List<M>> values)- Specified by:
putAllin interfaceReadWriteStore<K,M extends net.morimekta.providence.PMessage<M>>- Parameters:
values- Put all key value pairs form this map into the storage.
-
removeAll
public void removeAll(java.util.Collection<K> keys)
Description copied from interface:ReadWriteStoreRemove the values for the given keys.- Specified by:
removeAllin interfaceReadWriteStore<K,M extends net.morimekta.providence.PMessage<M>>- Parameters:
keys- Map of removed key value pairs.
-
-