Class InMemoryTaskRepository

java.lang.Object
com.guinetik.hexafun.examples.tasks.InMemoryTaskRepository
All Implemented Interfaces:
TaskRepository

public class InMemoryTaskRepository extends Object implements TaskRepository
In-memory implementation of TaskRepository.

This is an adapter that implements the output port. Useful for testing and demos. In production, you'd have a JPA, JDBC, or other persistent implementation.

  • Constructor Details

    • InMemoryTaskRepository

      public InMemoryTaskRepository()
  • Method Details

    • save

      public Task save(Task task)
      Description copied from interface: TaskRepository
      Save a task (create or update).
      Specified by:
      save in interface TaskRepository
      Parameters:
      task - The task to save
      Returns:
      The saved task
    • findById

      public Optional<Task> findById(String id)
      Description copied from interface: TaskRepository
      Find a task by ID.
      Specified by:
      findById in interface TaskRepository
      Parameters:
      id - The task ID
      Returns:
      The task if found
    • findAll

      public List<Task> findAll()
      Description copied from interface: TaskRepository
      Find all tasks.
      Specified by:
      findAll in interface TaskRepository
      Returns:
      List of all tasks
    • delete

      public boolean delete(String id)
      Description copied from interface: TaskRepository
      Delete a task by ID.
      Specified by:
      delete in interface TaskRepository
      Parameters:
      id - The task ID
      Returns:
      true if deleted, false if not found
    • clear

      public void clear()
      Clear all tasks (useful for testing).
    • count

      public int count()
      Get the count of tasks.