Class VersionSpec
java.lang.Object
com.dua3.gradle.jdkprovider.types.VersionSpec
Represents a version specification with a range defined by minimum and maximum versions.
This class allows specifying whether the boundaries of the range are inclusive or exclusive.
It provides utility methods for common version specifications, such as the latest version,
any version, or a specific version.
-
Method Summary
Modifier and TypeMethodDescriptionstatic VersionSpecany()Creates aVersionSpecinstance that matches any version.static VersionSpeccurrent()Retrieves the current runtime version and constructs a VersionSpec object representing the major, minor, patch, and build versions.booleaninthashCode()booleanDetermines if this instance refers to a fixed feature only, i.e., represents a single Java feature version with no interim, update, etc fields set.static VersionSpeclatest()Creates aVersionSpecinstance representing the latest version.static VersionSpecReturns aVersionSpecinstance representing the latest Long-Term Support (LTS) version.booleanDetermines if the specified runtime version falls within the range defined by the currentVersionSpecinstance.min()Retrieves the minimum runtime version specified by thisVersionSpec.static VersionSpecCreates aVersionSpecinstance based on the specified runtime version.static VersionSpecParses a string representation of a version specification.toString()
-
Method Details
-
toString
-
of
Creates aVersionSpecinstance based on the specified runtime version. The resultingVersionSpecincludes the given version, the next version, and the string representation of the version.- Parameters:
v- theRuntime.Versionobject representing the version to base theVersionSpecon- Returns:
- a
VersionSpecinstance constructed from the specified runtime version
-
current
Retrieves the current runtime version and constructs a VersionSpec object representing the major, minor, patch, and build versions.- Returns:
- a VersionSpec object representing the current runtime version, with the feature version as the major, the interim version as the minor, the update version as the patch, and the build version as the build.
-
latest
Creates aVersionSpecinstance representing the latest version. The latest version is defined as having the maximum possible major version value, with minor, patch, and build versions unspecified.- Returns:
- a
VersionSpecinstance representing the latest version.
-
latestLts
Returns aVersionSpecinstance representing the latest Long-Term Support (LTS) version. The latest LTS version is defined as the most recent version officially designated as LTS.- Returns:
- a
VersionSpecinstance representing the latest LTS version.
-
any
Creates aVersionSpecinstance that matches any version.- Returns:
- a
VersionSpecinstance representing any version.
-
parse
Parses a string representation of a version specification.Supported formats:
- "any": matches any version
- "latest": matches the latest version
- "latest_lts": matches the latest LTS version
- "X.Y.Z": matches a specific version
- "X..Y": matches versions from X to Y (inclusive)
- "X..<Y": matches versions from X (inclusive) to Y (exclusive)
- ">X..Y": matches versions from X (exclusive) to Y (inclusive)
- ">X..<Y": matches versions from X (exclusive) to Y (exclusive)
- "<=X": matches versions up to and including X
- "<X": matches versions less than X
- ">=X": matches versions from X onwards
- ">X": matches versions greater than X
- Parameters:
s- the string to parse- Returns:
- a VersionSpec object representing the parsed specification
- Throws:
IllegalArgumentException- if the string cannot be parsed
-
isFixedFeature
public boolean isFixedFeature()Determines if this instance refers to a fixed feature only, i.e., represents a single Java feature version with no interim, update, etc fields set.- Returns:
trueif this instances refers to a single Java feature version, otherwisefalse.
-
matches
Determines if the specified runtime version falls within the range defined by the currentVersionSpecinstance.- Parameters:
v- theRuntime.Versionobject to check against the version range- Returns:
trueif the specified version is greater than or equal to the minimum version and less than the maximum version;falseotherwise
-
min
Retrieves the minimum runtime version specified by thisVersionSpec.- Returns:
- the minimum runtime version
-
equals
-
hashCode
public int hashCode()
-