Class DefaultVersionInfo
java.lang.Object
org.apache.maven.shared.release.versions.DefaultVersionInfo
- All Implemented Interfaces:
Comparable<VersionInfo>, VersionInfo
This compares and increments versions for a common java versioning scheme.
The supported version scheme has the following parts.
Example:
The separators "_" and "-" between components are also optional (though they are usually recommended).
Example:
component-digits-annotation-annotationRevision-buildSpecifierExample:
my-component-1.0.1-alpha-2-SNAPSHOT
- Terms:
- component - name of the versioned component (log4j, commons-lang, etc)
- digits - Numeric digits with at least one "." period. (1.0, 1.1, 1.01, 1.2.3, etc)
- annotationRevision - Integer qualifier for the annotation. (4 as in RC-4)
- buildSpecifier - Additional specifier for build. (SNAPSHOT, or build number like "20041114.081234-2")
The separators "_" and "-" between components are also optional (though they are usually recommended).
Example:
log4j-1.2.9-beta-9-SNAPSHOT == log4j1.2.9beta9SNAPSHOT == log4j_1.2.9_beta_9_SNAPSHOT
Leading zeros are significant when performing comparisons.
TODO: this parser is better than DefaultArtifactVersion - replace it with this (but align naming) and then remove
this from here.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Patternprivate Stringprivate static final intprivate static final intprivate static final intprivate static final intprivate Stringprivate Stringprivate Stringprivate static final intprivate static final intprivate final Stringprivate final Stringprivate static final Stringprivate static final intprivate static final Stringstatic final Patternprivate final String -
Constructor Summary
ConstructorsConstructorDescriptionDefaultVersionInfo(String version) Constructs this object and parses the supplied version string.DefaultVersionInfo(List<String> digits, String annotation, String annotationRevision, String buildSpecifier, String annotationSeparator, String annotationRevSeparator, String buildSeparator) -
Method Summary
Modifier and TypeMethodDescriptionintcompareTo(VersionInfo obj) Compares thisDefaultVersionInfoto the suppliedDefaultVersionInfoto determine which version is greater.booleanReturns aVersionInfoobject which represents the next version of this object.Returns a string representing the version without a snapshot specification.Returns a string representing the version with a snapshot specificationprotected static StringgetVersionString(DefaultVersionInfo info, String buildSpecifier, String buildSeparator) inthashCode()protected StringTakes a string and increments it as an integer.booleanReturns whether this represents a snapshot version.protected static StringjoinDigitString(List<String> digits) Simply joins the items in the list with "." periodprivate static StringparseDigits(String strDigits) Splits the string on "." and returns a list containing each digit.toString()
-
Field Details
-
strVersion
-
digits
-
annotation
-
annotationRevision
-
buildSpecifier
-
annotationSeparator
-
annotationRevSeparator
-
buildSeparator
-
DIGITS_INDEX
private static final int DIGITS_INDEX- See Also:
-
ANNOTATION_SEPARATOR_INDEX
private static final int ANNOTATION_SEPARATOR_INDEX- See Also:
-
ANNOTATION_INDEX
private static final int ANNOTATION_INDEX- See Also:
-
ANNOTATION_REV_SEPARATOR_INDEX
private static final int ANNOTATION_REV_SEPARATOR_INDEX- See Also:
-
ANNOTATION_REVISION_INDEX
private static final int ANNOTATION_REVISION_INDEX- See Also:
-
BUILD_SEPARATOR_INDEX
private static final int BUILD_SEPARATOR_INDEX- See Also:
-
BUILD_SPECIFIER_INDEX
private static final int BUILD_SPECIFIER_INDEX- See Also:
-
SNAPSHOT_IDENTIFIER
- See Also:
-
DIGIT_SEPARATOR_STRING
- See Also:
-
STANDARD_PATTERN
-
ALTERNATE_PATTERN
-
-
Constructor Details
-
DefaultVersionInfo
Constructs this object and parses the supplied version string.- Parameters:
version-- Throws:
VersionParseException
-
DefaultVersionInfo
-
-
Method Details
-
isSnapshot
public boolean isSnapshot()Description copied from interface:VersionInfoReturns whether this represents a snapshot version.- Specified by:
isSnapshotin interfaceVersionInfo- Returns:
trueif the original value was a snapshot, otherwisefalse
-
getNextVersion
Description copied from interface:VersionInfoReturns aVersionInfoobject which represents the next version of this object.- Specified by:
getNextVersionin interfaceVersionInfo- Returns:
- the next VersionInfo
-
equals
-
hashCode
-
incrementVersionString
-
getSnapshotVersionString
Description copied from interface:VersionInfoReturns a string representing the version with a snapshot specification- Specified by:
getSnapshotVersionStringin interfaceVersionInfo- Returns:
- the snapshot version transformation of the original value
-
getReleaseVersionString
Description copied from interface:VersionInfoReturns a string representing the version without a snapshot specification.- Specified by:
getReleaseVersionStringin interfaceVersionInfo- Returns:
- the final version transformation of the original value
-
toString
-
joinDigitString
-
parseDigits
-
nullIfEmpty
-
getDigits
-
getAnnotation
-
getAnnotationRevision
-
getBuildSpecifier
-