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
    Retrieves the current version.
    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 version, boolean includeSnapshots)
    Returns an array of newer versions than the given version, given whether snapshots should be included.
    final org.apache.maven.artifact.versioning.ArtifactVersion[]
    getNewerVersions(String version, Optional<Segment> upperBoundSegment, boolean includeSnapshots)
    Deprecated.
    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
    getNewestUpdate(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.
    final org.apache.maven.artifact.versioning.ArtifactVersion
    getNewestUpdate(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 versionString, Optional<Segment> upperBoundSegment, 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.ArtifactVersion lowerBound, org.apache.maven.artifact.versioning.ArtifactVersion upperBound, boolean includeSnapshots)
    Returns the latest version newer than the specified lowerBound, 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.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.
    final org.apache.maven.artifact.versioning.ArtifactVersion[]
    getVersions(org.apache.maven.artifact.versioning.ArtifactVersion lowerBound, org.apache.maven.artifact.versioning.ArtifactVersion upperBound, boolean includeSnapshots)
    Returns all available versions within the specified bounds.
    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.
    final boolean
    Returns true if and only if getCurrentVersion() != null.
    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
    Returns a Restriction object for computing version upgrades with the given segment allowing updates, with all more major segments locked in place.
    org.apache.maven.artifact.versioning.Restriction
    Returns the Restriction objects for a segemnt scope which is to be ignored.
    final void
    setCurrentVersion(String currentVersion)
    Sets the current version.
    final void
    setCurrentVersion(org.apache.maven.artifact.versioning.ArtifactVersion currentVersion)
    Sets the current version.

    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

    • restrictionFor

      public org.apache.maven.artifact.versioning.Restriction restrictionFor(Optional<Segment> scope) throws InvalidSegmentException
      Description copied from interface: VersionDetails

      Returns a Restriction object for computing version upgrades with the given segment allowing updates, with all more major segments locked in place.

      The resulting restriction could be thought of as one retaining the versions on positions up to the held position, the position right after the position held in place will be incremented by one, and on all positions which are more minor than that, the range would contain -∞ for the bottom bound and +∞ for the above bound.

      This will allow matching the required versions while not matching versions which are considered inferior than the zeroth version, i.e. versions with a qualifier.

      Specified by:
      restrictionFor in interface VersionDetails
      Parameters:
      scope - most major segment where updates are allowed Optional.empty() for no restriction
      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(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:
      ignored - most major segment where updates are to be ignored; Optional.empty() for no ignored segments
      Returns:
      Restriction object based on the arguments
    • isCurrentVersionDefined

      public final boolean isCurrentVersionDefined()
      Description copied from interface: VersionDetails
      Returns true if and only if getCurrentVersion() != null.
      Specified by:
      isCurrentVersionDefined in interface VersionDetails
      Returns:
      true if and only if getCurrentVersion() != null.
    • getCurrentVersion

      public final org.apache.maven.artifact.versioning.ArtifactVersion getCurrentVersion()
      Description copied from interface: VersionDetails
      Retrieves 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.
    • 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.
    • getVersions

      public final org.apache.maven.artifact.versioning.ArtifactVersion[] getVersions(org.apache.maven.artifact.versioning.ArtifactVersion lowerBound, org.apache.maven.artifact.versioning.ArtifactVersion upperBound, boolean includeSnapshots)
      Description copied from interface: VersionDetails
      Returns all available versions within the specified bounds.
      Specified by:
      getVersions in interface VersionDetails
      Parameters:
      lowerBound - the lower bound or null if the lower limit is unbounded.
      upperBound - the upper bound or null if the upper limit is unbounded.
      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.ArtifactVersion lowerBound, org.apache.maven.artifact.versioning.ArtifactVersion upperBound, boolean includeSnapshots)
      Description copied from interface: VersionDetails
      Returns the latest version newer than the specified lowerBound, but less than the specified upper bound or null if no such version exists.
      Specified by:
      getNewestVersion in interface VersionDetails
      Parameters:
      lowerBound - the lower bound or null if the lower limit is unbounded.
      upperBound - the upper bound or null if the upper limit is unbounded.
      includeSnapshots - true if snapshots are to be included.
      Returns:
      the latest version between currentVersion 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)
      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 version, boolean includeSnapshots)
      Description copied from interface: VersionDetails
      Returns an array of newer versions than the given version, given whether snapshots should be included.
      Specified by:
      getNewerVersions in interface VersionDetails
      Parameters:
      version - current version in String format
      includeSnapshots - whether snapshot versions should be included
      Returns:
      array of newer versions fulfilling the criteria
    • getNewerVersions

      @Deprecated public final org.apache.maven.artifact.versioning.ArtifactVersion[] getNewerVersions(String version, Optional<Segment> upperBoundSegment, boolean includeSnapshots) throws InvalidSegmentException
      Deprecated.
      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:
      version - current version
      upperBoundSegment - the upper bound segment; empty() means no upper bound
      includeSnapshots - whether snapshot versions should be included
      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)
    • 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 versionString, Optional<Segment> upperBoundSegment, 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:
      versionString - current version
      upperBoundSegment - 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:
      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.
    • getNewestUpdate

      public final org.apache.maven.artifact.versioning.ArtifactVersion getNewestUpdate(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:
      getNewestUpdate 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.
    • getNewestUpdate

      public final org.apache.maven.artifact.versioning.ArtifactVersion getNewestUpdate(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:
      getNewestUpdate 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.