Package i5.las2peer.api.p2p
Class ServiceVersion
java.lang.Object
i5.las2peer.api.SemverVersion
i5.las2peer.api.p2p.ServiceVersion
- All Implemented Interfaces:
Serializable
,Comparable<ServiceVersion>
A simple class managing a service version number in the format
<major> "." <minor> "." <patch> "-" <pre-release> "+" <build>
(where minor, patch, pre-release and build
are optional) or "*" (no version specified / matches all versions).- See Also:
-
Field Summary
Fields inherited from class i5.las2peer.api.SemverVersion
build, major, minor, patch, preRelease
-
Constructor Summary
ConstructorDescriptionServiceVersion
(int major) generate a new ServiceVersionServiceVersion
(int major, int minor) generate a new ServiceVersionServiceVersion
(int major, int minor, int patch) generate a new ServiceVersionServiceVersion
(int major, int minor, int patch, String preRelease) generate a new ServiceVersionServiceVersion
(int major, int minor, int patch, String preRelease, String build) generate a new ServiceVersionServiceVersion
(String version) Generate a Version from String representation format : Semver<major> "." <minor> "." <patch> "-" <pre-release> "+" <build>
(where minor, patch, pre-release and build are optional) or "*" (no version specified / matches all versions) -
Method Summary
Modifier and TypeMethodDescriptionchooseFittingVersion
(ServiceVersion[] available) returns the newest ServiceVersion from all available ServiceVersions that fits this versionint
compareTo
(ServiceVersion other) implementation of Comparableboolean
fits
(ServiceVersion required) checks if this version "fits" to the required version e.g.boolean
isBetween
(ServiceVersion smaller, ServiceVersion larger) check if this version is between the given onesboolean
tries to create a version number from the given strings and compares them to this versionboolean
check if this version is larger than or equal to the given oneboolean
check if this version is larger than the given oneboolean
check if this version is smaller than or equal to the given oneboolean
check if this version is smaller than the given one
-
Constructor Details
-
ServiceVersion
Generate a Version from String representation format : Semver<major> "." <minor> "." <patch> "-" <pre-release> "+" <build>
(where minor, patch, pre-release and build are optional) or "*" (no version specified / matches all versions)- Parameters:
version
- A version string representation to parse- Throws:
IllegalArgumentException
- If the string contains no valid version representation
-
ServiceVersion
public ServiceVersion(int major, int minor, int patch, String preRelease, String build) throws IllegalArgumentException generate a new ServiceVersion- Parameters:
major
- Major version number partminor
- Minor version number partpatch
- Patch version number partpreRelease
- pre-release versionbuild
- build version- Throws:
IllegalArgumentException
- If a version number part is smaller than 0
-
ServiceVersion
public ServiceVersion(int major, int minor, int patch, String preRelease) throws IllegalArgumentException generate a new ServiceVersion- Parameters:
major
- Major version number partminor
- Minor version number partpatch
- Patch version number partpreRelease
- pre-release version- Throws:
IllegalArgumentException
- If a version number part is smaller than 0
-
ServiceVersion
generate a new ServiceVersion- Parameters:
major
- Major version number partminor
- Minor version number partpatch
- Patch version number part- Throws:
IllegalArgumentException
- If a version number part is smaller than 0
-
ServiceVersion
generate a new ServiceVersion- Parameters:
major
- Major version number partminor
- Minor version number part- Throws:
IllegalArgumentException
- If a version number part is smaller than 0
-
ServiceVersion
generate a new ServiceVersion- Parameters:
major
- Major version number part- Throws:
IllegalArgumentException
- If a version number part is smaller than 0
-
-
Method Details
-
isLargerThan
check if this version is larger than the given one- Parameters:
v
- Another service version to compare to- Returns:
- true, if this version is larger than the given one
-
isSmallerThan
check if this version is smaller than the given one- Parameters:
v
- Another service version to compare to- Returns:
- true, if this version is smaller than the given one
-
isLargerOrEqual
check if this version is larger than or equal to the given one- Parameters:
v
- Another service version to compare to- Returns:
- true, if this version is larger than or equal to the given one
-
isSmallerOrEqual
check if this version is smaller than or equal to the given one- Parameters:
v
- Another service version to compare to- Returns:
- true, if this version is smaller than or equal to the given one
-
isBetween
check if this version is between the given ones- Parameters:
smaller
- A smaller service version to check forlarger
- A larger service version to check for- Returns:
- true, if this version is between the two given ones
-
isBetween
tries to create a version number from the given strings and compares them to this version- Parameters:
smaller
- A smaller service version to check forlarger
- A larger service version to check for- Returns:
- true, if this version is between the two given ones
-
compareTo
implementation of Comparable- Specified by:
compareTo
in interfaceComparable<ServiceVersion>
- Parameters:
other
- Another service version to check- Returns:
- comparison code
-
fits
checks if this version "fits" to the required version e.g. "1.5.2-123" will fit "1.5", but "1.5" won't fit "1.6" or "1.5.2"- Parameters:
required
- A required service version to check for- Returns:
- Returns true if this version fits the required version
-
chooseFittingVersion
returns the newest ServiceVersion from all available ServiceVersions that fits this version- Parameters:
available
- available versions- Returns:
- a fitting ServiceVersion or null if no fitting version exists
-