Class VersionRange

java.lang.Object
ai.djl.repository.VersionRange

public final class VersionRange extends Object
A VersionRange is a set of Restrictions that match some Versions.

A VersionRange should be constructed using parse(String). The format used by the version ranges matches the maven version range syntax.

  • Method Details

    • getRecommendedVersion

      public Version getRecommendedVersion()
      Returns the recommended version in the range.
      Returns:
      the recommended version in the range
    • getRestrictions

      public List<ai.djl.repository.Restriction> getRestrictions()
      Returns the restrictions that compose the range.
      Returns:
      the restrictions that compose the range
    • parse

      public static VersionRange parse(String spec)
      Creates a new version range from a string version range.
      Parameters:
      spec - the string version range
      Returns:
      the VersionRange
    • matches

      public List<Artifact> matches(List<Artifact> artifacts)
      Filters the provided artifacts to those that match the version range.
      Parameters:
      artifacts - the artifacts to filter
      Returns:
      the filtered artifacts
    • contains

      public boolean contains(Version version)
      Returns true if a version falls within this range.
      Parameters:
      version - the version to test
      Returns:
      true if the version falls within this range
    • contains

      public boolean contains(Artifact artifact)
      Returns true if the artifact's version falls within this range.
      Parameters:
      artifact - the artifact to test
      Returns:
      true if the artifact's version falls within this range
    • toString

      public String toString()
      Overrides:
      toString in class Object