Class InMemoryMessageSetStore<K,​M extends net.morimekta.providence.PMessage<M,​F>,​F extends net.morimekta.providence.descriptor.PField>

  • All Implemented Interfaces:
    MessageReadOnlyStore<K,​M,​F>, MessageSetStore<K,​M,​F>, ReadOnlyStore<K,​M>, ReadWriteSetStore<K,​M>

    public class InMemoryMessageSetStore<K,​M extends net.morimekta.providence.PMessage<M,​F>,​F extends net.morimekta.providence.descriptor.PField>
    extends java.lang.Object
    implements MessageSetStore<K,​M,​F>
    Simple in-memory set storage of providence messages. Uses a local hash map for storing the instances. The store is thread safe through using re-entrant read-write mutex handling, so reading can happen in parallel.
    • Constructor Detail

      • InMemoryMessageSetStore

        public InMemoryMessageSetStore​(java.util.function.Function<M,​K> messageToKey)
    • Method Detail

      • getAll

        @Nonnull
        public java.util.Map<K,​M> getAll​(@Nonnull
                                               java.util.Collection<K> keys)
        Description copied from interface: ReadOnlyStore
        Look up a set of keys from the storage.
        Specified by:
        getAll in interface ReadOnlyStore<K,​M extends net.morimekta.providence.PMessage<M,​F>>
        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:
        containsKey in interface ReadOnlyStore<K,​M extends net.morimekta.providence.PMessage<M,​F>>
        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: ReadOnlyStore
        Get a collection of all the keys in the store.
        Specified by:
        keys in interface ReadOnlyStore<K,​M extends net.morimekta.providence.PMessage<M,​F>>
        Returns:
        Key collection.
      • putAll

        @Nonnull
        public java.util.Map<K,​M> putAll​(@Nonnull
                                               java.util.Collection<M> values)
        Specified by:
        putAll in interface ReadWriteSetStore<K,​M extends net.morimekta.providence.PMessage<M,​F>>
        Parameters:
        values - Put all key value pairs form this map into the storage.
        Returns:
        Immutable map of replaced values, if any.
      • removeAll

        @Nonnull
        public java.util.Map<K,​M> removeAll​(java.util.Collection<K> keys)
        Description copied from interface: ReadWriteSetStore
        Remove the values for the given keys.
        Specified by:
        removeAll in interface ReadWriteSetStore<K,​M extends net.morimekta.providence.PMessage<M,​F>>
        Parameters:
        keys - Map of removed key value pairs.
        Returns:
        Immutable map of removed values. Values not removed should not have an entry in the result set (no null entries).