Interface HexaRepo<T>

Type Parameters:
T - The entity type this repository manages
All Known Implementing Classes:
InMemoryHexaRepo

public interface HexaRepo<T>
Generic repository interface for entity persistence operations. Provides CRUD (Create, Read, Update, Delete) operations with Result wrappers.
  • Method Details

    • save

      Result<T> save(T entity)
      Saves a single entity to the repository.
      Parameters:
      entity - The entity to save
      Returns:
      A Result containing the saved entity with any generated values
    • saveAll

      Result<List<T>> saveAll(List<T> entities)
      Saves multiple entities to the repository in a batch operation.
      Parameters:
      entities - The list of entities to save
      Returns:
      A Result containing the list of saved entities
    • findById

      Result<T> findById(String id)
      Finds an entity by its unique identifier.
      Parameters:
      id - The unique identifier of the entity
      Returns:
      A Result containing the found entity or an error if not found
    • findAll

      Result<List<T>> findAll()
      Retrieves all entities from the repository.
      Returns:
      A Result containing a list of all entities
    • findBy

      Result<List<T>> findBy(DirectoryStream.Filter<T> filter)
      Retrieves entities that match the given filter criteria.
      Parameters:
      filter - The filter to apply
      Returns:
      A Result containing a list of matching entities
    • findAll

      Result<List<T>> findAll(int offset, int limit)
      Retrieves a paginated list of entities.
      Parameters:
      offset - The number of entities to skip
      limit - The maximum number of entities to return
      Returns:
      A Result containing a list of entities within the specified range
    • count

      Result<Long> count()
      Counts the total number of entities in the repository.
      Returns:
      A Result containing the count of entities
    • update

      Result<T> update(String id, T entity)
      Updates an existing entity identified by its ID.
      Parameters:
      id - The ID of the entity to update
      entity - The updated entity data
      Returns:
      A Result containing the updated entity
    • deleteById

      Result<Boolean> deleteById(String id)
      Deletes an entity by its unique identifier.
      Parameters:
      id - The unique identifier of the entity to delete
      Returns:
      A Result containing a Boolean indicating success
    • deleteAllById

      Result<Void> deleteAllById(List<String> ids)
      Deletes multiple entities by their IDs in a batch operation.
      Parameters:
      ids - The list of entity IDs to delete
      Returns:
      A Result indicating the operation outcome
    • clear

      Result<Void> clear()
      Removes all entities from the repository.
      Returns:
      A Result indicating the operation outcome