Remove equals and hashCode from computer details

This commit is contained in:
Cameron Gutman 2014-11-17 19:00:07 -08:00
parent c0e95ea18b
commit c2cdb1264d

View File

@ -22,6 +22,17 @@ public class ComputerDetails {
public String macAddress; public String macAddress;
public int runningGameId; public int runningGameId;
public ComputerDetails() {
// Use defaults
state = State.UNKNOWN;
reachability = Reachability.UNKNOWN;
}
public ComputerDetails(ComputerDetails details) {
// Copy details from the other computer
update(details);
}
public void update(ComputerDetails details) { public void update(ComputerDetails details) {
this.state = details.state; this.state = details.state;
this.reachability = details.reachability; this.reachability = details.reachability;
@ -34,29 +45,6 @@ public class ComputerDetails {
this.runningGameId = details.runningGameId; this.runningGameId = details.runningGameId;
} }
@Override
public boolean equals(Object o) {
if (o instanceof ComputerDetails) {
ComputerDetails other = (ComputerDetails)o;
// Use UUIDs if they both have them
if (other.uuid != null && this.uuid != null)
{
return other.uuid.equals(this.uuid);
}
// Otherwise use local IP
return other.localIp.equals(this.localIp);
}
return false;
}
@Override
public int hashCode() {
return localIp.hashCode();
}
@Override @Override
public String toString() { public String toString() {
StringBuilder str = new StringBuilder(); StringBuilder str = new StringBuilder();