Package org.codehaus.mojo.versions.api
Class AbstractVersionDetails
java.lang.Object
org.codehaus.mojo.versions.api.AbstractVersionDetails
- All Implemented Interfaces:
VersionDetails
- Direct Known Subclasses:
ArtifactVersions
,PropertyVersions
Base class for
VersionDetails
.- Since:
- 1.0-beta-1
- Author:
- Stephen Connolly
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal boolean
containsVersion
(String version) Returnstrue
if the specific version is in the list of versions.final org.apache.maven.artifact.versioning.ArtifactVersion[]
getAllUpdates
(boolean includeSnapshots) Returns the all versions newer than the specified current versionfinal org.apache.maven.artifact.versioning.ArtifactVersion[]
getAllUpdates
(Optional<Segment> updateScope, boolean includeSnapshots) Returns the all versions newer than the specified current version, but within the specified update scope.final org.apache.maven.artifact.versioning.ArtifactVersion[]
getAllUpdates
(org.apache.maven.artifact.versioning.ArtifactVersion currentVersion, Optional<Segment> updateScope, boolean includeSnapshots) Returns the all versions newer than the specified current version, but within the specified update scope.org.apache.maven.artifact.versioning.ArtifactVersion[]
getAllUpdates
(org.apache.maven.artifact.versioning.VersionRange versionRange, boolean includeSnapshots) Returns the all versions newer than the specified current version, but within the specified update scope.final org.apache.maven.artifact.versioning.ArtifactVersion
Returns the current version.final org.apache.maven.artifact.versioning.VersionRange
Returns the current version range (may benull
)protected org.apache.maven.artifact.versioning.ArtifactVersion
getHighestLowerBound
(org.apache.maven.artifact.versioning.ArtifactVersion lowerBoundVersion) If a version is a version range consisting of one or more version ranges, returns the highest lower bound.getLowerBound
(org.apache.maven.artifact.versioning.ArtifactVersion version, Optional<Segment> unchangedSegment) Returns the string designation of the lower bound version based on the given artifact version and the lowest unchanged segment index (0-based); -1 means that the whole version string can be changed, implying that there is also no string designation of the lower bound version.final org.apache.maven.artifact.versioning.ArtifactVersion[]
getNewerVersions
(String versionString, Optional<Segment> unchangedSegment, boolean includeSnapshots, boolean allowDowngrade) Returns an array of newer versions than the given version, given the upper bound segment and whether snapshots should be included.final org.apache.maven.artifact.versioning.ArtifactVersion
getNewestUpdateWithinSegment
(Optional<Segment> updateScope, boolean includeSnapshots) Returns the newest version newer than the specified current version, only within the segment specified byupdateScope
ornull
if no such version exists.final org.apache.maven.artifact.versioning.ArtifactVersion
getNewestUpdateWithinSegment
(org.apache.maven.artifact.versioning.ArtifactVersion currentVersion, Optional<Segment> updateScope, boolean includeSnapshots) Returns the newest version newer than the specified current version, but within the specified update scope ornull
if no such version exists.Optional
<org.apache.maven.artifact.versioning.ArtifactVersion> getNewestVersion
(String actualVersion, Optional<Segment> unchangedSegment, boolean includeSnapshots, boolean allowDowngrade) Returns the latest version, newer than the given version, given the upper bound segment and whether snapshots should be included.final org.apache.maven.artifact.versioning.ArtifactVersion
getNewestVersion
(org.apache.maven.artifact.versioning.Restriction restriction, boolean includeSnapshots) Returns the latest version newer than the specified current version, but less than the specified upper bound ornull
if no such version exists.final org.apache.maven.artifact.versioning.ArtifactVersion
getNewestVersion
(org.apache.maven.artifact.versioning.VersionRange versionRange, boolean includeSnapshots) Returns the latest version within the specified version range ornull
if no such version exists.final org.apache.maven.artifact.versioning.ArtifactVersion
getNewestVersion
(org.apache.maven.artifact.versioning.VersionRange versionRange, org.apache.maven.artifact.versioning.Restriction restriction, boolean includeSnapshots) Returns the latest version newer than the specified current version, but less than the specified upper bound ornull
if no such version exists.final org.apache.maven.artifact.versioning.ArtifactVersion
getNewestVersion
(org.apache.maven.artifact.versioning.VersionRange versionRange, org.apache.maven.artifact.versioning.Restriction restriction, boolean includeSnapshots, boolean allowDowngrade) Returns the latest version given the version range, restricition, whether to include snapshots and/or allow downgrades, ornull
if no such version exists.final org.apache.maven.artifact.versioning.ArtifactVersion
getReportNewestUpdate
(Optional<Segment> updateScope, boolean includeSnapshots) Returns the latest version newer than the specified current version, and within the specified update scope, ornull
if no such version exists.final org.apache.maven.artifact.versioning.ArtifactVersion[]
getReportUpdates
(Optional<Segment> updateScope, boolean includeSnapshots) Returns all versions newer than the specified current version, and within the specified update scope.protected Optional
<org.apache.maven.artifact.versioning.Restriction> getSelectedRestriction
(org.apache.maven.artifact.versioning.ArtifactVersion selectedVersion) If the artifact is bound by one or more version ranges, returns the restriction that constitutes the version range containing the selected actual version.final org.apache.maven.artifact.versioning.ArtifactVersion[]
getVersions
(org.apache.maven.artifact.versioning.Restriction restriction, boolean includeSnapshots) Returns all available versions within the specified bounds.final org.apache.maven.artifact.versioning.ArtifactVersion[]
getVersions
(org.apache.maven.artifact.versioning.VersionRange versionRange, boolean includeSnapshots) Returns all available versions within the specified version range.final org.apache.maven.artifact.versioning.ArtifactVersion[]
getVersions
(org.apache.maven.artifact.versioning.VersionRange versionRange, org.apache.maven.artifact.versioning.Restriction restriction, boolean includeSnapshots) Returns all available versions within the specified bounds.boolean
isVersionInRestriction
(org.apache.maven.artifact.versioning.Restriction restriction, org.apache.maven.artifact.versioning.ArtifactVersion candidate) Checks if the candidate version is in the range of the restriction.org.apache.maven.artifact.versioning.Restriction
restrictionForIgnoreScope
(org.apache.maven.artifact.versioning.ArtifactVersion lowerBound, Optional<Segment> ignored) Returns theRestriction
objects for a segemnt scope which is to be ignored.org.apache.maven.artifact.versioning.Restriction
restrictionForSelectedSegment
(org.apache.maven.artifact.versioning.ArtifactVersion lowerBound, Optional<Segment> selectedSegment) Returns a Restriction object for computing version upgrades within the given segment allowing updates, with all more major segments locked in place, but also ignoring all version updates from lesser scopes.org.apache.maven.artifact.versioning.Restriction
restrictionForUnchangedSegment
(org.apache.maven.artifact.versioning.ArtifactVersion actualVersion, Optional<Segment> unchangedSegment, boolean allowDowngrade) Returns a Restriction object for computing version upgrades within the all segments minor/lesser to the providedunchangedSegment
.final void
setCurrentVersion
(String currentVersion) Sets the current version.final void
setCurrentVersion
(org.apache.maven.artifact.versioning.ArtifactVersion currentVersion) Sets the current version.final void
setCurrentVersionRange
(org.apache.maven.artifact.versioning.VersionRange versionRange) Sets the current version range (may benull
)Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.codehaus.mojo.versions.api.VersionDetails
getVersionComparator, getVersions
-
Field Details
-
verboseDetail
protected boolean verboseDetail
-
-
Constructor Details
-
AbstractVersionDetails
protected AbstractVersionDetails()
-
-
Method Details
-
getHighestLowerBound
protected org.apache.maven.artifact.versioning.ArtifactVersion getHighestLowerBound(org.apache.maven.artifact.versioning.ArtifactVersion lowerBoundVersion) If a version is a version range consisting of one or more version ranges, returns the highest lower bound. If a single version range is present, returns its value.- Parameters:
lowerBoundVersion
- actual version used- Returns:
- highest lower bound of the given version range or
getCurrentVersion()
if there's no lower bound
-
getSelectedRestriction
protected Optional<org.apache.maven.artifact.versioning.Restriction> getSelectedRestriction(org.apache.maven.artifact.versioning.ArtifactVersion selectedVersion) If the artifact is bound by one or more version ranges, returns the restriction that constitutes the version range containing the selected actual version. If there are no version ranges, returns the provided version.- Parameters:
selectedVersion
- actual version used, may not benull
- Returns:
- restriction containing the version range selected by the given version,
or
Optional.empty()
if there are no ranges
-
restrictionForSelectedSegment
public org.apache.maven.artifact.versioning.Restriction restrictionForSelectedSegment(org.apache.maven.artifact.versioning.ArtifactVersion lowerBound, Optional<Segment> selectedSegment) Description copied from interface:VersionDetails
Returns a Restriction object for computing version upgrades within the given segment allowing updates, with all more major segments locked in place, but also ignoring all version updates from lesser scopes.
- Specified by:
restrictionForSelectedSegment
in interfaceVersionDetails
- Parameters:
lowerBound
- artifact version, for which the unchanged segment is computedselectedSegment
- segment, for which the restriction is to be built orOptional.empty()
for no restriction- Returns:
- Restriction object based on the arguments
-
restrictionForUnchangedSegment
public org.apache.maven.artifact.versioning.Restriction restrictionForUnchangedSegment(org.apache.maven.artifact.versioning.ArtifactVersion actualVersion, Optional<Segment> unchangedSegment, boolean allowDowngrade) throws InvalidSegmentException Description copied from interface:VersionDetails
Returns a Restriction object for computing version upgrades within the all segments minor/lesser to the provided
unchangedSegment
.If the provided segment is
Optional.empty()
, all possible updates are returned.- Specified by:
restrictionForUnchangedSegment
in interfaceVersionDetails
- Parameters:
actualVersion
- artifact version, for which the unchanged segment is computedunchangedSegment
- segment, which should not be changed orOptional.empty()
for no restrictionallowDowngrade
- whether downgrades are allowed- Returns:
- Restriction object based on the arguments
- Throws:
InvalidSegmentException
- if the requested segment is outside the bounds (less than 1 or greater than the segment count)
-
restrictionForIgnoreScope
public org.apache.maven.artifact.versioning.Restriction restrictionForIgnoreScope(org.apache.maven.artifact.versioning.ArtifactVersion lowerBound, Optional<Segment> ignored) Description copied from interface:VersionDetails
Returns theRestriction
objects for a segemnt scope which is to be ignored.- Specified by:
restrictionForIgnoreScope
in interfaceVersionDetails
- Parameters:
lowerBound
- artifact version, for which the unchanged segment is computedignored
- most major segment where updates are to be ignored; Optional.empty() for no ignored segments- Returns:
- Restriction object based on the arguments
-
getCurrentVersion
public final org.apache.maven.artifact.versioning.ArtifactVersion getCurrentVersion()Description copied from interface:VersionDetails
Returns the current version.- Specified by:
getCurrentVersion
in interfaceVersionDetails
- Returns:
- The current version (may be
null
).
-
setCurrentVersion
public final void setCurrentVersion(org.apache.maven.artifact.versioning.ArtifactVersion currentVersion) Description copied from interface:VersionDetails
Sets the current version.- Specified by:
setCurrentVersion
in interfaceVersionDetails
- Parameters:
currentVersion
- The new current version.
-
getCurrentVersionRange
public final org.apache.maven.artifact.versioning.VersionRange getCurrentVersionRange()Description copied from interface:VersionDetails
Returns the current version range (may benull
)- Specified by:
getCurrentVersionRange
in interfaceVersionDetails
- Returns:
- current version range (may be
null
)
-
setCurrentVersionRange
public final void setCurrentVersionRange(org.apache.maven.artifact.versioning.VersionRange versionRange) Description copied from interface:VersionDetails
Sets the current version range (may benull
)- Specified by:
setCurrentVersionRange
in interfaceVersionDetails
- Parameters:
versionRange
- version range to set (may benull
)
-
setCurrentVersion
Description copied from interface:VersionDetails
Sets the current version.- Specified by:
setCurrentVersion
in interfaceVersionDetails
- Parameters:
currentVersion
- The new current version.
-
getVersions
public final org.apache.maven.artifact.versioning.ArtifactVersion[] getVersions(org.apache.maven.artifact.versioning.VersionRange versionRange, boolean includeSnapshots) Description copied from interface:VersionDetails
Returns all available versions within the specified version range.- Specified by:
getVersions
in interfaceVersionDetails
- Parameters:
versionRange
- The version range within which the version must exist.includeSnapshots
-true
if snapshots are to be included.- Returns:
- all available versions within the specified version range.
-
getNewestVersion
public final org.apache.maven.artifact.versioning.ArtifactVersion getNewestVersion(org.apache.maven.artifact.versioning.VersionRange versionRange, org.apache.maven.artifact.versioning.Restriction restriction, boolean includeSnapshots) Description copied from interface:VersionDetails
Returns the latest version newer than the specified current version, but less than the specified upper bound ornull
if no such version exists.- Specified by:
getNewestVersion
in interfaceVersionDetails
- Parameters:
versionRange
- The version range within which the version must exist wherenull
imples[,)
.restriction
- version criteria.includeSnapshots
-true
if snapshots are to be included.- Returns:
- the latest version between lowerBound and upperBound or
null
if no version is available.
-
getNewestVersion
public final org.apache.maven.artifact.versioning.ArtifactVersion getNewestVersion(org.apache.maven.artifact.versioning.VersionRange versionRange, org.apache.maven.artifact.versioning.Restriction restriction, boolean includeSnapshots, boolean allowDowngrade) Description copied from interface:VersionDetails
Returns the latest version given the version range, restricition, whether to include snapshots and/or allow downgrades, ornull
if no such version exists.- Specified by:
getNewestVersion
in interfaceVersionDetails
- Parameters:
versionRange
- range to look for the versionsrestriction
- restriction restricting the version lookupincludeSnapshots
-true
if snapshots are to be included.allowDowngrade
- whether downgrades are allowed- Returns:
- the latest version satisfying the conditions or
null
if no version is available.
-
getNewestVersion
public final org.apache.maven.artifact.versioning.ArtifactVersion getNewestVersion(org.apache.maven.artifact.versioning.Restriction restriction, boolean includeSnapshots) Description copied from interface:VersionDetails
Returns the latest version newer than the specified current version, but less than the specified upper bound ornull
if no such version exists.- Specified by:
getNewestVersion
in interfaceVersionDetails
- Parameters:
restriction
- version criteria.includeSnapshots
-true
if snapshots are to be included.- Returns:
- the latest version between lowerBound and upperBound or
null
if no version is available.
-
getNewestVersion
public final org.apache.maven.artifact.versioning.ArtifactVersion getNewestVersion(org.apache.maven.artifact.versioning.VersionRange versionRange, boolean includeSnapshots) Description copied from interface:VersionDetails
Returns the latest version within the specified version range ornull
if no such version exists.- Specified by:
getNewestVersion
in interfaceVersionDetails
- Parameters:
versionRange
- The version range within which the version must exist.includeSnapshots
-true
if snapshots are to be included.- Returns:
- the latest version within the version range or
null
if no version is available.
-
containsVersion
Description copied from interface:VersionDetails
Returnstrue
if the specific version is in the list of versions.- Specified by:
containsVersion
in interfaceVersionDetails
- Parameters:
version
- the specific version.- Returns:
true
if the specific version is in the list of versions.
-
getNewerVersions
public final org.apache.maven.artifact.versioning.ArtifactVersion[] getNewerVersions(String versionString, Optional<Segment> unchangedSegment, boolean includeSnapshots, boolean allowDowngrade) throws InvalidSegmentException Description copied from interface:VersionDetails
Returns an array of newer versions than the given version, given the upper bound segment and whether snapshots should be included.- Specified by:
getNewerVersions
in interfaceVersionDetails
- Parameters:
versionString
- current versionunchangedSegment
- the upper bound segment; empty() means no upper boundincludeSnapshots
- whether snapshot versions should be includedallowDowngrade
- whether to allow downgrading if the current version is a snapshots and snapshots are disallowed- Returns:
- array of newer versions fulfilling the criteria
- Throws:
InvalidSegmentException
- if the requested segment is outside the bounds (less than 1 or greater than the segment count)
-
getNewestVersion
public Optional<org.apache.maven.artifact.versioning.ArtifactVersion> getNewestVersion(String actualVersion, Optional<Segment> unchangedSegment, boolean includeSnapshots, boolean allowDowngrade) throws InvalidSegmentException Description copied from interface:VersionDetails
Returns the latest version, newer than the given version, given the upper bound segment and whether snapshots should be included.- Specified by:
getNewestVersion
in interfaceVersionDetails
- Parameters:
actualVersion
- current versionunchangedSegment
- segment that may not be changed; empty() means no upper boundincludeSnapshots
- whether snapshot versions should be includedallowDowngrade
- whether to allow downgrading if the current version is a snapshots and snapshots are disallowed- Returns:
- newer version or
Optional.empty()
if none can be found - Throws:
InvalidSegmentException
- if the requested segment is outside the bounds (less than 1 or greater than the segment count)
-
getVersions
public final org.apache.maven.artifact.versioning.ArtifactVersion[] getVersions(org.apache.maven.artifact.versioning.Restriction restriction, boolean includeSnapshots) Description copied from interface:VersionDetails
Returns all available versions within the specified bounds.- Specified by:
getVersions
in interfaceVersionDetails
- Parameters:
restriction
- version criteria.includeSnapshots
-true
if snapshots are to be included.- Returns:
- all available versions within the specified version range.
-
getVersions
public final org.apache.maven.artifact.versioning.ArtifactVersion[] getVersions(org.apache.maven.artifact.versioning.VersionRange versionRange, org.apache.maven.artifact.versioning.Restriction restriction, boolean includeSnapshots) Description copied from interface:VersionDetails
Returns all available versions within the specified bounds.- Specified by:
getVersions
in interfaceVersionDetails
- Parameters:
versionRange
- The version range within which the version must exist wherenull
imples[,)
.restriction
- version criteria.includeSnapshots
-true
if snapshots are to be included.- Returns:
- all available versions within the specified version range.
-
getNewestUpdateWithinSegment
public final org.apache.maven.artifact.versioning.ArtifactVersion getNewestUpdateWithinSegment(org.apache.maven.artifact.versioning.ArtifactVersion currentVersion, Optional<Segment> updateScope, boolean includeSnapshots) Description copied from interface:VersionDetails
Returns the newest version newer than the specified current version, but within the specified update scope ornull
if no such version exists.- Specified by:
getNewestUpdateWithinSegment
in interfaceVersionDetails
- Parameters:
currentVersion
- the lower bound ornull
if the lower limit is unbounded.updateScope
- the update scope to include.includeSnapshots
-true
if snapshots are to be included.- Returns:
- the newest version after currentVersion within the specified update scope or
null
if no version is available.
-
getAllUpdates
public final org.apache.maven.artifact.versioning.ArtifactVersion[] getAllUpdates(org.apache.maven.artifact.versioning.ArtifactVersion currentVersion, Optional<Segment> updateScope, boolean includeSnapshots) Description copied from interface:VersionDetails
Returns the all versions newer than the specified current version, but within the specified update scope.- Specified by:
getAllUpdates
in interfaceVersionDetails
- Parameters:
currentVersion
- the lower bound ornull
if the lower limit is unbounded.updateScope
- the update scope to include.includeSnapshots
-true
if snapshots are to be included.- Returns:
- the all versions after currentVersion within the specified update scope.
-
getNewestUpdateWithinSegment
public final org.apache.maven.artifact.versioning.ArtifactVersion getNewestUpdateWithinSegment(Optional<Segment> updateScope, boolean includeSnapshots) Description copied from interface:VersionDetails
Returns the newest version newer than the specified current version, only within the segment specified by
updateScope
ornull
if no such version exists.If
updateScope
isOptional.empty()
, will return all updates.- Specified by:
getNewestUpdateWithinSegment
in interfaceVersionDetails
- Parameters:
updateScope
- the update scope to include.includeSnapshots
-true
if snapshots are to be included.- Returns:
- the newest version after currentVersion within the specified update scope or
null
if no version is available.
-
getAllUpdates
public final org.apache.maven.artifact.versioning.ArtifactVersion[] getAllUpdates(Optional<Segment> updateScope, boolean includeSnapshots) Description copied from interface:VersionDetails
Returns the all versions newer than the specified current version, but within the specified update scope.- Specified by:
getAllUpdates
in interfaceVersionDetails
- Parameters:
updateScope
- the update scope to include.includeSnapshots
-true
if snapshots are to be included.- Returns:
- the all versions after currentVersion within the specified update scope.
-
getAllUpdates
public final org.apache.maven.artifact.versioning.ArtifactVersion[] getAllUpdates(boolean includeSnapshots) Description copied from interface:VersionDetails
Returns the all versions newer than the specified current version- Specified by:
getAllUpdates
in interfaceVersionDetails
- Parameters:
includeSnapshots
-true
if snapshots are to be included.- Returns:
- the all versions after currentVersion
-
getAllUpdates
public org.apache.maven.artifact.versioning.ArtifactVersion[] getAllUpdates(org.apache.maven.artifact.versioning.VersionRange versionRange, boolean includeSnapshots) Description copied from interface:VersionDetails
Returns the all versions newer than the specified current version, but within the specified update scope.- Specified by:
getAllUpdates
in interfaceVersionDetails
- Parameters:
versionRange
- the version range to include.includeSnapshots
-true
if snapshots are to be included.- Returns:
- the all versions after currentVersion within the specified update scope.
-
getLowerBound
protected Optional<String> getLowerBound(org.apache.maven.artifact.versioning.ArtifactVersion version, Optional<Segment> unchangedSegment) throws InvalidSegmentException Returns the string designation of the lower bound version based on the given artifact version and the lowest unchanged segment index (0-based); -1 means that the whole version string can be changed, implying that there is also no string designation of the lower bound version.- Parameters:
version
-ArtifactVersion
object specifying the version for which the lower bound is being computedunchangedSegment
- first segment not to be changed; empty() means anything can change- Returns:
Optional
string containing the lowest artifact version with the given segment held- Throws:
InvalidSegmentException
- if the requested segment is outside of the bounds (less than 1 or greater than the segment count)
-
isVersionInRestriction
public boolean isVersionInRestriction(org.apache.maven.artifact.versioning.Restriction restriction, org.apache.maven.artifact.versioning.ArtifactVersion candidate) Checks if the candidate version is in the range of the restriction. a custom comparator is/can be used to have milestones and rcs before final releases, which is not yet possible withRestriction.containsVersion(ArtifactVersion)
.- Parameters:
restriction
- the range to check against.candidate
- the version to check.- Returns:
- true if the candidate version is within the range of the restriction parameter.
-
getReportNewestUpdate
public final org.apache.maven.artifact.versioning.ArtifactVersion getReportNewestUpdate(Optional<Segment> updateScope, boolean includeSnapshots) Returns the latest version newer than the specified current version, and within the specified update scope, ornull
if no such version exists.- Parameters:
updateScope
- the scope of updates to include.includeSnapshots
- whether snapshots should be included- Returns:
- the newest version after currentVersion within the specified update scope,
or
null
if no version is available.
-
getReportUpdates
public final org.apache.maven.artifact.versioning.ArtifactVersion[] getReportUpdates(Optional<Segment> updateScope, boolean includeSnapshots) Returns all versions newer than the specified current version, and within the specified update scope.- Parameters:
updateScope
- the scope of updates to include.includeSnapshots
- whether snapshots should be included- Returns:
- all versions after currentVersion within the specified update scope.
-