From 85d09a6094ffbeca0e5d9db9d6ed1400ee5c323a Mon Sep 17 00:00:00 2001
From: Stian Lyng <stianlyng@protonmail.com>
Date: Tue, 18 Apr 2023 14:07:18 +0200
Subject: [PATCH] add repository

---
 .../SmartMat/repository/RecipeRepository.java | 52 +++++++++++++++++++
 1 file changed, 52 insertions(+)
 create mode 100644 src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java

diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java
new file mode 100644
index 00000000..cae4ee3d
--- /dev/null
+++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/RecipeRepository.java
@@ -0,0 +1,52 @@
+package ntnu.idatt2016.v233.SmartMat.repository;
+
+import java.util.List;
+import java.util.Optional;
+
+import ntnu.idatt2016.v233.SmartMat.model.Recipe;
+
+/**
+ * This interface defines the methods for the recipe repository
+ * 
+ * @author Stian Lyng
+ * @version 1.0
+ */
+public interface RecipeRepository {
+
+    /**
+     * Saves a recipe to the database
+     * 
+     * @param recipe the recipe to save
+     */
+    Recipe save (Recipe recipe);
+
+    /**
+     * Gets a recipe by its ID
+     * 
+     * @param id the ID of the recipe
+     * @return an optional containing the recipe if it exists
+     */
+    Optional<Recipe> getById(long id);
+
+    /**
+     * Gets a recipe by its name
+     * @param name the name of the recipe
+     * @return an optional containing the recipe if it exists
+     */
+    Optional<Recipe> getByName(String name);
+
+    /**
+     * Gets all recipes
+     * 
+     * @return an optional containing a list of all recipes
+     */
+    Optional<List<Recipe>> getAll();
+    
+    /**
+     * Deletes a recipe by its ID
+     * 
+     * @param id the ID of the recipe
+     */
+    void deleteById(int id);
+    
+}
-- 
GitLab