Class BoundArtifactVersion

java.lang.Object
org.codehaus.mojo.versions.ordering.BoundArtifactVersion
All Implemented Interfaces:
Comparable<org.apache.maven.artifact.versioning.ArtifactVersion>, org.apache.maven.artifact.versioning.ArtifactVersion

public class BoundArtifactVersion extends Object implements org.apache.maven.artifact.versioning.ArtifactVersion

Represents an immutable artifact version with all segments major to the given segment held in place. It can be thought of as an artifact having +∞ as its upper bound on all segments minor to the held segment.

For example:

A BoundArtifactVersion of [1.2.3-2, INCREMENTAL] can be seen as 1.2.+∞ and will be greater than all versions matching the 1.2.* pattern.

A BoundArtifactVersion of [1.2.3-2, SUBINCREMENTAL] will be greater * than all versions matching the 1.2.3-2.* pattern.

When compared to another artifact versions, this results with the other object with the segment versions up to the held segment being equal, always comparing lower than this object.

This is particularly helpful for -SNAPSHOT and other versions with qualifiers, which are lower than version 0 in the Maven versioning system.

  • Constructor Details

    • BoundArtifactVersion

      public BoundArtifactVersion(String artifactVersion, Segment segment)
      Constructs the instance given the version in a text format.
      Parameters:
      artifactVersion - lower bound
      segment - most major segment that can change, i.e. not held in place
    • BoundArtifactVersion

      public BoundArtifactVersion(org.apache.maven.artifact.versioning.ArtifactVersion artifactVersion, Segment segment)
      Constructs the instance given a instance
      Parameters:
      artifactVersion - lower bound
      segment - most major segment that can change, i.e. not held in place
  • Method Details

    • getSegment

      public Segment getSegment()
      Returns the most major segment that can change. All segments that are more major than this one are held in place.
      Returns:
      segment that can change
    • compareTo

      public int compareTo(org.apache.maven.artifact.versioning.ArtifactVersion other)
      Specified by:
      compareTo in interface Comparable<org.apache.maven.artifact.versioning.ArtifactVersion>
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getMajorVersion

      public int getMajorVersion()
      Specified by:
      getMajorVersion in interface org.apache.maven.artifact.versioning.ArtifactVersion
    • getMinorVersion

      public int getMinorVersion()
      Specified by:
      getMinorVersion in interface org.apache.maven.artifact.versioning.ArtifactVersion
    • getIncrementalVersion

      public int getIncrementalVersion()
      Specified by:
      getIncrementalVersion in interface org.apache.maven.artifact.versioning.ArtifactVersion
    • getBuildNumber

      public int getBuildNumber()
      Specified by:
      getBuildNumber in interface org.apache.maven.artifact.versioning.ArtifactVersion
    • getQualifier

      public String getQualifier()
      Specified by:
      getQualifier in interface org.apache.maven.artifact.versioning.ArtifactVersion
    • parseVersion

      @Deprecated public void parseVersion(String version)
      Deprecated.
      do not use: this method would mutate the state and therefore is illegal to use
      Specified by:
      parseVersion in interface org.apache.maven.artifact.versioning.ArtifactVersion
      Throws:
      UnsupportedOperationException - thrown if the method is called
    • toString

      public String toString()
      Quasi-contract: toString() must produce the textual representation of the version, without any additional items, this is required by the implementation of NumericVersionComparator.
      Overrides:
      toString in class Object