public class Version extends Object implements CharSequence, Comparable<Version>, Serializable
"6.11.2"
will have major number 6, minor
number 11 and revision number 2. Alternatively a version code such as "3.18-SNAPSHOT"
will have major version number 3, minor version number 18 and revision string "SNAPSHOT".
This class provides methods for performing comparisons of Version
objects where major,
minor and revision parts are compared as numbers when possible, or as strings otherwise.
Defined in the sis-utility
module
Modifier and Type | Field and Description |
---|---|
static Version |
SIS
The version of this Apache SIS distribution.
|
Constructor and Description |
---|
Version(String version)
Creates a new version object from the supplied string.
|
Modifier and Type | Method and Description |
---|---|
char |
charAt(int index)
Returns the
char value at the specified index. |
int |
compareTo(Version other)
Compares this version with an other version object.
|
int |
compareTo(Version other,
int limit)
Compares this version with an other version object, up to the specified limit.
|
boolean |
equals(Object other)
Compare this version string with the specified object for equality.
|
Comparable<?> |
getMajor()
Returns the major version number.
|
Comparable<?> |
getMinor()
Returns the minor version number.
|
Comparable<?> |
getRevision()
Returns the revision number.
|
int |
hashCode()
Returns a hash code value for this version.
|
int |
length()
Returns the length of the version string.
|
CharSequence |
subSequence(int start,
int end)
Returns a new version string that is a subsequence of this sequence.
|
String |
toString()
Returns the version string.
|
static Version |
valueOf(int... components)
Returns an instance for the given integer values.
|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
chars, codePoints
public static final Version SIS
public Version(String version)
version
- the version as a string.public static Version valueOf(int... components)
components
array must contain at least 1 element, where:
string value
.components
- the major number, optionally followed by minor, revision or other numbers.Version
for the given numbers.public Comparable<?> getMajor()
Integer
if possible,
or a String
otherwise.public Comparable<?> getMinor()
Integer
if possible,
or a String
otherwise. If there is no minor version number, then this method
returns null
.null
if none.public Comparable<?> getRevision()
Integer
if possible,
or a String
otherwise. If there is no revision number, then this method
returns null
.null
if none.public int compareTo(Version other, int limit)
Integer
object if possible, or as String
otherwise.other
- the other version object to compare with.limit
- the maximum number of components to compare.public int compareTo(Version other)
compareTo(Version, int)
with no limit.compareTo
in interface Comparable<Version>
other
- the other version object to compare with.public boolean equals(Object other)
compareTo(other) == 0
.public int length()
length
in interface CharSequence
public char charAt(int index)
char
value at the specified index.charAt
in interface CharSequence
public CharSequence subSequence(int start, int end)
subSequence
in interface CharSequence
public String toString()
toString
in interface CharSequence
toString
in class Object
Copyright © 2010–2017 The Apache Software Foundation. All rights reserved.