mirror of
https://github.com/st-tu-dresden-praktikum/swt23w23
synced 2024-07-04 20:39:38 +02:00
I forgot to update them in commits743e459d41
,90d368a95b
,7fbd26d84c
, and2d87b3928b
. It also adds swt23w23 as copyright owner on the time recording, as this was forgotten when the attributions had initially been added.
76 lines
1.3 KiB
Java
76 lines
1.3 KiB
Java
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
// SPDX-FileCopyrightText: 2023-2024 swt23w23
|
|
package catering.staff;
|
|
|
|
import static org.salespointframework.core.Currencies.EURO;
|
|
|
|
import java.util.Objects;
|
|
|
|
import javax.money.MonetaryAmount;
|
|
|
|
import org.javamoney.moneta.Money;
|
|
|
|
import jakarta.persistence.Entity;
|
|
import jakarta.persistence.GeneratedValue;
|
|
import jakarta.persistence.Id;
|
|
|
|
@Entity
|
|
public class Employee {
|
|
|
|
private String name;
|
|
private JobType job;
|
|
private @Id @GeneratedValue Long id;
|
|
private MonetaryAmount wage;
|
|
|
|
protected Employee() {
|
|
// No-argument constructor for JPA
|
|
}
|
|
|
|
public Employee(String name, JobType job, MonetaryAmount wage) {
|
|
this.name = name;
|
|
this.job = job;
|
|
this.wage = wage;
|
|
}
|
|
|
|
public Long getId() {
|
|
return id;
|
|
}
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public JobType getJob() {
|
|
return job;
|
|
}
|
|
|
|
public Double getWage() {
|
|
return wage.getNumber().doubleValue();
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public void setJob(JobType job) {
|
|
this.job = job;
|
|
}
|
|
|
|
public void setWage(Double wage) {
|
|
this.wage = Money.of(wage, EURO);
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
return Objects.hash(Employee.class, getId());
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (obj instanceof Employee other) {
|
|
return id.equals(other.id);
|
|
}
|
|
return false;
|
|
}
|
|
}
|