mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-26 19:11:29 +01:00
Extracted magic numbers in hashCode() to named constants.
Former-commit-id: e023cdf8583859215243244227bdc576b4df75f4
This commit is contained in:
@@ -48,6 +48,14 @@ public class Dependency implements Serializable, Comparable<Dependency> {
|
|||||||
* The logger.
|
* The logger.
|
||||||
*/
|
*/
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(Dependency.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(Dependency.class);
|
||||||
|
/**
|
||||||
|
* Used as starting point for generating the value in {@link #hashCode()}.
|
||||||
|
*/
|
||||||
|
private static final int MAGIC_HASH_INIT_VALUE = 3;
|
||||||
|
/**
|
||||||
|
* Used as a multiplier for generating the value in {@link #hashCode()}.
|
||||||
|
*/
|
||||||
|
private static final int MAGIC_HASH_MULTIPLIER = 47;
|
||||||
/**
|
/**
|
||||||
* The actual file path of the dependency on disk.
|
* The actual file path of the dependency on disk.
|
||||||
*/
|
*/
|
||||||
@@ -752,12 +760,12 @@ public class Dependency implements Serializable, Comparable<Dependency> {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int hash = 3;
|
int hash = MAGIC_HASH_INIT_VALUE;
|
||||||
for (Object field : new Object[]{this.actualFilePath, this.filePath, this.fileName, this.fileExtension, this.md5sum,
|
for (Object field : new Object[]{this.actualFilePath, this.filePath, this.fileName, this.fileExtension, this.md5sum,
|
||||||
this.sha1sum, this.identifiers, this.vendorEvidence, this.productEvidence, this.versionEvidence,
|
this.sha1sum, this.identifiers, this.vendorEvidence, this.productEvidence, this.versionEvidence,
|
||||||
this.description, this.license, this.vulnerabilities, this.relatedDependencies, this.projectReferences,
|
this.description, this.license, this.vulnerabilities, this.relatedDependencies, this.projectReferences,
|
||||||
this.availableVersions}) {
|
this.availableVersions}) {
|
||||||
hash = 47 * hash + ObjectUtils.hashCode(field);
|
hash = MAGIC_HASH_MULTIPLIER * hash + ObjectUtils.hashCode(field);
|
||||||
}
|
}
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user