Package org.openhab.core.storage
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 TypeMethodDescriptionboolean
containsKey
(String key) Checks if the storage contains a key.@Nullable T
Gets the value mapped to the key specified.getKeys()
Gets all keys of this storage.Collection<@Nullable T>
Gets all values of this storage.@Nullable T
Puts a key-value mapping into this storage.@Nullable T
Removes the specified mapping from this map.stream()
Gets all storage entries asStream
.
-
Method Details
-
put
Puts a key-value mapping into this storage.- Parameters:
key
- the key to addvalue
- the value to add- Returns:
- previous value for the key or null if no value was replaced
-
remove
Removes the specified mapping from this map.- Parameters:
key
- the mapping to remove- Returns:
- the removed value or null if no entry existed
-
containsKey
Checks if the storage contains a key.- Parameters:
key
- the key- Returns:
- true if the storage contains the key, otherwise false
-
get
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
Gets all storage entries asStream
.- Returns:
- a stream of all storage entries
-