Class VolatileStorage<T>

  • All Implemented Interfaces:
    Storage<T>

    @NonNullByDefault
    public class VolatileStorage<T>
    extends Object
    implements Storage<T>
    A Storage implementation which stores it's data in-memory.
    Author:
    Thomas Eichstaedt-Engelen - Initial contribution, Kai Kreuzer - improved return values
    • Constructor Detail

      • VolatileStorage

        public VolatileStorage()
    • Method Detail

      • put

        public @Nullable T put​(String key,
                               @Nullable T value)
        Description copied from interface: Storage
        Puts a key-value mapping into this Storage.
        Specified by:
        put in interface Storage<T>
        Parameters:
        key - the key to add
        value - the value to add
        Returns:
        previous value for the key or null if no value was replaced
      • remove

        public @Nullable T remove​(String key)
        Description copied from interface: Storage
        Removes the specified mapping from this map.
        Specified by:
        remove in interface Storage<T>
        Parameters:
        key - the mapping to remove
        Returns:
        the removed value or null if no entry existed
      • containsKey

        public boolean containsKey​(String key)
        Description copied from interface: Storage
        Check if the storage contains a key.
        Specified by:
        containsKey in interface Storage<T>
        Parameters:
        key - the key
        Returns:
        true if the storage contains the key, otherwise false
      • get

        public @Nullable T get​(String key)
        Description copied from interface: Storage
        Gets the value mapped to the key specified.
        Specified by:
        get in interface Storage<T>
        Parameters:
        key - the key
        Returns:
        the mapped value, null if no match
      • getKeys

        public Collection<String> getKeys()
        Description copied from interface: Storage
        Gets all keys of this Storage.
        Specified by:
        getKeys in interface Storage<T>
        Returns:
        the keys of this Storage
      • getValues

        public Collection<@Nullable T> getValues()
        Description copied from interface: Storage
        Gets all values of this Storage.
        Specified by:
        getValues in interface Storage<T>
        Returns:
        the values of this Storage