Package org.onosproject.core
Class Version
- java.lang.Object
-
- org.onosproject.core.Version
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
FORMAT_LONG
static java.lang.String
FORMAT_MINIMAL
static java.lang.String
FORMAT_SHORT
static java.lang.String
TOO_SHORT
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
build()
Returns the version build string.int
compareTo(Version other)
boolean
equals(java.lang.Object obj)
static Version
fromInt(int version)
Returns an version from integer.int
hashCode()
int
major()
Returns the major version number.int
minor()
Returns the minor version number.java.lang.String
patch()
Returns the version patch segment.int
toInt()
Returns an integer representation of the version.java.lang.String
toString()
static Version
version(int major, int minor, java.lang.String patch, java.lang.String build)
Creates a new version from the specified constituent numbers.static Version
version(java.lang.String string)
Creates a new version by parsing the specified string.
-
-
-
Field Detail
-
FORMAT_MINIMAL
public static final java.lang.String FORMAT_MINIMAL
- See Also:
- Constant Field Values
-
FORMAT_SHORT
public static final java.lang.String FORMAT_SHORT
- See Also:
- Constant Field Values
-
FORMAT_LONG
public static final java.lang.String FORMAT_LONG
- See Also:
- Constant Field Values
-
TOO_SHORT
public static final java.lang.String TOO_SHORT
- See Also:
- Constant Field Values
-
-
Method Detail
-
version
public static Version version(int major, int minor, java.lang.String patch, java.lang.String build)
Creates a new version from the specified constituent numbers.- Parameters:
major
- major version numberminor
- minor version numberpatch
- version patch segmentbuild
- optional build string- Returns:
- version descriptor
-
version
public static Version version(java.lang.String string)
Creates a new version by parsing the specified string.- Parameters:
string
- version string- Returns:
- version descriptor
-
fromInt
public static Version fromInt(int version)
Returns an version from integer.The version integer must be in the following format (big endian):
- 8-bit unsigned major version
- 8-bit unsigned minor version
- 16-bit unsigned patch version
- Parameters:
version
- the version integer- Returns:
- the version instance
-
major
public int major()
Returns the major version number.- Returns:
- major version number
-
minor
public int minor()
Returns the minor version number.- Returns:
- minor version number
-
patch
public java.lang.String patch()
Returns the version patch segment.- Returns:
- patch number
-
build
public java.lang.String build()
Returns the version build string.- Returns:
- build string
-
toInt
public int toInt()
Returns an integer representation of the version.The version integer can be used to compare two versions to one another. The integer representation of the version number is in the following format (big endian):
- 8-bit unsigned major version
- 8-bit unsigned minor version
- 16-bit unsigned patch version
patch()
is not a number, it will default to0
.- Returns:
- an integer representation of the version
-
compareTo
public int compareTo(Version other)
- Specified by:
compareTo
in interfacejava.lang.Comparable<Version>
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
-