mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-22 00:59:34 +01:00
added equals and hashCode
Former-commit-id: e7091b8f28f1a24d761729fe213b6208fe2ee03b
This commit is contained in:
@@ -111,4 +111,35 @@ public class DependencyVersion implements Iterable {
|
|||||||
public String toString() {
|
public String toString() {
|
||||||
return StringUtils.join(versionParts.toArray(), ".");
|
return StringUtils.join(versionParts.toArray(), ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compares the equality of this object to the one passed in as a parameter.
|
||||||
|
* @param obj the object to compare equality
|
||||||
|
* @return returns true only if the two objects are equal, otherwise false
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object obj) {
|
||||||
|
if (obj == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (getClass() != obj.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final DependencyVersion other = (DependencyVersion) obj;
|
||||||
|
if (this.versionParts != other.versionParts && (this.versionParts == null || !this.versionParts.equals(other.versionParts))) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Calculates the hashCode for this object.
|
||||||
|
* @return the hashCode
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hash = 5;
|
||||||
|
hash = 71 * hash + (this.versionParts != null ? this.versionParts.hashCode() : 0);
|
||||||
|
return hash;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user