Class Versions


  • public final class Versions
    extends java.lang.Object
    Helper class for constructing Version and VersionRange literals.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static @NotNull Version getVersion​(int major, int minor, int patch)
      Constructs a new version from the provided values.
      static @NotNull Version getVersion​(@NotNull java.math.BigInteger major, @NotNull java.math.BigInteger minor, @NotNull java.math.BigInteger patch)
      Constructs a new version from the provided values.
      static @NotNull Version getVersion​(@NotNull java.math.BigInteger major, @NotNull java.math.BigInteger minor, @NotNull java.math.BigInteger patch, @NotNull BuildMetadata buildMetadata)
      Constructs a new version from the provided values.
      static @NotNull Version getVersion​(@NotNull java.math.BigInteger major, @NotNull java.math.BigInteger minor, @NotNull java.math.BigInteger patch, @NotNull PreRelease preRelease)
      Constructs a new version from the provided values.
      static @NotNull Version getVersion​(@NotNull java.math.BigInteger major, @NotNull java.math.BigInteger minor, @NotNull java.math.BigInteger patch, @NotNull PreRelease preRelease, @NotNull BuildMetadata buildMetadata)
      Constructs a new version from the provided values.
      static @NotNull VersionRange getVersionRange​(@Nullable Version startVersion, boolean startInclusive, @Nullable Version endVersion, boolean endInclusive)
      Constructs a new version range from the provided values.
      static @NotNull Version parseVersion​(@NotNull java.lang.String versionString)
      Parses a version from the provided string, according to the semver spec as listed in VersionParser
      static @NotNull Version parseVersion​(@NotNull java.lang.String coreVersion, @Nullable java.lang.String preReleaseVersion, @Nullable java.lang.String buildMetadataVersion)
      Parses a version from the provided coreVersion, preReleaseVersion, and buildMetadataVersion, according to the semver spec as listed in VersionParser.
      static @NotNull VersionRange parseVersionRange​(@NotNull java.lang.String versionString)
      Parses a VersionRange from the provided string, according to the specification described in VersionRangeParser.
      • Methods inherited from class java.lang.Object

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

      • getVersion

        @NotNull
        @Contract(value="_, _, _ -> new",
                  pure=true)
        public static @NotNull Version getVersion​(int major,
                                                  int minor,
                                                  int patch)
        Constructs a new version from the provided values.
        Parameters:
        major - The major version.
        minor - The minor version.
        patch - The patch version.
        Returns:
        The new version.
      • getVersion

        @NotNull
        @Contract(value="_, _, _ -> new",
                  pure=true)
        public static @NotNull Version getVersion​(@NotNull
                                                  @NotNull java.math.BigInteger major,
                                                  @NotNull
                                                  @NotNull java.math.BigInteger minor,
                                                  @NotNull
                                                  @NotNull java.math.BigInteger patch)
        Constructs a new version from the provided values.
        Parameters:
        major - The major version.
        minor - The minor version.
        patch - The patch version.
        Returns:
        The new version.
      • getVersion

        @NotNull
        @Contract(value="_, _, _, _ -> new",
                  pure=true)
        public static @NotNull Version getVersion​(@NotNull
                                                  @NotNull java.math.BigInteger major,
                                                  @NotNull
                                                  @NotNull java.math.BigInteger minor,
                                                  @NotNull
                                                  @NotNull java.math.BigInteger patch,
                                                  @NotNull
                                                  @NotNull PreRelease preRelease)
        Constructs a new version from the provided values.
        Parameters:
        major - The major version.
        minor - The minor version.
        patch - The patch version.
        preRelease - The pre-release version.
        Returns:
        The new version.
      • getVersion

        @NotNull
        @Contract(value="_, _, _, _ -> new",
                  pure=true)
        public static @NotNull Version getVersion​(@NotNull
                                                  @NotNull java.math.BigInteger major,
                                                  @NotNull
                                                  @NotNull java.math.BigInteger minor,
                                                  @NotNull
                                                  @NotNull java.math.BigInteger patch,
                                                  @NotNull
                                                  @NotNull BuildMetadata buildMetadata)
        Constructs a new version from the provided values.
        Parameters:
        major - The major version.
        minor - The minor version.
        patch - The patch version.
        buildMetadata - The build metadata.
        Returns:
        The new version.
      • getVersion

        @NotNull
        @Contract(value="_, _, _, _, _ -> new",
                  pure=true)
        public static @NotNull Version getVersion​(@NotNull
                                                  @NotNull java.math.BigInteger major,
                                                  @NotNull
                                                  @NotNull java.math.BigInteger minor,
                                                  @NotNull
                                                  @NotNull java.math.BigInteger patch,
                                                  @NotNull
                                                  @NotNull PreRelease preRelease,
                                                  @NotNull
                                                  @NotNull BuildMetadata buildMetadata)
        Constructs a new version from the provided values.
        Parameters:
        major - The major version.
        minor - The minor version.
        patch - The patch version.
        preRelease - The pre-release version.
        buildMetadata - The build metadata.
        Returns:
        The new version.
      • parseVersion

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public static @NotNull Version parseVersion​(@NotNull
                                                    @NotNull java.lang.String versionString)
                                             throws ParseException
        Parses a version from the provided string, according to the semver spec as listed in VersionParser
        Parameters:
        versionString - The version string to parse.
        Returns:
        The parsed version.
        Throws:
        ParseException - If an exception occurred during the parsing of the version. If taking user input, the message from this exception is highly useful and should be returned to the user.@see Versions#parseVersion(String)
        See Also:
        VersionParser
      • parseVersion

        @NotNull
        @Contract(value="_, _, _ -> new",
                  pure=true)
        public static @NotNull Version parseVersion​(@NotNull
                                                    @NotNull java.lang.String coreVersion,
                                                    @Nullable
                                                    @Nullable java.lang.String preReleaseVersion,
                                                    @Nullable
                                                    @Nullable java.lang.String buildMetadataVersion)
                                             throws ParseException
        Parses a version from the provided coreVersion, preReleaseVersion, and buildMetadataVersion, according to the semver spec as listed in VersionParser.
        Parameters:
        coreVersion - The core version.
        preReleaseVersion - The pre-release version.
        buildMetadataVersion - The build metadata.
        Returns:
        The parsed version.
        Throws:
        ParseException - If an exception occurred during the parsing of the version. If taking user input, the message from this exception is highly useful and should be returned to the user.@see Versions#parseVersion(String)
        See Also:
        VersionParser
      • parseVersionRange

        @NotNull
        @Contract(value="_ -> new",
                  pure=true)
        public static @NotNull VersionRange parseVersionRange​(@NotNull
                                                              @NotNull java.lang.String versionString)
                                                       throws ParseException
        Parses a VersionRange from the provided string, according to the specification described in VersionRangeParser.
        Parameters:
        versionString - The version range string to parse.
        Returns:
        The parsed version range.
        Throws:
        ParseException - If an exception occurred during the parsing of the version. If taking user input, the message from this exception is highly useful and should be returned to the user.@see Versions#parseVersion(String)
        See Also:
        VersionRangeParser
      • getVersionRange

        @NotNull
        @Contract(value="_, _, _, _ -> new",
                  pure=true)
        public static @NotNull VersionRange getVersionRange​(@Nullable
                                                            @Nullable Version startVersion,
                                                            boolean startInclusive,
                                                            @Nullable
                                                            @Nullable Version endVersion,
                                                            boolean endInclusive)
        Constructs a new version range from the provided values.
        Parameters:
        startVersion - The starting version. Use null if this has no lower bound.
        startInclusive - true if the starting version is inclusive, false if the starting version is exclusive.
        endVersion - The ending version. Use null if this has no upper bound.
        endInclusive - true if the ending version is inclusive, false if the ending version is exclusive.
        Returns:
        The version range from the provided values.
        See Also:
        VersionRange(ca.solostudios.strata.version.Version, boolean, ca.solostudios.strata.version.Version, boolean)