Class Version.Builder

java.lang.Object
net.luis.utils.util.Version.Builder
Enclosing class:
Version

public static final class Version.Builder extends Object
This class represents a builder for a version number.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    The appendable build version number.
    private int
    The major version number.
    private int
    The minor version number.
    private int
    The patch or fix version number.
    private String
    The suffix or pre-release identifier.
    The appendable suffix version number.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Builder(int major, int minor)
    Constructs a new version builder with the given version numbers.
    The version numbers will be clamped to a minimum of 0.
    private
    Builder(int major, int minor, int patch)
    Constructs a new version builder with the given version numbers.
    The version numbers will be clamped to a minimum of 0.
  • Method Summary

    Modifier and Type
    Method
    Description
    @NotNull Version
    Builds the version with the given version numbers.
    boolean
     
    int
     
    withBuild(char separator, int version)
    Sets the build version number and the separator.
    The build version number will be clamped to a minimum of 0.
    withMajor(int major)
    Sets the major version number.
    The major version number will be clamped to a minimum of 0.
    withMinor(int minor)
    Sets the minor version number.
    The minor version number will be clamped to a minimum of 0.
    withPatch(int patch)
    Sets the patch or fix version number.
    The patch or fix version number will be clamped to a minimum of 0.
    withSuffix(@Nullable String suffix)
    Sets the suffix or pre-release identifier.
    Removes leading and trailing whitespace from the suffix.
    Recommended suffixes are 'alpha', 'beta', 'rc', 'release-candidate', 'release', and 'final'.
    withSuffixVersion(int version)
    Sets the suffix version number.
    The suffix version number will be clamped to a minimum of 0.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • major

      private int major
      The major version number.
    • minor

      private int minor
      The minor version number.
    • patch

      private int patch
      The patch or fix version number.
    • build

      private Version.AppendingVersion build
      The appendable build version number.
    • suffix

      private String suffix
      The suffix or pre-release identifier.
    • suffixVersion

      private Version.AppendingVersion suffixVersion
      The appendable suffix version number.
  • Constructor Details

    • Builder

      private Builder(int major, int minor)
      Constructs a new version builder with the given version numbers.
      The version numbers will be clamped to a minimum of 0.
      Parameters:
      major - The major version number
      minor - The minor version number
    • Builder

      private Builder(int major, int minor, int patch)
      Constructs a new version builder with the given version numbers.
      The version numbers will be clamped to a minimum of 0.
      Parameters:
      major - The major version number
      minor - The minor version number
      patch - The patch or fix version number
  • Method Details

    • withMajor

      @NotNull public @NotNull Version.Builder withMajor(int major)
      Sets the major version number.
      The major version number will be clamped to a minimum of 0.
      Parameters:
      major - The major version number
      Returns:
      This builder
    • withMinor

      @NotNull public @NotNull Version.Builder withMinor(int minor)
      Sets the minor version number.
      The minor version number will be clamped to a minimum of 0.
      Parameters:
      minor - The minor version number
      Returns:
      This builder
    • withPatch

      @NotNull public @NotNull Version.Builder withPatch(int patch)
      Sets the patch or fix version number.
      The patch or fix version number will be clamped to a minimum of 0.
      Parameters:
      patch - The patch or fix version number
      Returns:
      This builder
    • withBuild

      @NotNull public @NotNull Version.Builder withBuild(char separator, int version)
      Sets the build version number and the separator.
      The build version number will be clamped to a minimum of 0.
      Parameters:
      separator - The separator character (must be '.', '-', or 'r')
      version - The build version number
      Returns:
      This builder
      Throws:
      IllegalArgumentException - If the separator is not '.', '-', or 'r'
    • withSuffix

      @NotNull public @NotNull Version.Builder withSuffix(@Nullable @Nullable String suffix)
      Sets the suffix or pre-release identifier.
      Removes leading and trailing whitespace from the suffix.
      Recommended suffixes are 'alpha', 'beta', 'rc', 'release-candidate', 'release', and 'final'.
      Parameters:
      suffix - The suffix or pre-release identifier
      Returns:
      This builder
    • withSuffixVersion

      @NotNull public @NotNull Version.Builder withSuffixVersion(int version)
      Sets the suffix version number.
      The suffix version number will be clamped to a minimum of 0.
      Parameters:
      version - The suffix version number
      Returns:
      This builder
    • build

      @NotNull public @NotNull Version build()
      Builds the version with the given version numbers.
      Returns:
      The created version
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object