Interface Storage<T>

All Known Subinterfaces:
DeletableStorage<T>
All Known Implementing Classes:
VolatileStorage

@NonNullByDefault public interface Storage<T>
A Storage is the generic way to store key-value pairs in OHC. Each storage implementation can store its data differently, e.g in-memory or in-database.
Author:
Thomas Eichstaedt-Engelen - Initial contribution, Kai Kreuzer - improved return values
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Checks if the storage contains a key.
    @Nullable T
    get(String key)
    Gets the value mapped to the key specified.
    Gets all keys of this storage.
    Collection<@Nullable T>
    Gets all values of this storage.
    @Nullable T
    put(String key, @Nullable T value)
    Puts a key-value mapping into this storage.
    @Nullable T
    Removes the specified mapping from this map.
    default Stream<Map.Entry<String,@Nullable T>>
    Gets all storage entries as Stream.
  • Method Details

    • put

      @Nullable T put(String key, @Nullable T value)
      Puts a key-value mapping into this storage.
      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

      @Nullable T remove(String key)
      Removes the specified mapping from this map.
      Parameters:
      key - the mapping to remove
      Returns:
      the removed value or null if no entry existed
    • containsKey

      boolean containsKey(String key)
      Checks if the storage contains a key.
      Parameters:
      key - the key
      Returns:
      true if the storage contains the key, otherwise false
    • get

      @Nullable T get(String key)
      Gets the value mapped to the key specified.
      Parameters:
      key - the key
      Returns:
      the mapped value, null if no match
    • getKeys

      Collection<String> getKeys()
      Gets all keys of this storage.
      Returns:
      the keys of this storage
    • getValues

      Collection<@Nullable T> getValues()
      Gets all values of this storage.
      Returns:
      the values of this storage
    • stream

      default Stream<Map.Entry<String,@Nullable T>> stream()
      Gets all storage entries as Stream.
      Returns:
      a stream of all storage entries