feat(commons/recipe): introduce weight sum calculations

This commit is contained in:
Zhongheng Liu 2026-01-19 14:38:21 +01:00
commit 23447a96d6
Signed by: steven
GPG key ID: F69B980899C1C09D

View file

@ -203,7 +203,10 @@ public class Recipe {
final double PER = 100; // Gram
return
this.ingredients.stream().mapToDouble(RecipeIngredient::getKcal).sum() /
this.ingredients.stream().mapToDouble(RecipeIngredient::getBaseAmount).sum() * PER;
weight() * PER;
}
public double weight() {
return this.ingredients.stream().mapToDouble(RecipeIngredient::getBaseAmount).sum();
}
}