Class DependencyVersion
java.lang.Object
org.owasp.dependencycheck.utils.DependencyVersion
- All Implemented Interfaces:
Comparable<DependencyVersion>, Iterable<String>
@NotThreadSafe
public class DependencyVersion
extends Object
implements Iterable<String>, Comparable<DependencyVersion>
Simple object to track the parts of a version number. The parts are contained
in a List such that version 1.2.3 will be stored as: versionParts[0] = 1;
versionParts[1] = 2;
versionParts[2] = 3;
Note, the parser contained in this class expects the version numbers to be separated by periods. If a different separator is used the parser will likely fail.
- Author:
- Jeremy Long
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor for a empty DependencyVersion.DependencyVersion(String version) Constructor for a DependencyVersion that will parse a version string. -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(@NonNull DependencyVersion version) booleanCompares the equality of this object to the one passed in as a parameter.Get the value of versionParts.inthashCode()Calculates the hashCode for this object.iterator()Retrieves an iterator for the version parts.booleanDetermines if the three most major major version parts are identical.final voidparseVersion(String version) Parses a version string into its sub parts: major, minor, revision, build, etc.voidsetVersionParts(List<String> versionParts) Set the value of versionParts.toString()Reconstructs the version string from the split version parts.Methods inherited from interface Iterable
forEach, spliterator
-
Constructor Details
-
DependencyVersion
public DependencyVersion()Constructor for a empty DependencyVersion. -
DependencyVersion
Constructor for a DependencyVersion that will parse a version string. Note, this should only be used when the version passed in is already known to be a well formatted version number. Otherwise, DependencyVersionUtil.parseVersion() should be used instead.- Parameters:
version- the well formatted version number to parse
-
-
Method Details
-
parseVersion
Parses a version string into its sub parts: major, minor, revision, build, etc. Note, this should only be used to parse something that is already known to be a version number.- Parameters:
version- the version string to parse
-
getVersionParts
-
setVersionParts
-
iterator
-
toString
-
equals
-
hashCode
-
matchesAtLeastThreeLevels
Determines if the three most major major version parts are identical. For instances, if version 1.2.3.4 was compared to 1.2.3 this function would return true.- Parameters:
version- the version number to compare- Returns:
- true if the first three major parts of the version are identical
-
compareTo
- Specified by:
compareToin interfaceComparable<DependencyVersion>
-