Interface EntityAwareMemory

All Superinterfaces:
DataMemory<String>
All Known Implementing Classes:
EntityDataMemory

public interface EntityAwareMemory extends DataMemory<String>
An entity-aware extension of DataMemory that enables the storage and retrieval of complex domain objects using structured mapping logic. *

Note: This is an experimental feature and is currently considered unstable. It provides a high-level abstraction for interacting with entities directly, abstracting away the underlying serialization and flattening processes.

*

Implementations must provide a MapperOperatorContract to handle the translation between raw memory paths and strongly-typed objects.

Since:
0.3
Author:
a8kj7sea
  • Method Details

    • getMapperService

      MapperOperatorContract getMapperService()
      Retrieves the mapper service responsible for converting entities to and from memory-compatible structures.
      Returns:
      the MapperOperatorContract instance used by this memory.
    • setEntity

      default <T> void setEntity(String path, T entity)
      Persists an arbitrary object into the memory under the specified path.

      This method delegates the serialization and flattening logic to the internal mapper service.

      Type Parameters:
      T - the type of the entity.
      Parameters:
      path - the base configuration path (e.g., "user.profile") where the entity will be stored.
      entity - the domain object instance to store.
    • getEntity

      default <T> Optional<T> getEntity(String path, Class<T> type)
      Retrieves and reconstructs an object of the specified type from the memory.

      This method delegates the unflattening and deserialization logic to the internal mapper service.

      Type Parameters:
      T - the expected type of the reconstructed entity.
      Parameters:
      path - the base configuration path where the entity data resides.
      type - the class literal of the entity type to load.
      Returns:
      an Optional containing the reconstructed entity, or Optional.empty() if the entity could not be loaded.