fix(commons/ingredient): add missing setters

This commit is contained in:
Zhongheng Liu 2026-01-15 17:10:01 +01:00
commit 9f7f32beff
Signed by: steven
GPG key ID: F69B980899C1C09D
4 changed files with 21 additions and 10 deletions

View file

@ -3,7 +3,14 @@ package client.Ingredient;
import commons.Ingredient; import commons.Ingredient;
import javafx.beans.binding.Bindings; import javafx.beans.binding.Bindings;
import javafx.beans.binding.DoubleBinding; 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 { public class IngredientViewModel {
private final LongProperty id = new SimpleLongProperty(); private final LongProperty id = new SimpleLongProperty();

View file

@ -27,8 +27,6 @@ public class IngredientListCtrl {
private ListView<Ingredient> ingredientListView; private ListView<Ingredient> ingredientListView;
@FXML @FXML
private NutritionDetailsCtrl nutritionDetailsCtrl; private NutritionDetailsCtrl nutritionDetailsCtrl;
@FXML
private ListView<Ingredient> ingredientListView;
@Inject @Inject
public IngredientListCtrl( public IngredientListCtrl(

View file

@ -11,7 +11,6 @@ import javafx.application.Platform;
import javafx.beans.binding.Bindings; import javafx.beans.binding.Bindings;
import javafx.beans.property.SimpleObjectProperty; import javafx.beans.property.SimpleObjectProperty;
import javafx.event.ActionEvent; import javafx.event.ActionEvent;
import javafx.event.EventType;
import javafx.fxml.FXML; import javafx.fxml.FXML;
import javafx.scene.control.Label; import javafx.scene.control.Label;
import javafx.scene.control.TextField; import javafx.scene.control.TextField;
@ -22,10 +21,6 @@ import javafx.scene.layout.VBox;
import javafx.util.converter.NumberStringConverter; import javafx.util.converter.NumberStringConverter;
import java.io.IOException; 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; import java.util.logging.Logger;
public class NutritionDetailsCtrl implements LocaleAware { public class NutritionDetailsCtrl implements LocaleAware {

View file

@ -84,10 +84,21 @@ public class Ingredient {
public double getCarbsPer100g() { public double getCarbsPer100g() {
return carbsPer100g; return carbsPer100g;
} }
public Long getId() { public Long getId() {
return id; 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() { public String getName() {
return name; return name;
@ -101,7 +112,7 @@ public class Ingredient {
public boolean equals(Object o) { public boolean equals(Object o) {
if (o == null || getClass() != o.getClass()) return false; if (o == null || getClass() != o.getClass()) return false;
Ingredient that = (Ingredient) o; 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 @Override