Class LibraryVersion
java.lang.Object
i5.las2peer.classLoaders.libraries.LibraryVersion
public class LibraryVersion
extends java.lang.Object
a simple class managing a library version number in the format major.minor.subversion-build where minor, subversion
and build are optional
-
Constructor Summary
Constructors Constructor Description LibraryVersion(int major)
generate a new LibraryVersionLibraryVersion(int major, int minor)
generate a new LibraryVersionLibraryVersion(int major, int minor, int sub)
generate a new LibraryVersionLibraryVersion(int major, int minor, int sub, int build)
generate a new LibraryVersionLibraryVersion(java.lang.String version)
Generate a Version from String representation format : major.minor.sub-build minor, subversion and build are optional -
Method Summary
Modifier and Type Method Description boolean
equals(LibraryVersion v)
compares to version and checks for equalityboolean
equals(java.lang.Object o)
compares this version with any object if the given object is a String, the string representation of this version is compared to the given stringint
getBuild()
get the build number of this (sub)versionint
getMajor()
get the major version numberint
getMinor()
get the minor version numberint
getSub()
get the subversion of the minor version numberint
hashCode()
since equals is overridden, we should implement an own hashCode.java.lang.String
toString()
-
Constructor Details
-
LibraryVersion
public LibraryVersion(java.lang.String version) throws java.lang.IllegalArgumentExceptionGenerate a Version from String representation format : major.minor.sub-build minor, subversion and build are optional- Parameters:
version
- A version string representation- Throws:
java.lang.IllegalArgumentException
- If the string contains no valid version representation
-
LibraryVersion
public LibraryVersion(int major, int minor, int sub, int build) throws java.lang.IllegalArgumentExceptiongenerate a new LibraryVersion- Parameters:
major
- Major version number partminor
- Minor version number partsub
- Sub version number partbuild
- Build number- Throws:
java.lang.IllegalArgumentException
- If a version number part is smaller than 0
-
LibraryVersion
public LibraryVersion(int major, int minor, int sub) throws java.lang.IllegalArgumentExceptiongenerate a new LibraryVersion- Parameters:
major
- Major version number partminor
- Minor version number partsub
- Sub version number part- Throws:
java.lang.IllegalArgumentException
- If a version number part is smaller than 0
-
LibraryVersion
public LibraryVersion(int major, int minor) throws java.lang.IllegalArgumentExceptiongenerate a new LibraryVersion- Parameters:
major
- Major version number partminor
- Minor version number part- Throws:
java.lang.IllegalArgumentException
- If a version number part is smaller than 0
-
LibraryVersion
public LibraryVersion(int major) throws java.lang.IllegalArgumentExceptiongenerate a new LibraryVersion- Parameters:
major
- Major version number part- Throws:
java.lang.IllegalArgumentException
- If a version number part is smaller than 0
-
-
Method Details
-
equals
compares to version and checks for equality- Parameters:
v
- Another library version to check- Returns:
- true, if this version is the same as the given one
-
equals
public boolean equals(java.lang.Object o)compares this version with any object if the given object is a String, the string representation of this version is compared to the given string- Overrides:
equals
in classjava.lang.Object
- Parameters:
o
- Another version string to check- Returns:
- true, if the given object is a version and the same as this one
-
hashCode
public int hashCode()since equals is overridden, we should implement an own hashCode.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- a hash code as int
-
getMinor
public int getMinor()get the minor version number- Returns:
- minor version number
-
getMajor
public int getMajor()get the major version number- Returns:
- major version number
-
getSub
public int getSub()get the subversion of the minor version number- Returns:
- suberverion number of minor
-
getBuild
public int getBuild()get the build number of this (sub)version- Returns:
- build number
-
toString
public java.lang.String toString()- Overrides:
toString
in classjava.lang.Object
- Returns:
- a String representation of this version
-