Skip to content

Commit 2d2c601

Browse files
feat: implement addIngredient and removeIngredient methods in Recipe class
1 parent 42a853d commit 2d2c601

File tree

1 file changed

+55
-1
lines changed

1 file changed

+55
-1
lines changed

src/main/java/com/otavio/aifoodapp/model/Recipe.java

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@
77
import jakarta.persistence.*;
88
import lombok.AllArgsConstructor;
99
import lombok.Data;
10+
import lombok.EqualsAndHashCode;
1011
import lombok.NoArgsConstructor;
11-
12+
@EqualsAndHashCode
1213
@Entity
1314
@Table(name = "tb_recipes")
1415

@@ -42,4 +43,57 @@ public class Recipe {
4243

4344

4445

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+
}
4599
}

0 commit comments

Comments
 (0)