|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.tum.cs.commons.version.Version
public class Version
A class to describe versions of software (or other) artifacts. A version has a major and a minor version number. Version are ordered. This class is immutable.
Constructor Summary | |
---|---|
Version(int major,
int minor)
Create a new version. |
Method Summary | |
---|---|
int |
compareTo(Version other)
Compares to version numbers by their major and minor numbers. |
boolean |
equals(java.lang.Object other)
Two version are equal if their major and minor version numbers are equal. |
int |
getMajor()
Get major version number. |
int |
getMinor()
Get minor version number. |
int |
hashCode()
Hashcode is (major << 7) | minor; |
boolean |
isSatisfied(Version currentVersion,
Version compatibleVersion)
This method is used to check version compatibility in dependency management. |
static Version |
parseVersion(java.lang.String s)
Parses a version from a string. |
java.lang.String |
toString()
String representation: major.minor |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public Version(int major, int minor)
major
- major version number.minor
- minor version number.
java.lang.IllegalArgumentException
- if one of the version numbers is less than 0.Method Detail |
---|
public static Version parseVersion(java.lang.String s) throws FormatException
FormatException
- if the string does not follow the expected pattern.public int compareTo(Version other)
compareTo
in interface java.lang.Comparable<Version>
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
public int getMajor()
public int getMinor()
public int hashCode()
hashCode
in class java.lang.Object
public boolean isSatisfied(Version currentVersion, Version compatibleVersion)
Consider the following situation and artefact A (the depender) depends on another artefact B (the dependee). A claims that it requires B in version 1.3. B states that it has version 1.5 but is downward compatible to version 1.1.
Using this method one can find out if the version provided by B satisfies A's requirement. It is satisfied iff
requiredVersion <= currentVersion && requiredVersion >= compatibleVersionwhere
requiredVersion
is this instance and the other two
are provided as method parameters.
java.lang.IllegalArgumentException
- if compatibleVersion
is greater than
currentVersion
.public java.lang.String toString()
toString
in class java.lang.Object
|
TUM CCSM Commons | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |