|
7 | 7 | import jakarta.persistence.*; |
8 | 8 | import lombok.AllArgsConstructor; |
9 | 9 | import lombok.Data; |
| 10 | +import lombok.EqualsAndHashCode; |
10 | 11 | import lombok.NoArgsConstructor; |
11 | | - |
| 12 | +@EqualsAndHashCode |
12 | 13 | @Entity |
13 | 14 | @Table(name = "tb_recipes") |
14 | 15 |
|
@@ -42,4 +43,57 @@ public class Recipe { |
42 | 43 |
|
43 | 44 |
|
44 | 45 |
|
| 46 | + public Recipe(String name, String description, List<String> instructions, List<String> nutritionalInfo) { |
| 47 | + this.name = name; |
| 48 | + this.description = description; |
| 49 | + this.instructions = instructions; |
| 50 | + this.nutritionalInfo = nutritionalInfo; |
| 51 | + } |
| 52 | + |
| 53 | + public Long getId() { |
| 54 | + return id; |
| 55 | + } |
| 56 | + public void setId(Long id) { |
| 57 | + this.id = id; |
| 58 | + } |
| 59 | + public String getName() { |
| 60 | + return name; |
| 61 | + } |
| 62 | + public void setName(String name) { |
| 63 | + this.name = name; |
| 64 | + } |
| 65 | + public String getDescription() { |
| 66 | + return description; |
| 67 | + } |
| 68 | + public void setDescription(String description) { |
| 69 | + this.description = description; |
| 70 | + } |
| 71 | + public List<String> getInstructions() { |
| 72 | + return instructions; |
| 73 | + } |
| 74 | + public void setInstructions(List<String> instructions) { |
| 75 | + this.instructions = instructions; |
| 76 | + } |
| 77 | + public List<String> getNutritionalInfo() { |
| 78 | + return nutritionalInfo; |
| 79 | + } |
| 80 | + public void setNutritionalInfo(List<String> nutritionalInfo) { |
| 81 | + this.nutritionalInfo = nutritionalInfo; |
| 82 | + } |
| 83 | + public Set<RecipeIngredient> getIngredientsList() { |
| 84 | + return ingredientsList; |
| 85 | + } |
| 86 | + public void setIngredientsList(Set<RecipeIngredient> ingredientsList) { |
| 87 | + this.ingredientsList = ingredientsList; |
| 88 | + } |
| 89 | + |
| 90 | + public void addIngredient(FoodItem foodItem, double quantity, String unit) { |
| 91 | + RecipeIngredient recipeIngredient = new RecipeIngredient(this, foodItem, quantity, unit); |
| 92 | + ingredientsList.add(recipeIngredient); |
| 93 | + } |
| 94 | + |
| 95 | + |
| 96 | + public void removeIngredient(RecipeIngredient recipeIngredient) { |
| 97 | + this.ingredientsList.remove(recipeIngredient); |
| 98 | + } |
45 | 99 | } |
0 commit comments