feat(client/scaling): initial implementation

This commit is contained in:
Zhongheng Liu 2026-01-18 14:18:19 +01:00
commit 54db9bddff
Signed by: steven
GPG key ID: F69B980899C1C09D
4 changed files with 96 additions and 5 deletions

View file

@ -191,5 +191,14 @@ public class Recipe {
", preparationSteps=" + preparationSteps +
'}';
}
public static Recipe getScaled(Recipe recipe, Double scale) {
List<RecipeIngredient> i = recipe.getIngredients().stream().map(ri -> switch (ri) {
case FormalIngredient f -> f.scaleBy(scale);
case VagueIngredient v -> v;
default -> throw new IllegalStateException("Unexpected value: " + ri);
}).toList();
return new Recipe(recipe.getId(), recipe.getName(), recipe.getLocale(), i, recipe.getPreparationSteps());
}
}