| 1234567891011121314151617181920212223242526272829303132333435363738 |
- package org.leumasjaffe.recipe.model;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Optional;
- import java.util.stream.Stream;
- import javax.swing.ImageIcon;
- import org.leumasjaffe.observer.Observable;
- import lombok.Data;
- import lombok.EqualsAndHashCode;
- @Data @EqualsAndHashCode(callSuper=false)
- public class RecipeCard extends Observable.Instance implements CompoundRecipeComponent {
- String title;
- String description;
- int servings;
- // TODO: Nutrition information
- Optional<ImageIcon> photo = Optional.empty(); // TODO JSONIZATION
- List<Element> elements = new ArrayList<>();
-
- @Override
- public Stream<Element> getComponents() {
- return elements.stream();
- }
-
- @Override
- public Stream<Ingredient> getIngredientsAsStream() {
- return getComponents().flatMap(Element::getIngredientsAsStream);
- }
- public CollatedDuration getCollatedDuration() {
- return getComponents().map(Element::getCollatedDuration)
- .reduce(CollatedDuration.ZERO, CollatedDuration::plus);
- }
- }
|