DataStore

Generic data storage for storing and retrieving DataItem objects.

Implementations are not guaranteed to be persistent. For instance, in cases where there may be insufficient storage space on the device, or other reasons such as write permissions etc.

Stored data requires an Expiry to be provided when storing, and expired data will not be included in any retrieval operations; that is, expired data won't be returned by get or getAll but it will also not be included in any aggregate methods such as keys or count

See also

Types

Link copied to clipboard

Enables editing multiple entries in the module storage in a transactional way.

Properties

Link copied to clipboard

Flow of keys from this DataStore that have been removed.

Link copied to clipboard

Flow of key-value pairs from this DataStore that have been updated.

Functions

Link copied to clipboard
abstract fun count(): Int

Returns the number of entries in this DataStore

Link copied to clipboard
abstract fun edit(): DataStore.Editor

Returns an Editor able to mutate the data in this ModuleStorage

Link copied to clipboard
open override fun extract(jsonPath: JsonPath<JsonPath.Component.Key>): DataItem?

Extracts a nested DataItem according to the given jsonPath.

open fun <T> extract(jsonPath: JsonPath<JsonPath.Component.Key>, converter: DataItemConverter<T>): T?

Extracts a nested DataItem according to the given jsonPath, and attempts to convert it to the type T using the given converter

Link copied to clipboard

Extracts a nested Boolean according to the given jsonPath.

Link copied to clipboard

Extracts a nested DataList according to the given jsonPath.

Link copied to clipboard

Extracts a nested DataObject according to the given jsonPath.

Link copied to clipboard

Extracts a nested Double according to the given jsonPath.

Link copied to clipboard

Extracts a nested Int according to the given jsonPath.

Link copied to clipboard

Extracts a nested Long according to the given jsonPath.

Link copied to clipboard

Extracts a nested String according to the given jsonPath.

Link copied to clipboard
abstract fun get(key: String): DataItem?

Gets the DataItem stored at the given key if there is one

open fun <T> get(key: String, converter: DataItemConverter<T>): T?

Gets the DataItem stored at the given key if there is one, and uses the given converter to translate it into an instance of type T

Link copied to clipboard
abstract fun getAll(): DataObject

Gets the entire DataObject containing all data stored.

Link copied to clipboard
open fun getBoolean(key: String): Boolean?

Gets the Boolean stored at the given key if there is one

Link copied to clipboard
open fun getDataList(key: String): DataList?

Gets the DataList stored at the given key if there is one

Link copied to clipboard

Gets the DataObject stored at the given key if there is one

Link copied to clipboard
open fun getDouble(key: String): Double?

Gets the Double stored at the given key if there is one

Link copied to clipboard
open fun getInt(key: String): Int?

Gets the Int stored at the given key if there is one

Link copied to clipboard
open fun getLong(key: String): Long?

Gets the Long stored at the given key if there is one

Link copied to clipboard
open fun getString(key: String): String?

Gets the String stored at the given key if there is one

Link copied to clipboard
abstract operator fun iterator(): Iterator<Map.Entry<String, DataItem>>
Link copied to clipboard
abstract fun keys(): List<String>

Returns all keys stored in this DataStore

Link copied to clipboard

Convenience method for merging a Iterable group of Observables of the same type.