diff --git a/src/main/java/ntnu/idatt2016/v233/SmartMat/model/Allergy.java b/src/main/java/ntnu/idatt2016/v233/SmartMat/model/Allergy.java new file mode 100644 index 0000000000000000000000000000000000000000..845d776c3eb6c81a2e17dbc3227f35bd0045ef4f --- /dev/null +++ b/src/main/java/ntnu/idatt2016/v233/SmartMat/model/Allergy.java @@ -0,0 +1,13 @@ +package ntnu.idatt2016.v233.SmartMat.model; + +/** + * This is a record class representing an allergy + * + * @author Stian Lyng + * @version 1.0 + * + * @param name The name of the allergy + * @param description The description of the allergy + */ +public record Allergy(String name, String description) { +} \ No newline at end of file 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 0000000000000000000000000000000000000000..f675fea2cbd5b3061941f11b931f2f5d87d949b5 --- /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); + +}