@NotThreadSafe public class DependencyVersion extends java.lang.Object implements java.lang.Iterable<java.lang.String>, java.lang.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.
Constructor and Description |
---|
DependencyVersion()
Constructor for a empty DependencyVersion.
|
DependencyVersion(java.lang.String version)
Constructor for a DependencyVersion that will parse a version string.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(@NotNull DependencyVersion version) |
boolean |
equals(java.lang.Object obj)
Compares the equality of this object to the one passed in as a parameter.
|
java.util.List<java.lang.String> |
getVersionParts()
Get the value of versionParts.
|
int |
hashCode()
Calculates the hashCode for this object.
|
@NotNull java.util.Iterator<java.lang.String> |
iterator()
Retrieves an iterator for the version parts.
|
boolean |
matchesAtLeastThreeLevels(DependencyVersion version)
Determines if the three most major major version parts are identical.
|
void |
parseVersion(java.lang.String version)
Parses a version string into its sub parts: major, minor, revision,
build, etc.
|
void |
setVersionParts(java.util.List<java.lang.String> versionParts)
Set the value of versionParts.
|
java.lang.String |
toString()
Reconstructs the version string from the split version parts.
|
public DependencyVersion()
public DependencyVersion(java.lang.String version)
version
- the well formatted version number to parsepublic final void parseVersion(java.lang.String version)
version
- the version string to parsepublic java.util.List<java.lang.String> getVersionParts()
public void setVersionParts(java.util.List<java.lang.String> versionParts)
versionParts
- new value of versionParts@NotNull public @NotNull java.util.Iterator<java.lang.String> iterator()
iterator
in interface java.lang.Iterable<java.lang.String>
public java.lang.String toString()
toString
in class java.lang.Object
public boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
obj
- the object to compare equalitypublic int hashCode()
hashCode
in class java.lang.Object
public boolean matchesAtLeastThreeLevels(DependencyVersion version)
version
- the version number to comparepublic int compareTo(@NotNull @NotNull DependencyVersion version)
compareTo
in interface java.lang.Comparable<DependencyVersion>
Copyright© 2012-21 Jeremy Long. All Rights Reserved.