public class Version extends Object implements Comparable<Version>
("." number)*.| Modifier and Type | Field and Description |
|---|---|
private static Pattern |
PATTERN |
private int[] |
segments |
private static String |
SEPARATOR |
| Constructor and Description |
|---|
Version(int... version)
Version created from version segments.
|
Version(String version)
Creates a new version by parsing a string.
|
| Modifier and Type | Method and Description |
|---|---|
static int |
compare(Version version1,
Version version2)
Compares two versions considering null for both parameters and results in:
-1 : this is smaller <=> given version and this is bigger.
|
int |
compareTo(Version version)
Compares two versions and results in:
-1 : this is smaller <=> given version and this is bigger.
|
boolean |
equals(Object obj) |
static boolean |
equals(Version version1,
Version version2)
Returns whether two versions are equal.
|
int |
getSegment(int index)
Returns the version segment specified by
index. |
int |
getSegmentCount()
Returns the number of the segments.
|
int |
hashCode() |
static boolean |
isVersion(String string)
Returns whether the given
string denotes a version. |
String |
toString()
Returns a textual representation of this instance.
|
private static final Pattern PATTERN
private static final String SEPARATOR
private int[] segments
public Version(String version) throws IllegalArgumentException
version - the version string in form i(.i)* with i integer numbersIllegalArgumentException - in case of format problemspublic Version(int... version)
version - version number segments (from left to right), without SEPARATORpublic static final boolean isVersion(String string)
string denotes a version.string - the string to be testedtrueif string is a version, false elsepublic int getSegmentCount()
public int getSegment(int index)
index.index - a 0-based index specifying the segment to be returnedIndexOutOfBoundsException - if
index<0 || index>=getSegmentCount()public int compareTo(Version version)
compareTo in interface Comparable<Version>version - version to compare.public String toString()
public static boolean equals(Version version1, Version version2)
version1 - the first version instance (may be null)version2 - the second version instance (may be null)true if version1 equals
version2, false elsepublic static int compare(Version version1, Version version2)
version1 - the first version to compare.version2 - the second version to compare.Copyright © 2021. All rights reserved.