Merge pull request #14194 from ulisseslima/bael-6253-quickfix_records

BAEL 6253 - quick fix - Overridding hashCode() and equals() for Records
This commit is contained in:
Loredana Crusoveanu 2023-06-08 17:07:49 +03:00 committed by GitHub
commit 0ac97ec5d9
1 changed files with 16 additions and 12 deletions

View File

@ -4,20 +4,24 @@ import java.util.Objects;
record Movie(String name, Integer yearOfRelease, String distributor) {
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (other == null) {
@Override
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (other == null) {
return false;
}
if (!(other instanceof Movie)) {
return false;
}
Movie movie = (Movie) other;
if (movie.name.equals(this.name) && movie.yearOfRelease.equals(this.yearOfRelease)) {
return true;
}
return false;
}
Movie movie = (Movie) other;
if (movie.name.equals(this.name) && movie.yearOfRelease.equals(this.yearOfRelease)) {
return true;
}
return false;
}
@Override
public int hashCode() {