Fixed hashCode and equals collisions
This commit is contained in:
parent
c42dc60af1
commit
0d3e1df6e5
@ -10,6 +10,7 @@ import ru.dragonestia.picker.api.repository.type.RoomPath;
|
|||||||
import java.beans.Transient;
|
import java.beans.Transient;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Schema(title = "Room")
|
@Schema(title = "Room")
|
||||||
public class ResponseRoom implements IRoom {
|
public class ResponseRoom implements IRoom {
|
||||||
@ -116,7 +117,7 @@ public class ResponseRoom implements IRoom {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return id.hashCode();
|
return Objects.hash(id, nodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -124,7 +125,7 @@ public class ResponseRoom implements IRoom {
|
|||||||
if (object == this) return true;
|
if (object == this) return true;
|
||||||
if (object == null) return false;
|
if (object == null) return false;
|
||||||
if (object instanceof ResponseRoom other) {
|
if (object instanceof ResponseRoom other) {
|
||||||
return id.equals(other.id);
|
return id.equals(other.id) && nodeId.equals(other.nodeId);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -9,6 +9,7 @@ import ru.dragonestia.picker.api.repository.type.RoomPath;
|
|||||||
import java.beans.Transient;
|
import java.beans.Transient;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Schema(title = "Room (Short)")
|
@Schema(title = "Room (Short)")
|
||||||
public class ShortResponseRoom implements IRoom {
|
public class ShortResponseRoom implements IRoom {
|
||||||
@ -92,7 +93,7 @@ public class ShortResponseRoom implements IRoom {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return id.hashCode();
|
return Objects.hash(id, nodeId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -100,7 +101,7 @@ public class ShortResponseRoom implements IRoom {
|
|||||||
if (object == this) return true;
|
if (object == this) return true;
|
||||||
if (object == null) return false;
|
if (object == null) return false;
|
||||||
if (object instanceof ShortResponseRoom other) {
|
if (object instanceof ShortResponseRoom other) {
|
||||||
return id.equals(other.id);
|
return id.equals(other.id) && nodeId.equals(other.nodeId);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user