Comparable<ModuleDescriptor.Version>
public static final class ModuleDescriptor.Version extends Object implements Comparable<ModuleDescriptor.Version>
A version string has three components: The version number itself, an
optional pre-release version, and an optional build version. Each
component is a sequence of tokens; each token is either a non-negative
integer or a string. Tokens are separated by the punctuation characters
'.'
, '-'
, or '+'
, or by transitions from a
sequence of digits to a sequence of characters that are neither digits
nor punctuation characters, or vice versa.
'.'
characters, terminated by the first '-'
or
'+'
character. '.'
or '-'
characters, terminated by the first
'+'
character. '.'
, '-'
, or '+'
characters.
When comparing two version strings, the elements of their corresponding components are compared in pointwise fashion. If one component is longer than the other, but otherwise equal to it, then the first component is considered the greater of the two; otherwise, if two corresponding elements are integers then they are compared as such; otherwise, at least one of the elements is a string, so the other is converted into a string if it is an integer and the two are compared lexicographically. Trailing integer elements with the value zero are ignored.
Given two version strings, if their version numbers differ then the result of comparing them is the result of comparing their version numbers; otherwise, if one of them has a pre-release version but the other does not then the first is considered to precede the second, otherwise the result of comparing them is the result of comparing their pre-release versions; otherwise, the result of comparing them is the result of comparing their build versions.
ModuleDescriptor.version()
Modifier and Type | Method | Description |
---|---|---|
int |
compareTo(ModuleDescriptor.Version that) |
Compares this module version to another module version.
|
boolean |
equals(Object ob) |
Tests this module version for equality with the given object.
|
int |
hashCode() |
Computes a hash code for this module version.
|
static ModuleDescriptor.Version |
parse(String v) |
Parses the given string as a version string.
|
String |
toString() |
Returns the string from which this version was parsed.
|
public static ModuleDescriptor.Version parse(String v)
v
- The string to parseVersion
IllegalArgumentException
- If v
is null
, an empty string, or cannot be
parsed as a version stringpublic int compareTo(ModuleDescriptor.Version that)
compareTo
in interface Comparable<ModuleDescriptor.Version>
that
- The module version to comparepublic boolean equals(Object ob)
If the given object is not a Version
then this method
returns false
. Two module version are equal if their
corresponding components are equal.
This method satisfies the general contract of the Object.equals
method.
equals
in class Object
ob
- the object to which this object is to be comparedtrue
if, and only if, the given object is a module
reference that is equal to this module referenceObject.hashCode()
,
HashMap
public int hashCode()
The hash code is based upon the components of the version and
satisfies the general contract of the Object.hashCode
method.
hashCode
in class Object
Object.equals(java.lang.Object)
,
System.identityHashCode(java.lang.Object)
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2017, Oracle and/or its affiliates. 500 Oracle Parkway
Redwood Shores, CA 94065 USA. All rights reserved.
DRAFT 9-internal+0-adhoc.mlchung.jdk9-jdeps