public final class ArtifactVersion extends Object
Module.
Implements value semantics. Instances are immutable.
Implements hashCode() and equals(java.lang.Object) so that instances can be used as
Map keys.
Version. One reason for having two separate classes is to help avoid
type mismatch and ensuring type safety.
As for Version, two types of ArtifactVersion's are recognized:
ArtifactVersion's are assumed to be of the form <version>[-SNAPSHOT]. If the -SNAPSHOT suffix is present the ArtifactVersion is considered dynamic. If the -SNAPSHOT suffix is not present, it is considered static.
No other assumption is made on the format of ArtifactVersion's (numeric, semantic, date-based, etc.).
The -SNAPSHOT convention is borrowed from Maven so it could be said that this implementation is somewhat Maven-specific. But we assume that this convention is sufficiently generic to not be considered Maven-specific. Time and experience will tell if this proves wrong and adjustments may be required in the future to keep things clean.
| Modifier and Type | Field and Description |
|---|---|
static String |
DYNAMIC_VERSION_SUFFIX
Suffix for dynamic ArtifactVersion.
|
| Constructor and Description |
|---|
ArtifactVersion(String stringArtifactVersion)
Constructor using an ArtifactVersion literal.
|
ArtifactVersion(VersionType versionType,
String version)
Constructor using the individual fields.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object other) |
Version |
getCorrespondingVersion()
Returns a
Version corresponding to this ArtifactVersion assuming a
direct equivalence between the two. |
String |
getVersion() |
VersionType |
getVersionType() |
int |
hashCode() |
static ArtifactVersion |
parse(String stringArtifactVersion)
Parses an ArtifactVersion literal.
|
String |
toString() |
public static final String DYNAMIC_VERSION_SUFFIX
public ArtifactVersion(VersionType versionType, String version)
versionType - VersionType.version - Version string, without the -SNAPSHOT suffix for a dynamic
version.public ArtifactVersion(String stringArtifactVersion)
Throws RuntimeException if parsing fails.
stringArtifactVersion - ArtifactVersion literal.public static ArtifactVersion parse(String stringArtifactVersion) throws ParseException
stringArtifactVersion - ArtifactVersion literal.ParseException - If parsing fails.public VersionType getVersionType()
public String getVersion()
public Version getCorrespondingVersion()
Version corresponding to this ArtifactVersion assuming a
direct equivalence between the two.
Note that the mapping between ArtifactVersion and Version during tool
execution is generally handled by ArtifactVersionMapperPlugin. This
method implements a very simple mapping which is only one possible mapping.
ArtifactVersionMapperPlugin must generally be used so that module-specific
mapping algorithms can be honored.
public String toString()
Copyright © 2015–2017 AZYVA INC.. All rights reserved.