Skip to content

Commit

Permalink
Took care of equal() and hashCode() (#127)
Browse files Browse the repository at this point in the history
  • Loading branch information
climategadgets committed May 18, 2021
1 parent 334d1c7 commit 7468c9c
Showing 1 changed file with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1765,14 +1765,12 @@ private int arrayReadBit(int index, byte[] buf) {
*/
@Override
public boolean equals(Object o) {
return (o instanceof DSPortAdapter) && (this == o || toString().equals(o.toString()));
}

if (o != null && o instanceof DSPortAdapter) {
if (o == this || o.toString().equals(this.toString())) {
return true;
}
}

return false;
@Override
public int hashCode() {
return toString().hashCode();
}

/**
Expand All @@ -1787,7 +1785,7 @@ public String toString() {
try {
return this.getAdapterName() + " " + this.getPortName();
} catch (OneWireException owe) {
return this.getAdapterName() + " Unknown Port";
return this.getAdapterName() + " Unknown Port (" + owe.getMessage() + ")";
}
}
}

0 comments on commit 7468c9c

Please sign in to comment.