Skip to content

Commit 894b1ab

Browse files
cmagliefacchinm
authored andcommitted
Improved lib equality check
1 parent 2ec8c53 commit 894b1ab

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

arduino-core/src/cc/arduino/contributions/libraries/ContributedLibrary.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public boolean equals(Object obj) {
166166
String thisVersion = getParsedVersion();
167167
String otherVersion = other.getParsedVersion();
168168

169-
boolean versionEquals = (thisVersion != null && otherVersion != null
169+
boolean versionEquals = (thisVersion != null
170170
&& thisVersion.equals(otherVersion));
171171

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

177177
String thisName = getName();
178178
String otherName = other.getName();
179-
180-
boolean nameEquals = thisName == null || otherName == null || thisName.equals(otherName);
179+
boolean nameEquals = thisName != null && thisName.equals(otherName);
181180

182181
return versionEquals && nameEquals;
183182
}
183+
184+
@Override
185+
public int hashCode() {
186+
String hashingData = "CONTRIBUTEDLIB" + getName() + getVersion();
187+
return hashingData.hashCode();
188+
}
184189
}

0 commit comments

Comments
 (0)