public class VersionIdentifierImpl extends AbstractVersionIdentifier
VersionIdentifier.| Modifier and Type | Field and Description |
|---|---|
private String |
label |
private DevelopmentPhase |
phase |
private String |
phaseAlias |
private Integer |
phaseNumber |
private Long |
revision |
private int[] |
segments |
private static long |
serialVersionUID
UID for serialization.
|
private boolean |
snapshot |
private Date |
timestamp |
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 |
|---|
VersionIdentifierImpl()
The non-arg constructor.
|
VersionIdentifierImpl(String stringRepresentation,
String label,
Date timestamp,
Long revision,
DevelopmentPhase phase,
String phaseAlias,
Integer phaseNumber,
boolean snapshot,
int... versionSegments)
The constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getLabel()
This method gets the optional label of the
VersionIdentifier. |
DevelopmentPhase |
getPhase()
This method gets the
DevelopmentPhase of this VersionIdentifier. |
String |
getPhaseAlias()
This method gets the string representation of the
phase for this
VersionIdentifier. |
Integer |
getPhaseNumber()
This method gets the subsequent number of this
VersionIdentifier within a particular
phase. |
Long |
getRevision()
This method gets the revision of the
VersionIdentifier. |
Date |
getTimestamp()
This method gets the timestamp of the
VersionIdentifier. |
int |
getVersionSegment(int index)
This method gets an arbitrary segment of the version number.
|
int |
getVersionSegmentCount()
This method gets the number of
segments of this VersionIdentifier
. |
boolean |
isSnapshot()
This method determines if this
VersionIdentifier indicates a snapshot release. |
protected void |
setStringRepresentation(String stringRepresentation) |
private void |
validate()
This method validates the consistency of this version identifier.
|
compareTo, equals, getStringRepresentation, getValue, getVersionMajorSegment, getVersionMicroSegment, getVersionMilliSegment, getVersionMinorSegment, hashCode, toStringprivate static final long serialVersionUID
private int[] segments
getVersionSegment(int)private DevelopmentPhase phase
getPhase()private Integer phaseNumber
getPhaseNumber()private String phaseAlias
getPhaseAlias()private boolean snapshot
isSnapshot()private Long revision
getRevision()private Date timestamp
getTimestamp()private String label
getLabel()public VersionIdentifierImpl()
public VersionIdentifierImpl(String stringRepresentation, String label, Date timestamp, Long revision, DevelopmentPhase phase, String phaseAlias, Integer phaseNumber, boolean snapshot, int... versionSegments)
stringRepresentation - - see AbstractVersionIdentifier.toString().label - - see getLabel(). May be null.timestamp - - see getTimestamp(). May be null.revision - - see getRevision(). May be null.phase - - see getPhase(). May be null.phaseAlias - - see getPhase(). May be null (only if phase is
null).phaseNumber - - see getPhaseNumber(). May be null (only if phase
is null).snapshot - - see isSnapshot().versionSegments - - see getVersionSegment(int). At least one segment is required if no
snapshot.private void validate()
protected void setStringRepresentation(String stringRepresentation)
setStringRepresentation in class AbstractVersionIdentifierstringRepresentation - is the stringRepresentation to setpublic int getVersionSegment(int index)
throws IndexOutOfBoundsException
VersionIdentifier represented by the concatenation of all
segments separated by a separator (typically the dot sign). 0 if a segment is not available.
However it will not throw an IndexOutOfBoundsException if the index is non negative. | version number | VersionIdentifier.getVersionSegmentCount() |
index | getSegment(index) |
|---|---|---|---|
| 1.2.3.42 | 4 | 0 | 1 |
| 1.2.3.42 | 4 | 3 | 42 |
| 1.2.3.42 | 4 | 4 | 0 |
| 4.0 | 2 | 0 | 4 |
| 4.0 | 2 | 1 | 0 |
| 4.0 | 2 | 2 | 0 |
| 4.0 | 2 | 3 | 0 |
getSegment()index - is the 0-based index of the requested segment. It shall not be negative.index is greater or equal
to VersionIdentifier.getVersionSegmentCount()) the value 0 is returned.IndexOutOfBoundsException - if the given index is negative.VersionIdentifier.VERSION_SEGMENT_INDEX_MAJOR,
VersionIdentifier.VERSION_SEGMENT_INDEX_MINOR,
VersionIdentifier.VERSION_SEGMENT_INDEX_MILLI,
VersionIdentifier.VERSION_SEGMENT_INDEX_MICRO,
VersionIdentifier.VERSION_SEGMENT_INDEX_NANNO,
VersionIdentifier.VERSION_SEGMENT_INDEX_PICOpublic int getVersionSegmentCount()
segments of this VersionIdentifier
.segments.public DevelopmentPhase getPhase()
DevelopmentPhase of this VersionIdentifier. phase is undefined (null), DevelopmentPhase.RELEASE will
be assumed for VersionIdentifier.compareTo(VersionIdentifier).DevelopmentPhase or null if NOT defined.public Integer getPhaseNumber()
VersionIdentifier within a particular
phase. It is typically null and will then be omitted in the
string-representation. However release-candidates and updates are often numbered (e.g. like "u1", "u2",
... in Java-releases or "RC1"/"SR1", ... in Eclipse-releases). VersionIdentifier.getPhase() returns null also this method should return null. Also
if VersionIdentifier.getPhase() is DevelopmentPhase.RELEASE this method should return null
(there is just one official release - after that there are updates). phase is undefined (null), 0 will be assumed
for VersionIdentifier.compareTo(VersionIdentifier).null if NOT defined.public String getPhaseAlias()
phase for this
VersionIdentifier. This is ideally
VersionIdentifier.getPhase().toString() but may also be any other
legal alias for the phase. DevelopmentPhase.RELEASE the phase name may also be "final",
"GA", "RTM", "REL", "gold", or "stable".phase.public boolean isSnapshot()
VersionIdentifier indicates a snapshot release. A snapshot is an
informal pre-release. Multiple snapshot releases with different content can be published for snapshot
versions while this is strictly prohibited for non-snapshot versions. A snapshot version is a
strict predecessor of the same VersionIdentifier without
the snapshot. phase and can be combined
(e.g. "1.0.0-beta2-SNAPSHOT").true if this VersionIdentifier represents a snapshot release,
false in case of an official release.public Long getRevision()
VersionIdentifier. It typically has a technical nature and
might be derived from the underlying version control system.null if NOT defined.public Date getTimestamp()
VersionIdentifier. It indicates the point in time when this
VersionIdentifier was assigned to the associated object. The timestamp may also called
release date. The value is optional but is best practice to assign a timestamp to a
VersionIdentifier.null if NOT defined.public String getLabel()
VersionIdentifier. A label is a non-technical
identifier also called code name (e.g. "Tiger" or "Dolphin").null if NOT defined.Copyright © 2001–2015 mmm-Team. All rights reserved.