Package org.nuiton.version
Class Versions
- java.lang.Object
-
- org.nuiton.version.Versions
-
-
Constructor Summary
Constructors Constructor Description Versions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Version
addSnapshot(Version version)
Create a version from the given one and set to it thesnapshot
state totrue
.static Version
decrements(Version version, int componantPosition)
Creates a new version from this one with the number componant decremented at the given position.static boolean
equals(String version0, String version1)
Tests if two versions are equals.static Version
extractVersion(Version version, int component)
Create a new version containing a single component from a given version.static Version
extractVersion(Version version, int firstComponent, int lastComponent)
Create a new version containing a sub set of component from a given version.static boolean
greaterThan(String version0, String version1)
Tests if the first version is greater than the second version.static Version
increments(Version version)
Creates a new version from this one incremented.static Version
increments(Version version, char componantSeperator)
Creates a new version from this one incremented.static Version
increments(Version version, int componantPosition)
Creates a new version from this one with the number componant incremented at the given position.static Version
removeSnapshot(Version version)
Create a version from the given one and set to it thesnapshot
state tofalse
.static boolean
smallerThan(String version0, String version1)
Tests if the first version is smaller than the second version.static Version
valueOf(String version)
Shortcut method to get a version from his string representation.
-
-
-
Method Detail
-
valueOf
public static Version valueOf(String version)
Shortcut method to get a version from his string representation.- Parameters:
version
- string representation of the version- Returns:
- converted version from the string representation
-
equals
public static boolean equals(String version0, String version1)
Tests if two versions are equals.- Parameters:
version0
- the first versionversion1
- the second version- Returns:
true
if versions are equals,false
otherwise.
-
smallerThan
public static boolean smallerThan(String version0, String version1)
Tests if the first version is smaller than the second version.- Parameters:
version0
- the first versionversion1
- the second version- Returns:
true
ifversion0
is beforeversion1
,false
otherwise.
-
greaterThan
public static boolean greaterThan(String version0, String version1)
Tests if the first version is greater than the second version.- Parameters:
version0
- the first versionversion1
- the second version- Returns:
true
ifversion0
is afterversion1
,false
otherwise.
-
addSnapshot
public static Version addSnapshot(Version version)
Create a version from the given one and set to it thesnapshot
state totrue
.- Parameters:
version
- version to clone- Returns:
- the cloned version with the
snapshot
state totrue
- Throws:
IllegalArgumentException
- ifsnapshot
state is already set totrue
on the givenversion
.
-
removeSnapshot
public static Version removeSnapshot(Version version)
Create a version from the given one and set to it thesnapshot
state tofalse
.- Parameters:
version
- version to clone- Returns:
- the cloned version with the
snapshot
state totrue
- Throws:
IllegalArgumentException
- ifsnapshot
state is already set tofalse
on the givenversion
-
extractVersion
public static Version extractVersion(Version version, int component)
Create a new version containing a single component from a given version.- Parameters:
version
- original versioncomponent
- component index to extract- Returns:
- new
Version
with a single component
-
extractVersion
public static Version extractVersion(Version version, int firstComponent, int lastComponent)
Create a new version containing a sub set of component from a given version.- Parameters:
version
- original versionfirstComponent
- first component indexlastComponent
- last component index- Returns:
- new
Version
with a components sub set
-
increments
public static Version increments(Version version)
Creates a new version from this one incremented.If the last componant is a number, then just increments this number; otherwise add a new number componant with value 1.
Example:
- 1 → 2
- 1-a → 1-a.1
- Parameters:
version
- FIXME- Returns:
- the incremented version
-
increments
public static Version increments(Version version, char componantSeperator)
Creates a new version from this one incremented.If the last componant is a number, then just increments this number; otherwise add a new number componant with value 1.
Example:
- 1 → 2
- 1-a → 1-a.1
- Parameters:
version
- FIXMEcomponantSeperator
- the componant separator to use the last componant is a classifier- Returns:
- the incremented version
-
increments
public static Version increments(Version version, int componantPosition)
Creates a new version from this one with the number componant incremented at the given position.Note: Will fail if the componant at the required position is not a number.
- Parameters:
version
- FIXMEcomponantPosition
- position of the version componant to increment- Returns:
- the incremented version
-
decrements
public static Version decrements(Version version, int componantPosition)
Creates a new version from this one with the number componant decremented at the given position.Note: Will fail if the componant at the required position is not a number, or his value is 0.
- Parameters:
version
- FIXMEcomponantPosition
- position of the version componant to increment- Returns:
- the decremented version
-
-