Class AbstractVersionDetails

java.lang.Object
org.codehaus.mojo.versions.api.AbstractVersionDetails
All Implemented Interfaces:
VersionDetails
Direct Known Subclasses:
ArtifactVersions, PropertyVersions

public abstract class AbstractVersionDetails extends Object implements VersionDetails
Base class for VersionDetails.
Since:
1.0-beta-1
Author:
Stephen Connolly
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Returns true 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 version
    final 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 be null)
    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.
    protected Optional<String>
    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 by updateScope or null 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 or null 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 or null 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 or null 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 or null 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, or null 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, or null 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 the Restriction 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 provided unchangedSegment.
    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 be null)

    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 be null
      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 interface VersionDetails
      Parameters:
      lowerBound - artifact version, for which the unchanged segment is computed
      selectedSegment - segment, for which the restriction is to be built or Optional.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 interface VersionDetails
      Parameters:
      actualVersion - artifact version, for which the unchanged segment is computed
      unchangedSegment - segment, which should not be changed or Optional.empty() for no restriction
      allowDowngrade - 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 the Restriction objects for a segemnt scope which is to be ignored.
      Specified by:
      restrictionForIgnoreScope in interface VersionDetails
      Parameters:
      lowerBound - artifact version, for which the unchanged segment is computed
      ignored - 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 interface VersionDetails
      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 interface VersionDetails
      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 be null)
      Specified by:
      getCurrentVersionRange in interface VersionDetails
      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 be null)
      Specified by:
      setCurrentVersionRange in interface VersionDetails
      Parameters:
      versionRange - version range to set (may be null)
    • setCurrentVersion

      public final void setCurrentVersion(String currentVersion)
      Description copied from interface: VersionDetails
      Sets the current version.
      Specified by:
      setCurrentVersion in interface VersionDetails
      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 interface VersionDetails
      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 or null if no such version exists.
      Specified by:
      getNewestVersion in interface VersionDetails
      Parameters:
      versionRange - The version range within which the version must exist where null 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, or null if no such version exists.
      Specified by:
      getNewestVersion in interface VersionDetails
      Parameters:
      versionRange - range to look for the versions
      restriction - restriction restricting the version lookup
      includeSnapshots - 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 or null if no such version exists.
      Specified by:
      getNewestVersion in interface VersionDetails
      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 or null if no such version exists.
      Specified by:
      getNewestVersion in interface VersionDetails
      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

      public final boolean containsVersion(String version)
      Description copied from interface: VersionDetails
      Returns true if the specific version is in the list of versions.
      Specified by:
      containsVersion in interface VersionDetails
      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 interface VersionDetails
      Parameters:
      versionString - current version
      unchangedSegment - the upper bound segment; empty() means no upper bound
      includeSnapshots - whether snapshot versions should be included
      allowDowngrade - 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 interface VersionDetails
      Parameters:
      actualVersion - current version
      unchangedSegment - segment that may not be changed; empty() means no upper bound
      includeSnapshots - whether snapshot versions should be included
      allowDowngrade - 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 interface VersionDetails
      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 interface VersionDetails
      Parameters:
      versionRange - The version range within which the version must exist where null 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 or null if no such version exists.
      Specified by:
      getNewestUpdateWithinSegment in interface VersionDetails
      Parameters:
      currentVersion - the lower bound or null 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 interface VersionDetails
      Parameters:
      currentVersion - the lower bound or null 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 or null if no such version exists.

      If updateScope is Optional.empty(), will return all updates.

      Specified by:
      getNewestUpdateWithinSegment in interface VersionDetails
      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 interface VersionDetails
      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 interface VersionDetails
      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 interface VersionDetails
      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 computed
      unchangedSegment - 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 with Restriction.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, or null 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.