Class VersionRange


  • public final class VersionRange
    extends java.lang.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 Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean contains​(Artifact artifact)
      Returns true if the artifact's version falls within this range.
      boolean contains​(Version version)
      Returns true if a version falls within this range.
      Version getRecommendedVersion()
      Returns the recommended version in the range.
      java.util.List<ai.djl.repository.Restriction> getRestrictions()
      Returns the restrictions that compose the range.
      java.util.List<Artifact> matches​(java.util.List<Artifact> artifacts)
      Filters the provided artifacts to those that match the version range.
      static VersionRange parse​(java.lang.String spec)
      Creates a new version range from a string version range.
      java.lang.String toString()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Method Detail

      • getRecommendedVersion

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

        public java.util.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​(java.lang.String spec)
        Creates a new version range from a string version range.
        Parameters:
        spec - the string version range
        Returns:
        the VersionRange
      • matches

        public java.util.List<Artifact> matches​(java.util.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 java.lang.String toString()
        Overrides:
        toString in class java.lang.Object