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 booleancontainsVersion(String version) Returnstrueif 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.ArtifactVersionReturns the current version.final org.apache.maven.artifact.versioning.VersionRangeReturns the current version range (may benull)protected org.apache.maven.artifact.versioning.ArtifactVersiongetHighestLowerBound(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.ArtifactVersiongetNewestUpdateWithinSegment(Optional<Segment> updateScope, boolean includeSnapshots) Returns the newest version newer than the specified current version, only within the segment specified byupdateScopeornullif no such version exists.final org.apache.maven.artifact.versioning.ArtifactVersiongetNewestUpdateWithinSegment(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 ornullif 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.ArtifactVersiongetNewestVersion(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 ornullif no such version exists.final org.apache.maven.artifact.versioning.ArtifactVersiongetNewestVersion(org.apache.maven.artifact.versioning.VersionRange versionRange, boolean includeSnapshots) Returns the latest version within the specified version range ornullif no such version exists.final org.apache.maven.artifact.versioning.ArtifactVersiongetNewestVersion(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 ornullif no such version exists.final org.apache.maven.artifact.versioning.ArtifactVersiongetNewestVersion(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, ornullif no such version exists.final org.apache.maven.artifact.versioning.ArtifactVersiongetReportNewestUpdate(Optional<Segment> updateScope, boolean includeSnapshots) Returns the latest version newer than the specified current version, and within the specified update scope, ornullif 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.booleanisVersionInRestriction(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.RestrictionrestrictionForIgnoreScope(org.apache.maven.artifact.versioning.ArtifactVersion lowerBound, Optional<Segment> ignored) Returns theRestrictionobjects for a segemnt scope which is to be ignored.org.apache.maven.artifact.versioning.RestrictionrestrictionForSelectedSegment(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.RestrictionrestrictionForUnchangedSegment(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 voidsetCurrentVersion(String currentVersion) Sets the current version.final voidsetCurrentVersion(org.apache.maven.artifact.versioning.ArtifactVersion currentVersion) Sets the current version.final voidsetCurrentVersionRange(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, waitMethods 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:VersionDetailsReturns 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:
restrictionForSelectedSegmentin 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:VersionDetailsReturns 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:
restrictionForUnchangedSegmentin 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:VersionDetailsReturns theRestrictionobjects for a segemnt scope which is to be ignored.- Specified by:
restrictionForIgnoreScopein 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:VersionDetailsReturns the current version.- Specified by:
getCurrentVersionin interfaceVersionDetails- Returns:
- The current version (may be
null).
-
setCurrentVersion
public final void setCurrentVersion(org.apache.maven.artifact.versioning.ArtifactVersion currentVersion) Description copied from interface:VersionDetailsSets the current version.- Specified by:
setCurrentVersionin interfaceVersionDetails- Parameters:
currentVersion- The new current version.
-
getCurrentVersionRange
public final org.apache.maven.artifact.versioning.VersionRange getCurrentVersionRange()Description copied from interface:VersionDetailsReturns the current version range (may benull)- Specified by:
getCurrentVersionRangein interfaceVersionDetails- Returns:
- current version range (may be
null)
-
setCurrentVersionRange
public final void setCurrentVersionRange(org.apache.maven.artifact.versioning.VersionRange versionRange) Description copied from interface:VersionDetailsSets the current version range (may benull)- Specified by:
setCurrentVersionRangein interfaceVersionDetails- Parameters:
versionRange- version range to set (may benull)
-
setCurrentVersion
Description copied from interface:VersionDetailsSets the current version.- Specified by:
setCurrentVersionin 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:VersionDetailsReturns all available versions within the specified version range.- Specified by:
getVersionsin interfaceVersionDetails- Parameters:
versionRange- The version range within which the version must exist.includeSnapshots-trueif 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:VersionDetailsReturns the latest version newer than the specified current version, but less than the specified upper bound ornullif no such version exists.- Specified by:
getNewestVersionin interfaceVersionDetails- Parameters:
versionRange- The version range within which the version must exist wherenullimples[,).restriction- version criteria.includeSnapshots-trueif snapshots are to be included.- Returns:
- the latest version between lowerBound and upperBound or
nullif 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:VersionDetailsReturns the latest version given the version range, restricition, whether to include snapshots and/or allow downgrades, ornullif no such version exists.- Specified by:
getNewestVersionin interfaceVersionDetails- Parameters:
versionRange- range to look for the versionsrestriction- restriction restricting the version lookupincludeSnapshots-trueif snapshots are to be included.allowDowngrade- whether downgrades are allowed- Returns:
- the latest version satisfying the conditions or
nullif 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:VersionDetailsReturns the latest version newer than the specified current version, but less than the specified upper bound ornullif no such version exists.- Specified by:
getNewestVersionin interfaceVersionDetails- Parameters:
restriction- version criteria.includeSnapshots-trueif snapshots are to be included.- Returns:
- the latest version between lowerBound and upperBound or
nullif 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:VersionDetailsReturns the latest version within the specified version range ornullif no such version exists.- Specified by:
getNewestVersionin interfaceVersionDetails- Parameters:
versionRange- The version range within which the version must exist.includeSnapshots-trueif snapshots are to be included.- Returns:
- the latest version within the version range or
nullif no version is available.
-
containsVersion
Description copied from interface:VersionDetailsReturnstrueif the specific version is in the list of versions.- Specified by:
containsVersionin interfaceVersionDetails- Parameters:
version- the specific version.- Returns:
trueif 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:VersionDetailsReturns an array of newer versions than the given version, given the upper bound segment and whether snapshots should be included.- Specified by:
getNewerVersionsin 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:VersionDetailsReturns the latest version, newer than the given version, given the upper bound segment and whether snapshots should be included.- Specified by:
getNewestVersionin 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:VersionDetailsReturns all available versions within the specified bounds.- Specified by:
getVersionsin interfaceVersionDetails- Parameters:
restriction- version criteria.includeSnapshots-trueif 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:VersionDetailsReturns all available versions within the specified bounds.- Specified by:
getVersionsin interfaceVersionDetails- Parameters:
versionRange- The version range within which the version must exist wherenullimples[,).restriction- version criteria.includeSnapshots-trueif 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:VersionDetailsReturns the newest version newer than the specified current version, but within the specified update scope ornullif no such version exists.- Specified by:
getNewestUpdateWithinSegmentin interfaceVersionDetails- Parameters:
currentVersion- the lower bound ornullif the lower limit is unbounded.updateScope- the update scope to include.includeSnapshots-trueif snapshots are to be included.- Returns:
- the newest version after currentVersion within the specified update scope or
nullif 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:VersionDetailsReturns the all versions newer than the specified current version, but within the specified update scope.- Specified by:
getAllUpdatesin interfaceVersionDetails- Parameters:
currentVersion- the lower bound ornullif the lower limit is unbounded.updateScope- the update scope to include.includeSnapshots-trueif 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:VersionDetailsReturns the newest version newer than the specified current version, only within the segment specified by
updateScopeornullif no such version exists.If
updateScopeisOptional.empty(), will return all updates.- Specified by:
getNewestUpdateWithinSegmentin interfaceVersionDetails- Parameters:
updateScope- the update scope to include.includeSnapshots-trueif snapshots are to be included.- Returns:
- the newest version after currentVersion within the specified update scope or
nullif no version is available.
-
getAllUpdates
public final org.apache.maven.artifact.versioning.ArtifactVersion[] getAllUpdates(Optional<Segment> updateScope, boolean includeSnapshots) Description copied from interface:VersionDetailsReturns the all versions newer than the specified current version, but within the specified update scope.- Specified by:
getAllUpdatesin interfaceVersionDetails- Parameters:
updateScope- the update scope to include.includeSnapshots-trueif 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:VersionDetailsReturns the all versions newer than the specified current version- Specified by:
getAllUpdatesin interfaceVersionDetails- Parameters:
includeSnapshots-trueif 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:VersionDetailsReturns the all versions newer than the specified current version, but within the specified update scope.- Specified by:
getAllUpdatesin interfaceVersionDetails- Parameters:
versionRange- the version range to include.includeSnapshots-trueif 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-ArtifactVersionobject specifying the version for which the lower bound is being computedunchangedSegment- first segment not to be changed; empty() means anything can change- Returns:
Optionalstring 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, ornullif 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
nullif 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.
-