Recipe.java 641 B

12345678910111213141516171819202122232425262728
  1. package org.leumasjaffe.recipe.model;
  2. import java.util.ArrayList;
  3. import java.util.Collection;
  4. import java.util.List;
  5. import java.util.Optional;
  6. import java.util.stream.Collectors;
  7. import javax.swing.ImageIcon;
  8. import com.fasterxml.jackson.annotation.JsonIgnore;
  9. import lombok.Data;
  10. @Data
  11. public class Recipe {
  12. String title;
  13. String description;
  14. Object nutrition;
  15. int servings;
  16. Optional<ImageIcon> photo; // TODO JSONIZATION
  17. List<Product> products = new ArrayList<>();
  18. @JsonIgnore
  19. Collection<Ingredient> getIngredients() {
  20. return products.stream().flatMap(Product::getIngredientsAsStream).collect(Collectors.toList());
  21. }
  22. }