feat: Person equals & hashcode
This commit is contained in:
parent
f1650ba542
commit
9058be6a35
3 changed files with 24 additions and 4 deletions
|
@ -7,6 +7,7 @@ import lombok.Getter;
|
|||
import lombok.Setter;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@Entity
|
||||
|
@ -47,4 +48,23 @@ public class Person {
|
|||
|
||||
@ManyToMany(mappedBy = "participants")
|
||||
private Set<Event> events;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof Person)) {
|
||||
return false;
|
||||
}
|
||||
Person other = (Person) obj;
|
||||
return Objects.equals(firstName, other.firstName) &&
|
||||
Objects.equals(lastName, other.lastName) &&
|
||||
Objects.equals(email, other.email);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(firstName, lastName, email);
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ import org.springframework.data.jpa.domain.Specification;
|
|||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
import java.util.Optional;
|
||||
|
||||
@Service
|
||||
|
@ -27,7 +27,7 @@ public class PersonService {
|
|||
return personRepository.findById(id);
|
||||
}
|
||||
|
||||
public List<Person> findAll() {
|
||||
public Collection<Person> findAll() {
|
||||
return this.personRepository.findAll();
|
||||
}
|
||||
|
||||
|
|
|
@ -226,7 +226,7 @@ public class PeopleView extends Div implements BeforeEnterObserver {
|
|||
badge.setText("Debit");
|
||||
badge.getElement().getThemeList().add("badge error");
|
||||
} else {
|
||||
badge.setText("Nothing");
|
||||
badge.setText("Clear");
|
||||
badge.getElement().getThemeList().add("badge contrast");
|
||||
}
|
||||
return badge;
|
||||
|
|
Loading…
Reference in a new issue