|
@@ -1,30 +1,28 @@
|
|
|
package org.leumasjaffe.recipe.model;
|
|
package org.leumasjaffe.recipe.model;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
|
+import java.util.Collection;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
import javax.swing.ImageIcon;
|
|
import javax.swing.ImageIcon;
|
|
|
|
|
|
|
|
|
|
+import com.fasterxml.jackson.annotation.JsonIgnore;
|
|
|
|
|
+
|
|
|
import lombok.Data;
|
|
import lombok.Data;
|
|
|
|
|
|
|
|
-/**
|
|
|
|
|
- * Recipe handling logic::
|
|
|
|
|
- * if (num components == 1) {
|
|
|
|
|
- * let c := components(0)
|
|
|
|
|
- * create ingredient listing c.ingredients
|
|
|
|
|
- * add product panel for c
|
|
|
|
|
- * } else {
|
|
|
|
|
- * for (each component c) {
|
|
|
|
|
- * create ingredient listing c.title => c.ingredients
|
|
|
|
|
- * add product panel for c with heading c.title
|
|
|
|
|
- * }
|
|
|
|
|
- * }
|
|
|
|
|
- */
|
|
|
|
|
@Data
|
|
@Data
|
|
|
public class Recipe {
|
|
public class Recipe {
|
|
|
String title;
|
|
String title;
|
|
|
String description;
|
|
String description;
|
|
|
|
|
+ Object nutrition;
|
|
|
|
|
+ int servings;
|
|
|
Optional<ImageIcon> photo; // TODO JSONIZATION
|
|
Optional<ImageIcon> photo; // TODO JSONIZATION
|
|
|
- List<Product> products = new ArrayList<>();
|
|
|
|
|
|
|
+ List<Card> cards = new ArrayList<>();
|
|
|
|
|
+
|
|
|
|
|
+ @JsonIgnore
|
|
|
|
|
+ Collection<Ingredient> getIngredients() {
|
|
|
|
|
+ return cards.stream().flatMap(Card::getIngredientsAsStream).collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|