Skip to content

Commit 3cd0ad1

Browse files
cmagliefacchinm
authored andcommitted
Improved lib equality check
1 parent 2ac9d0b commit 3cd0ad1

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public boolean equals(Object obj) {
137137
String thisVersion = getParsedVersion();
138138
String otherVersion = other.getParsedVersion();
139139

140-
boolean versionEquals = (thisVersion != null && otherVersion != null
140+
boolean versionEquals = (thisVersion != null
141141
&& thisVersion.equals(otherVersion));
142142

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

148148
String thisName = getName();
149149
String otherName = other.getName();
150-
151-
boolean nameEquals = thisName == null || otherName == null || thisName.equals(otherName);
150+
boolean nameEquals = thisName != null && thisName.equals(otherName);
152151

153152
return versionEquals && nameEquals;
154153
}
154+
155+
@Override
156+
public int hashCode() {
157+
String hashingData = "CONTRIBUTEDLIB" + getName() + getVersion();
158+
return hashingData.hashCode();
159+
}
155160
}

0 commit comments

Comments
 (0)