diff --git a/commons/src/main/java/commons/Recipe.java b/commons/src/main/java/commons/Recipe.java index 0472175..6ee2497 100644 --- a/commons/src/main/java/commons/Recipe.java +++ b/commons/src/main/java/commons/Recipe.java @@ -31,7 +31,6 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Objects; -import java.util.Collection; // TABLE named recipes @Entity @@ -48,45 +47,35 @@ public class Recipe { @Column(name = "name", nullable = false, unique = true) private String name; - /** - * Creates another table named recipe_ingredients which stores: - * recipe_ingredients(recipe_id -> recipes(id), ingredient). - *

- * Example recipe_ingredients table: - *

-     * | recipe_id           | ingredient |
-     * |---------------------|------------|
-     * | 0 (Chocolate Cake)  | Egg        |
-     * | 0 (Chocolate Cake)  | Egg        |
-     * | 0 (Chocolate Cake)  | Flour      |
-     * | 1 (Steak)           | 40g salt   |
-     * | 1 (Steak)           | 40g pepper |
-     * | 1 (Steak)           | Meat       |
-     * |----------------------------------|
-     * 
- * TODO: Replace String with Embeddable Ingredient Class - */ + // Creates another table named recipe_ingredients which stores: + // recipe_ingredients(recipe_id -> recipes(id), ingredient). + // Example recipe_ingredients table: + // | recipe_id | ingredient | + // |---------------------|------------| + // | 0 (Chocolate Cake) | Egg | + // | 0 (Chocolate Cake) | Egg | + // | 0 (Chocolate Cake) | Flour | + // | 1 (Steak) | 40g salt | + // | 1 (Steak) | 40g pepper | + // | 1 (Steak) | Meat | + // |----------------------------------| @ElementCollection @CollectionTable(name = "recipe_ingredients", joinColumns = @JoinColumn(name = "recipe_id")) @Column(name = "ingredient") + // TODO: Replace String with Embeddable Ingredient Class private List ingredients = new ArrayList<>(); - /** - * Creates another table named recipe_preparation which stores: - * recipe_preparation(recipe_id -> recipes(id), preparation_step, step_order). - *

- * Example recipe_preparation table: - *

-     * | recipe_id           | preparation_step     | step_order |
-     * |---------------------|----------------------|------------|
-     * | 0 (Chocolate Cake)  | Preheat oven         | 1          |
-     * | 0 (Chocolate Cake)  | Mix eggs and sugar   | 2          |
-     * | 0 (Chocolate Cake)  | Add flour gradually  | 3          |
-     * | 1 (Steak)           | Season meat          | 1          |
-     * | 1 (Steak)           | Heat pan             | 2          |
-     * |---------------------------------------------------------|
-     * 
- */ + // Creates another table named recipe_preparation which stores: + // recipe_preparation(recipe_id -> recipes(id), preparation_step, step_order). + // Example recipe_preparation table: + // | recipe_id | preparation_step | step_order | + // |---------------------|----------------------|------------| + // | 0 (Chocolate Cake) | Preheat oven | 1 | + // | 0 (Chocolate Cake) | Mix eggs and sugar | 2 | + // | 0 (Chocolate Cake) | Add flour gradually | 3 | + // | 1 (Steak) | Season meat | 1 | + // | 1 (Steak) | Heat pan | 2 | + // |---------------------------------------------------------| @ElementCollection @CollectionTable(name = "recipe_preparation", joinColumns = @JoinColumn(name = "recipe_id")) @Column(name = "preparation_step") @@ -129,16 +118,6 @@ public class Recipe { this.name = name; } - /** - * Returns an unmodifiable view of the ingredients list. - *

- * The returned list cannot be modified directly. To modify ingredients, - * create a copy using {@link List#copyOf(Collection)} or create your own list, - * populate it, and use {@link #setIngredients(List)} to update. - * - * @return An unmodifiable list of ingredients. - * @see #setIngredients(List) - */ // TODO: Replace String with Embeddable Ingredient Class public List getIngredients() { // Disallow modifying the returned list. @@ -146,22 +125,11 @@ public class Recipe { return Collections.unmodifiableList(ingredients); } - // TODO: Replace String with Embeddable Ingredient Class public void setIngredients(List ingredients) { this.ingredients = ingredients; } - /** - * Returns an unmodifiable view of the preparation steps list. - *

- * The returned list cannot be modified directly. To modify preparation steps, - * create a copy using {@link List#copyOf(Collection)} or create your own list, - * populate it, and use {@link #setPreparationSteps(List)} to update. - * - * @return An unmodifiable list of preparation steps in order. - * @see #setPreparationSteps(List) - */ public List getPreparationSteps() { // Disallow modifying the returned list. // You can still copy it with List.copyOf(...) @@ -195,17 +163,9 @@ public class Recipe { "}"; } - /** - * Returns a more detailed string than {@link #toString()} of this recipe, including - * the full contents of all ingredients and preparation steps. - *

- * Intended only for debugging. - * - * @return A detailed string representation containing all recipe data. - * @see #toString() - */ @SuppressWarnings("unused") public String toDetailedString() { + // More detailed toString for debugging. return "Recipe{" + "name='" + name + '\'' + ", ingredients=" + ingredients + @@ -213,4 +173,4 @@ public class Recipe { '}'; } -} +} \ No newline at end of file