#22: Setup Medication Model
All checks were successful
Quality Check / Qualty Check (push) Successful in 9s

Signed-off-by: Dominik Säume <Dominik.Saeume@hmmh.de>
This commit is contained in:
Dominik Säume 2024-05-04 09:11:37 +02:00
parent cda74bbf82
commit 60b3d587ea
Signed by: SZUT-Dominik
GPG key ID: 67D15BB250B41E7C

View file

@ -0,0 +1,149 @@
package de.hitec.nhplus.medication;
import javafx.beans.property.SimpleIntegerProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleStringProperty;
import javafx.collections.ObservableList;
import java.util.StringJoiner;
import java.util.stream.Collectors;
public class Medication {
private SimpleIntegerProperty id;
private final SimpleStringProperty name;
private final SimpleStringProperty manufacturer;
private final SimpleListProperty<String> ingredients;
private final SimpleStringProperty possibleSideEffects;
private final SimpleStringProperty administrationMethod;
private final SimpleIntegerProperty currentStock;
public Medication(
String name,
String manufacturer,
ObservableList<String> ingredients,
String possibleSideEffects,
String administrationMethod,
int currentStock
) {
this.name = new SimpleStringProperty(name);
this.manufacturer = new SimpleStringProperty(manufacturer);
this.ingredients = new SimpleListProperty<>(ingredients);
this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects);
this.administrationMethod = new SimpleStringProperty(administrationMethod);
this.currentStock = new SimpleIntegerProperty(currentStock);
}
public Medication(
int id,
String name,
String manufacturer,
ObservableList<String> ingredients,
String possibleSideEffects,
String administrationMethod,
int currentStock
) {
this.id = new SimpleIntegerProperty(id);
this.name = new SimpleStringProperty(name);
this.manufacturer = new SimpleStringProperty(manufacturer);
this.ingredients = new SimpleListProperty<>(ingredients);
this.possibleSideEffects = new SimpleStringProperty(possibleSideEffects);
this.administrationMethod = new SimpleStringProperty(administrationMethod);
this.currentStock = new SimpleIntegerProperty(currentStock);
}
public int getId() {
return id.get();
}
public SimpleIntegerProperty idProperty() {
return id;
}
public String getName() {
return name.get();
}
public SimpleStringProperty nameProperty() {
return name;
}
public void setName(String name) {
this.name.set(name);
}
public String getManufacturer() {
return manufacturer.get();
}
public SimpleStringProperty manufacturerProperty() {
return manufacturer;
}
public void setManufacturer(String manufacturer) {
this.manufacturer.set(manufacturer);
}
public ObservableList<String> getIngredients() {
return ingredients.get();
}
public SimpleListProperty<String> ingredientsProperty() {
return ingredients;
}
public void setIngredients(ObservableList<String> ingredients) {
this.ingredients.set(ingredients);
}
public String getPossibleSideEffects() {
return possibleSideEffects.get();
}
public SimpleStringProperty possibleSideEffectsProperty() {
return possibleSideEffects;
}
public void setPossibleSideEffects(String possibleSideEffects) {
this.possibleSideEffects.set(possibleSideEffects);
}
public String getAdministrationMethod() {
return administrationMethod.get();
}
public SimpleStringProperty administrationMethodProperty() {
return administrationMethod;
}
public void setAdministrationMethod(String administrationMethod) {
this.administrationMethod.set(administrationMethod);
}
public int getCurrentStock() {
return currentStock.get();
}
public SimpleIntegerProperty currentStockProperty() {
return currentStock;
}
public void setCurrentStock(int currentStock) {
this.currentStock.set(currentStock);
}
@Override
public String toString() {
return new StringJoiner(System.lineSeparator())
.add("MEDICATION")
.add("ID: " + this.getId())
.add("Name: " + this.getName())
.add("Manufacturer: " + this.getManufacturer())
.add("Ingredients: " + this.getIngredients()
.stream()
.collect(Collectors.joining(", ", "[", "]")))
.add("Possible Side Effects: " + this.getPossibleSideEffects())
.add("Administration Method: " + this.getAdministrationMethod())
.add("Current Stock: " + this.getCurrentStock())
.toString();
}
}