Fixed hash and equals collisions

This commit is contained in:
Andrey Terentev 2024-03-14 23:58:06 +07:00 committed by Andrey Terentev
parent 4817e5e395
commit cad8f59d30
2 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,8 @@ import ru.dragonestia.picker.api.model.room.RoomDetails;
import ru.dragonestia.picker.api.model.room.ShortResponseRoom;
import ru.dragonestia.picker.api.repository.type.RoomIdentifier;
import java.util.Objects;
public class Room implements IRoom {
private final String identifier;
@ -80,7 +82,7 @@ public class Room implements IRoom {
@Override
public int hashCode() {
return identifier.hashCode();
return Objects.hash(identifier, nodeIdentifier);
}
@Override
@ -88,7 +90,7 @@ public class Room implements IRoom {
if (object == this) return true;
if (object == null) return false;
if (object instanceof Room other) {
return identifier.equals(other.identifier);
return identifier.equals(other.identifier) && nodeIdentifier.equals(other.nodeIdentifier);
}
return false;
}

View File

@ -29,6 +29,11 @@ public class User implements IUser {
return new ResponseUser(identifier);
}
@Override
public String toString() {
return identifier;
}
@Override
public int hashCode() {
return identifier.hashCode();