From 9f7f32beffdf58fe2dac4465a28bc69c9d97a44b Mon Sep 17 00:00:00 2001 From: Steven Liu Date: Thu, 15 Jan 2026 17:10:01 +0100 Subject: [PATCH] fix(commons/ingredient): add missing setters --- .../client/Ingredient/IngredientViewModel.java | 9 ++++++++- .../scenes/Ingredient/IngredientListCtrl.java | 2 -- .../scenes/nutrition/NutritionDetailsCtrl.java | 5 ----- commons/src/main/java/commons/Ingredient.java | 15 +++++++++++++-- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/client/src/main/java/client/Ingredient/IngredientViewModel.java b/client/src/main/java/client/Ingredient/IngredientViewModel.java index 90499a8..799c69f 100644 --- a/client/src/main/java/client/Ingredient/IngredientViewModel.java +++ b/client/src/main/java/client/Ingredient/IngredientViewModel.java @@ -3,7 +3,14 @@ package client.Ingredient; import commons.Ingredient; import javafx.beans.binding.Bindings; import javafx.beans.binding.DoubleBinding; -import javafx.beans.property.*; +import javafx.beans.property.DoubleProperty; +import javafx.beans.property.LongProperty; +import javafx.beans.property.ReadOnlyDoubleProperty; +import javafx.beans.property.ReadOnlyDoubleWrapper; +import javafx.beans.property.SimpleDoubleProperty; +import javafx.beans.property.SimpleLongProperty; +import javafx.beans.property.SimpleStringProperty; +import javafx.beans.property.StringProperty; public class IngredientViewModel { private final LongProperty id = new SimpleLongProperty(); diff --git a/client/src/main/java/client/scenes/Ingredient/IngredientListCtrl.java b/client/src/main/java/client/scenes/Ingredient/IngredientListCtrl.java index b63df27..4d223c8 100644 --- a/client/src/main/java/client/scenes/Ingredient/IngredientListCtrl.java +++ b/client/src/main/java/client/scenes/Ingredient/IngredientListCtrl.java @@ -27,8 +27,6 @@ public class IngredientListCtrl { private ListView ingredientListView; @FXML private NutritionDetailsCtrl nutritionDetailsCtrl; - @FXML - private ListView ingredientListView; @Inject public IngredientListCtrl( diff --git a/client/src/main/java/client/scenes/nutrition/NutritionDetailsCtrl.java b/client/src/main/java/client/scenes/nutrition/NutritionDetailsCtrl.java index 8232b23..25b7bfb 100644 --- a/client/src/main/java/client/scenes/nutrition/NutritionDetailsCtrl.java +++ b/client/src/main/java/client/scenes/nutrition/NutritionDetailsCtrl.java @@ -11,7 +11,6 @@ import javafx.application.Platform; import javafx.beans.binding.Bindings; import javafx.beans.property.SimpleObjectProperty; import javafx.event.ActionEvent; -import javafx.event.EventType; import javafx.fxml.FXML; import javafx.scene.control.Label; import javafx.scene.control.TextField; @@ -22,10 +21,6 @@ import javafx.scene.layout.VBox; import javafx.util.converter.NumberStringConverter; import java.io.IOException; -import java.util.IllegalFormatConversionException; -import java.util.IllegalFormatException; -import java.util.Optional; -import java.util.Set; import java.util.logging.Logger; public class NutritionDetailsCtrl implements LocaleAware { diff --git a/commons/src/main/java/commons/Ingredient.java b/commons/src/main/java/commons/Ingredient.java index c824912..a195dfc 100644 --- a/commons/src/main/java/commons/Ingredient.java +++ b/commons/src/main/java/commons/Ingredient.java @@ -84,10 +84,21 @@ public class Ingredient { public double getCarbsPer100g() { return carbsPer100g; } - public Long getId() { return id; } + public void setCarbsPer100g(double carbsPer100g) { + this.carbsPer100g = carbsPer100g; + } + + public void setFatPer100g(double fatPer100g) { + this.fatPer100g = fatPer100g; + } + + public void setProteinPer100g(double proteinPer100g) { + this.proteinPer100g = proteinPer100g; + } + public String getName() { return name; @@ -101,7 +112,7 @@ public class Ingredient { public boolean equals(Object o) { if (o == null || getClass() != o.getClass()) return false; Ingredient that = (Ingredient) o; - return id == that.id && Double.compare(proteinPer100g, that.proteinPer100g) == 0 && Double.compare(fatPer100g, that.fatPer100g) == 0 && Double.compare(carbsPer100g, that.carbsPer100g) == 0 && Objects.equals(name, that.name); + return Objects.equals(id, that.id) && Double.compare(proteinPer100g, that.proteinPer100g) == 0 && Double.compare(fatPer100g, that.fatPer100g) == 0 && Double.compare(carbsPer100g, that.carbsPer100g) == 0 && Objects.equals(name, that.name); } @Override