mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-01-13 23:33:37 +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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@@ -752,12 +760,12 @@ public class Dependency implements Serializable, Comparable<Dependency> {
|
||||
*/
|
||||
@Override
|
||||
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,
|
||||
this.sha1sum, this.identifiers, this.vendorEvidence, this.productEvidence, this.versionEvidence,
|
||||
this.description, this.license, this.vulnerabilities, this.relatedDependencies, this.projectReferences,
|
||||
this.availableVersions}) {
|
||||
hash = 47 * hash + ObjectUtils.hashCode(field);
|
||||
hash = MAGIC_HASH_MULTIPLIER * hash + ObjectUtils.hashCode(field);
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user