Class SemverRange

java.lang.Object
org.opensearch.semver.SemverRange
All Implemented Interfaces:
ToXContent, ToXContentFragment

@PublicApi(since="2.13.0") public class SemverRange extends Object implements ToXContentFragment
Represents a single semver range that allows for specifying which org.opensearch.Versions satisfy the range. It is composed of a range version and a range operator. Following are the supported operators:
  • '=' Requires exact match with the range version. For example, =1.2.3 range would match only 1.2.3
  • '~' Allows for patch version variability starting from the range version. For example, ~1.2.3 range would match versions greater than or equal to 1.2.3 but less than 1.3.0
  • '^' Allows for patch and minor version variability starting from the range version. For example, ^1.2.3 range would match versions greater than or equal to 1.2.3 but less than 2.0.0
Opensearch.api:
  • Constructor Details

  • Method Details

    • fromString

      public static SemverRange fromString(String range)
      Constructs a SemverRange from its string representation.
      Parameters:
      range - given range
      Returns:
      a SemverRange
    • getRangeOperator

      public SemverRange.RangeOperator getRangeOperator()
      Return the range operator for this range.
      Returns:
      range operator
    • getRangeVersion

      public Version getRangeVersion()
      Return the version for this range.
      Returns:
      the range version
    • isSatisfiedBy

      public boolean isSatisfiedBy(String versionToEvaluate)
      Check if range is satisfied by given version string.
      Parameters:
      versionToEvaluate - version to check
      Returns:
      true if range is satisfied by version, false otherwise
    • isSatisfiedBy

      public boolean isSatisfiedBy(Version versionToEvaluate)
      Check if range is satisfied by given version.
      Parameters:
      versionToEvaluate - version to check
      Returns:
      true if range is satisfied by version, false otherwise
      See Also:
    • equals

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

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

      public String toString()
      Overrides:
      toString in class Object
    • toXContent

      public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException
      Specified by:
      toXContent in interface ToXContent
      Throws:
      IOException