swt23w23/src/main/java/catering/staff/Employee.java
Simon Bruder 6297f3c073
Update copyright dates of recently changed files
I forgot to update them in commits
743e459d41,
90d368a95b,
7fbd26d84c,
and 2d87b3928b.

It also adds swt23w23 as copyright owner on the time recording, as this
was forgotten when the attributions had initially been added.
2024-01-06 22:06:48 +01:00

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;
}
}