Class Version.Builder

java.lang.Object
com.github.zafarkhaja.semver.Version.Builder
Enclosing class:
Version

public static class Version.Builder extends Object
A mutable builder for the immutable Version class.
  • Field Details

    • normal

      private String normal
      The normal version string.
    • preRelease

      private String preRelease
      The pre-release version string.
    • build

      private String build
      The build metadata string.
  • Constructor Details

    • Builder

      public Builder()
      Constructs a Builder instance.
    • Builder

      public Builder(String normal)
      Constructs a Builder instance with the string representation of the normal version.
      Parameters:
      normal - the string representation of the normal version
  • Method Details

    • setNormalVersion

      public Version.Builder setNormalVersion(String normal)
      Sets the normal version.
      Parameters:
      normal - the string representation of the normal version
      Returns:
      this builder instance
    • setPreReleaseVersion

      public Version.Builder setPreReleaseVersion(String preRelease)
      Sets the pre-release version.
      Parameters:
      preRelease - the string representation of the pre-release version
      Returns:
      this builder instance
    • setBuildMetadata

      public Version.Builder setBuildMetadata(String build)
      Sets the build metadata.
      Parameters:
      build - the string representation of the build metadata
      Returns:
      this builder instance
    • build

      public Version build()
      Builds a Version object.
      Returns:
      a newly built Version instance
      Throws:
      ParseException - when invalid version string is provided
      UnexpectedCharacterException - is a special case of ParseException
    • isFilled

      private boolean isFilled(String str)
      Checks if a string has a usable value.
      Parameters:
      str - the string to check
      Returns:
      true if the string is filled or false otherwise