fix(commons/scaling): delegate scaleBy(int) to scaleBy(double) impl

This commit is contained in:
Zhongheng Liu 2026-01-05 17:14:28 +01:00
commit 39b2bb9d61
2 changed files with 4 additions and 7 deletions

View file

@ -52,14 +52,9 @@ public class FormalIngredient extends RecipeIngredient implements Scalable<Forma
return amount + unitSuffix + " of " + ingredient.name;
}
@Override
public FormalIngredient scaleBy(int numPortions) {
return new FormalIngredient(getIngredient(), amount * numPortions, unitSuffix);
}
@Override
public FormalIngredient scaleBy(double factor) {
return new FormalIngredient(getIngredient(), amount, unitSuffix);
return new FormalIngredient(getIngredient(), amount * factor, unitSuffix);
}
@Override

View file

@ -1,6 +1,8 @@
package commons;
public interface Scalable<IngredientType extends RecipeIngredient> {
IngredientType scaleBy(int numPortions);
default IngredientType scaleBy(int numPortions) {
return scaleBy((double) numPortions);
};
IngredientType scaleBy(double factor);
}