Skip to content

Commit b652ec5

Browse files
fix: value object must have equals defined on their data
1 parent 1adf998 commit b652ec5

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/env/entity/room/RoomID.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
package entity.room;
1010

11+
import java.util.Objects;
12+
1113
/**
1214
* Room identifier.
1315
*/
@@ -29,4 +31,21 @@ public RoomID(final String id) {
2931
public String getId() {
3032
return this.id;
3133
}
34+
35+
@Override
36+
public final boolean equals(final Object other) {
37+
if (this == other) {
38+
return true;
39+
}
40+
if (other == null || this.getClass() != other.getClass()) {
41+
return false;
42+
}
43+
final RoomID that = (RoomID) other;
44+
return this.getId().equals(that.getId());
45+
}
46+
47+
@Override
48+
public final int hashCode() {
49+
return Objects.hash(this.getId());
50+
}
3251
}

0 commit comments

Comments
 (0)