java.lang.Object | |
↳ | com.atlassian.bitbucket.util.Version |
Version represents a version. This class is useful for comparing versions, for instance when you need to determine whether the version is at least X.
Versions
parsed by this class are always 0
-padded to at least three places. For
example, an input of "2"
will result in [2, 0, 0]
. More specific input, such as "1.7.9.5"
will result in longer lists; 3 places is a minimum, not a maximum.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
STRICT_NUMERIC_VALIDATOR | A Pattern that can validate a potential version String to ensure it contains a
valid set of numbers and '.''s
Version does not use this pattern, but it's handy for code that wants to ensure a
version string is valid before turning it into a Version . |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructor for accepting a pre-parsed version.
| |||||||||||
Constructor that parses a version string.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Compare two versions to determine their ordering.
| |||||||||||
Retrieves an immutable copy of the ordered list of version components.
| |||||||||||
Returns a
String representation of this version , with the components separated by
dots. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Comparable
|
A Pattern
that can validate a potential version String to ensure it contains a
valid set of numbers and '.''s
Version
does not use this pattern, but it's handy for code that wants to ensure a
version string is valid before turning it into a Version
.
Constructor for accepting a pre-parsed version.
elements | the version elements, starting with the most significant |
---|
Constructor that parses a version string. Version parts are determined by splitting on [.-] characters. If a non- numerical value is found (e.g. 'RC4'), the rest of the version String is ignored. In other words '1.0.1-RC.2' is considered equal to '1.0.1'
version | the version string |
---|
Compare two versions to determine their ordering. This class has a natural ordering that is consistent
with equals
.
Note: Returns from this method should not be assumed to be -1
, 0
or 1
. As per the
contract of Comparable
, they should be evaluated as negative, 0
or positive. Implementations
are free to use any positive or negative number they wish to indicate greater than and less than ordering.
getVersion().get(0)
getVersion().get(1)
getVersion().get(2)
Returns a String
representation of this version
, with the components separated by
dots.
Note: For version strings which contain non-numerical, non-separator elements, the resulting representation will
not match the input. For example, an initial version like "1.7.9-RC1"
will result in "1.7.9"
for
the return value here. Padding may also be applied, so an initial version of "2"
would be represented as
"2.0.0"
.