Skip to content

Commit

Permalink
Improved lib equality check
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie authored and facchinm committed Jul 18, 2019
1 parent 2ec8c53 commit 894b1ab
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public boolean equals(Object obj) {
String thisVersion = getParsedVersion();
String otherVersion = other.getParsedVersion();

boolean versionEquals = (thisVersion != null && otherVersion != null
boolean versionEquals = (thisVersion != null
&& thisVersion.equals(otherVersion));

// Important: for legacy libs, versions are null. Two legacy libs must
Expand All @@ -176,9 +176,14 @@ public boolean equals(Object obj) {

String thisName = getName();
String otherName = other.getName();

boolean nameEquals = thisName == null || otherName == null || thisName.equals(otherName);
boolean nameEquals = thisName != null && thisName.equals(otherName);

return versionEquals && nameEquals;
}

@Override
public int hashCode() {
String hashingData = "CONTRIBUTEDLIB" + getName() + getVersion();
return hashingData.hashCode();
}
}

0 comments on commit 894b1ab

Please sign in to comment.