Storage

interface Storage<K, T, U>

Synchronous storage contract for persisting and retrieving domain entities.

This interface defines the contract for persistent storage of domain objects. Implementations may use file systems, databases, or other storage backends.

This contract was based on roby2014 - uni-projects/TDS

Parameters

K

The type used to identify entities (e.g., String for names, Int for IDs).

T

The domain entity type being stored.

U

The storage format type used internally by the serializer (e.g., String, ByteArray).

Inheritors

Properties

Link copied to clipboard
abstract val serializer: Serializer<T, U>

The serializer responsible for converting entities to/from the storage format.

Functions

Link copied to clipboard
abstract fun close()

Closes the storage, releasing any held resources.

Link copied to clipboard
abstract fun delete(id: K)

Deletes an entity from storage by its identifier.

Link copied to clipboard
abstract fun lastModified(id: K): Long?

Gets the last modification timestamp for an entity.

Link copied to clipboard
abstract fun load(id: K): T?

Retrieves an entity from storage by its identifier.

Link copied to clipboard
abstract fun loadAllIds(): List<K>

Loads all identifiers currently stored in this storage.

Link copied to clipboard
abstract fun new(id: K, factory: () -> T): T

Creates a new entity in storage with the given identifier.

Link copied to clipboard
abstract fun save(id: K, obj: T)

Saves (persists) an entity in storage under the given identifier.