From 444739d085cb075e0f378d16e2ba97c09b1319ee Mon Sep 17 00:00:00 2001 From: Stian Lyng <stianlyng@protonmail.com> Date: Tue, 18 Apr 2023 13:52:21 +0200 Subject: [PATCH] add repository --- .../repository/AllergyRepository.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 src/main/java/ntnu/idatt2016/v233/SmartMat/repository/AllergyRepository.java diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/AllergyRepository.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/AllergyRepository.java new file mode 100644 index 00000000..f675fea2 --- /dev/null +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/repository/AllergyRepository.java @@ -0,0 +1,46 @@ +package ntnu.idatt2016.v233.SmartMat.repository; + +import ntnu.idatt2016.v233.SmartMat.model.Allergy; + +import java.util.List; +import java.util.Optional; + +/** + * Repository for allergies + * + * @author Stian Lyng + * @version 1.0 + * @since 04.04.2023 + */ +public interface AllergyRepository { + /** + * Saves a allergy to the database + * + * @param allergy Allergy to save + */ + Allergy save (Allergy allergy); + + /** + * Gets an allergy by name + * + * @param name the name of the allergy + * @return an optional containing the Allergy if it exists + */ + Optional<Allergy> getByName(String name); + + /** + * Gets all allergies + * + * @return an optional containing a list of all allergies + */ + Optional<List<Allergy>> getAll(); + + + /** + * Deletes an allergy by its name + * + * @param name the name of the allergy + */ + void deleteById(String name); + +} -- GitLab