|
|
@@ -1,10 +1,10 @@
|
|
|
package org.leumasjaffe.recipe.model;
|
|
|
|
|
|
import java.util.Collection;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
+import org.leumasjaffe.recipe.util.Collator;
|
|
|
+
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
|
|
|
|
@JsonIgnoreProperties({"duration", "ingredients", "components", "ingredientsAsStream"})
|
|
|
@@ -20,12 +20,6 @@ interface CompoundRecipeComponent extends RecipeComponent {
|
|
|
|
|
|
@Override
|
|
|
default Collection<Ingredient> getIngredients() {
|
|
|
- final Map<String, Ingredient> map = new HashMap<>();
|
|
|
- getIngredientsAsStream().forEach(i -> {
|
|
|
- final String key = i.key();
|
|
|
- map.computeIfPresent(key, (k, v) -> v.plus(i));
|
|
|
- map.computeIfAbsent(key, k -> i);
|
|
|
- });
|
|
|
- return map.values();
|
|
|
+ return Collator.collateBy(getIngredientsAsStream(), Ingredient::key, Ingredient::plus);
|
|
|
}
|
|
|
}
|