public abstract class AbstractVersionIdentifier extends Object implements VersionIdentifier
VersionIdentifier
.Modifier and Type | Field and Description |
---|---|
private int |
hash |
private static long |
serialVersionUID |
private String |
stringRepresentation |
COMPARE_TO_INCOMPARABLE, COMPARE_TO_STRICT_PREDECESSOR, COMPARE_TO_STRICT_SUCCESSOR, SNAPSHOT, VERSION_SEGMENT_INDEX_MAJOR, VERSION_SEGMENT_INDEX_MICRO, VERSION_SEGMENT_INDEX_MILLI, VERSION_SEGMENT_INDEX_MINOR, VERSION_SEGMENT_INDEX_NANNO, VERSION_SEGMENT_INDEX_PICO
Constructor and Description |
---|
AbstractVersionIdentifier(String stringRepresentation)
The constructor.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(VersionIdentifier otherVersion)
This method determines a (non-linear) distance from this version to the given
otherVersion . |
private int |
compareToLabel(int currentResult,
VersionIdentifier otherVersion)
This method performs the part of
compareTo(VersionIdentifier) for the label . |
private <T extends Comparable<T>> |
compareToLinear(int currentResult,
T thisValue,
T otherValue,
VersionIdentifier otherVersion)
This method performs the part of
compareTo(VersionIdentifier) for linear and optional attributes like
VersionIdentifier.getTimestamp() or VersionIdentifier.getRevision() . |
private int |
compareToPhase(int currentResult,
VersionIdentifier otherVersion)
This method performs the part of
compareTo(VersionIdentifier) for the timestamp . |
private int |
compareToRevision(int currentResult,
VersionIdentifier otherVersion)
This method performs the part of
compareTo(VersionIdentifier) for the revision . |
private int |
compareToTimestamp(int currentResult,
VersionIdentifier otherVersion)
This method performs the part of
compareTo(VersionIdentifier) for the timestamp . |
private int |
compareToVersionNumber(VersionIdentifier otherVersion)
This method performs the part of
compareTo(VersionIdentifier) for the version number . |
boolean |
equals(Object other) |
private static int |
getPhaseNumberAsInt(VersionIdentifier version)
This method gets
VersionIdentifier.getPhaseNumber() as int . |
String |
getStringRepresentation() |
String |
getValue()
This method returns the raw value of this datatype.
|
int |
getVersionMajorSegment()
|
int |
getVersionMicroSegment()
|
int |
getVersionMilliSegment()
|
int |
getVersionMinorSegment()
|
int |
hashCode() |
protected void |
setStringRepresentation(String stringRepresentation) |
String |
toString()
This method gets a unique string representation of this
VersionIdentifier . |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
getLabel, getPhase, getPhaseAlias, getPhaseNumber, getRevision, getTimestamp, getVersionSegment, getVersionSegmentCount, isSnapshot
private static final long serialVersionUID
private transient int hash
private transient String stringRepresentation
public AbstractVersionIdentifier(String stringRepresentation)
stringRepresentation
- is the String
returned by toString()
.public int getVersionMajorSegment()
VersionIdentifier
major
segment
of this
VersionIdentifier
. This is the most significant segment
of the version. It
only gets updated on significant functional and/or structural changes of the versioned artifact. An upgrade can
cause appreciable manual effort and will often cause compatibility problems and require migration of data or
configuration.getVersionMajorSegment
in interface VersionIdentifier
VersionIdentifier.VERSION_SEGMENT_INDEX_MAJOR
public int getVersionMinorSegment()
VersionIdentifier
minor
segment
of this
VersionIdentifier
. This is the second most significant segment
of the
version. It only gets updated on functional and/or structural changes of the versioned artifact. An upgrade should
be supported but may cause compatibility problems and require migration of data or configuration.getVersionMinorSegment
in interface VersionIdentifier
VersionIdentifier.VERSION_SEGMENT_INDEX_MINOR
public int getVersionMilliSegment()
VersionIdentifier
milli
segment
of this
VersionIdentifier
. This is the third most significant segment
of the
version. It only gets updated on small functional and/or structural changes of the versioned artifact. An upgrade
should not cause problems but needs to be tested.getVersionMilliSegment
in interface VersionIdentifier
VersionIdentifier.VERSION_SEGMENT_INDEX_MILLI
public int getVersionMicroSegment()
VersionIdentifier
micro
segment
of this
VersionIdentifier
. This is the fourth most significant segment
of the
version. It only gets updated on small internal changes (e.g. bugfixes) of the versioned artifact. An upgrade
should not cause problems.getVersionMicroSegment
in interface VersionIdentifier
VersionIdentifier.VERSION_SEGMENT_INDEX_MICRO
public String getStringRepresentation()
protected void setStringRepresentation(String stringRepresentation)
stringRepresentation
- is the stringRepresentation to setprivate int compareToVersionNumber(VersionIdentifier otherVersion)
compareTo(VersionIdentifier)
for the version number
.otherVersion
- is the VersionIdentifier
to compare to.private static int getPhaseNumberAsInt(VersionIdentifier version)
VersionIdentifier.getPhaseNumber()
as int
.version
- is the VersionIdentifier
.VersionIdentifier.getPhaseNumber()
as int
, using 0
for null
.private int compareToPhase(int currentResult, VersionIdentifier otherVersion)
compareTo(VersionIdentifier)
for the timestamp
.currentResult
- is the current result so far.otherVersion
- is the VersionIdentifier
to compare to.private int compareToTimestamp(int currentResult, VersionIdentifier otherVersion)
compareTo(VersionIdentifier)
for the timestamp
.currentResult
- is the current result so far.otherVersion
- is the VersionIdentifier
to compare to.private <T extends Comparable<T>> int compareToLinear(int currentResult, T thisValue, T otherValue, VersionIdentifier otherVersion)
compareTo(VersionIdentifier)
for linear and optional attributes like
VersionIdentifier.getTimestamp()
or VersionIdentifier.getRevision()
.T
- is the generic type of the Comparable
value.currentResult
- is the current result so far.thisValue
- is the value of this VersionIdentifier
.otherValue
- is the value of the other VersionIdentifier
.otherVersion
- is the VersionIdentifier
to compare to.private int compareToRevision(int currentResult, VersionIdentifier otherVersion)
compareTo(VersionIdentifier)
for the revision
.currentResult
- is the current result so far.otherVersion
- is the VersionIdentifier
to compare to.private int compareToLabel(int currentResult, VersionIdentifier otherVersion)
compareTo(VersionIdentifier)
for the label
.currentResult
- is the current result so far.otherVersion
- is the VersionIdentifier
to compare to.public final int compareTo(VersionIdentifier otherVersion)
VersionIdentifier
otherVersion
. It will return
VersionIdentifier.COMPARE_TO_INCOMPARABLE
if both versions are incompatible to each other (e.g. ).0
if both versions are historically equivalent (but may NOT be equal
)
otherVersion
. The value -1 indicates a
strict predecessor
.otherVersion
. The value +1 indicates a
strict successor
.version | otherVersion | version. |
---|---|---|
1.0.0-SNAPSHOT | 1.0.0-SNAPSHOT | 0 |
1.0.0 | 1.0.0-SNAPSHOT | 1 (VersionIdentifier.COMPARE_TO_STRICT_SUCCESSOR ) |
1.0.1 | 1.0.0 | 1 (VersionIdentifier.COMPARE_TO_STRICT_SUCCESSOR ) |
1.0.1 | 1.0.0-SNAPSHOT | >1 |
1.6.0u23 | 1.6.0u24 | -1 (VersionIdentifier.COMPARE_TO_STRICT_PREDECESSOR ) |
3.7-SR1-indigo | 4.1.1-201109121510 | <-1 |
3.7.1-helios | 3.7.1-indigo | VersionIdentifier.COMPARE_TO_INCOMPARABLE |
1.0-20000101T000000Z | 1.0-19991231T235959Z | VersionIdentifier.COMPARE_TO_INCOMPARABLE |
1.0-20000101T000000Z | 1.1-19991231T235959Z | VersionIdentifier.COMPARE_TO_INCOMPARABLE |
compareTo
in interface Comparable<VersionIdentifier>
compareTo
in interface VersionIdentifier
public String getValue()
SimpleDatatype
String
, Character
, Boolean
, any type of Number
, any type of java.time.LocalDate
, etc.).getValue
in interface AttributeReadValue<String>
getValue
in interface SimpleDatatype<String>
public String toString()
VersionIdentifier
VersionIdentifier
.
Returns the official String
representation of this Datatype
. While the general contract of
Object.toString()
is very weak and mainly used for debugging, the contract here is very strong. The
returned String
has to be suitable for end-users and official output to any kind of sink. NlsMessage
for
this purpose and implement NlsObject
if you want to support I18N/L10N.Copyright © 2001–2016 mmm-Team. All rights reserved.