|
|
@@ -2,7 +2,6 @@ package org.leumasjaffe.recipe.model;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
import org.leumasjaffe.observer.Observable;
|
|
|
@@ -18,7 +17,7 @@ public class Phase extends Observable.Instance implements CompoundRecipeComponen
|
|
|
String vessel = "";
|
|
|
Preparation preparation = new Preparation();
|
|
|
List<Step> cooking = new ArrayList<>();
|
|
|
- Optional<Rest> rest = Optional.empty();
|
|
|
+ Rest rest = new Rest();
|
|
|
|
|
|
public Stream<Ingredient> getIngredientsAsStream() {
|
|
|
return cooking.stream().flatMap(RecipeComponent::getIngredientsAsStream);
|
|
|
@@ -32,7 +31,8 @@ public class Phase extends Observable.Instance implements CompoundRecipeComponen
|
|
|
public CollatedDuration getCollatedDuration() {
|
|
|
final Duration prep = preparation.getIngredients().isEmpty() ?
|
|
|
Duration.ZERO : preparation.getDuration();
|
|
|
- final Duration rest = this.rest.map(Rest::getDuration).orElse(Duration.ZERO);
|
|
|
+ final Duration rest = this.rest.getWhere() == Rest.Where.NONE
|
|
|
+ ? Duration.ZERO : this.rest.getDuration();
|
|
|
final Duration cooking = this.cooking.stream().map(Step::getDuration)
|
|
|
.reduce(Duration.ZERO, Duration::plus);
|
|
|
return new CollatedDuration(prep, cooking, prep.plus(cooking).plus(rest));
|