Class IntVersion

    • Constructor Summary

      Constructors 
      Constructor Description
      IntVersion​(int... segments)
      Constructs a version with a variable number of segments.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareTo​(IntVersion version)  
      boolean equals​(Object object)  
      int hashCode()  
      int major()
      Convenience method that returns the 1st segment of this version.
      int micro()
      Convenience method that returns the 3rd segment of this version.
      int minor()
      Convenience method that returns the 2nd segment of this version.
      int segment​(int index)
      Returns the version segment at the specified index.
      int segments()
      Returns the number of segments with which this version was constructed, excluding any trailing zeros.
      IntStream stream()
      Returns a stream of the segments of this version, excluding any trailing zeros.
      IntStream stream​(int segments)
      Returns a stream of the segments of this version, zero padded (or truncated) to the specified number of segments.
      String toString()
      Equivalent to this.toString(this.segments())
      String toString​(int segments)
      Prints this version using the DEFAULT_DELIMITER segment delimiter, zero padded (or truncated) to the specified number of segments.
      String toString​(int segments, CharSequence delimiter)
      Prints this version using the specified segment delimiter, zero padded (or truncated) to the specified number of segments.
    • Field Detail

      • DEFAULT_DELIMITER

        public static final CharSequence DEFAULT_DELIMITER
    • Constructor Detail

      • IntVersion

        public IntVersion​(int... segments)
        Constructs a version with a variable number of segments.
        Parameters:
        segments - the version segments
    • Method Detail

      • segment

        public int segment​(int index)
        Returns the version segment at the specified index.
        Parameters:
        index - a version segment index
        Returns:
        the version segment at the specified index, or 0, if the index is out-of-bounds.
        Throws:
        ArrayIndexOutOfBoundsException - if index is negative
      • segments

        public int segments()
        Returns the number of segments with which this version was constructed, excluding any trailing zeros.
        Returns:
        the number of segments with which this version was constructed, excluding any trailing zeros.
      • major

        public int major()
        Convenience method that returns the 1st segment of this version. Equivalent to this.segment(0).
        Returns:
        the 1st segment of this version.
      • minor

        public int minor()
        Convenience method that returns the 2nd segment of this version. Equivalent to this.segment(1).
        Returns:
        the 2nd segment of this version.
      • micro

        public int micro()
        Convenience method that returns the 3rd segment of this version. Equivalent to this.segment(2).
        Returns:
        the 3rd segment of this version.
      • stream

        public IntStream stream()
        Returns a stream of the segments of this version, excluding any trailing zeros. Use stream(int) to obtain a stream of a specific length.
        Returns:
        a stream of version segments, excluding any trailing zeros.
      • stream

        public IntStream stream​(int segments)
        Returns a stream of the segments of this version, zero padded (or truncated) to the specified number of segments.
        Returns:
        a stream of version segments
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • toString

        public String toString()
        Equivalent to this.toString(this.segments())
        Overrides:
        toString in class Object
      • toString

        public String toString​(int segments)
        Prints this version using the DEFAULT_DELIMITER segment delimiter, zero padded (or truncated) to the specified number of segments. Equivalent to this.toString(segments, DEFAULT_DELIMITER)
        Parameters:
        the - number of segments with which to zero pad this version's string representation
        Returns:
        a string representation of this version
      • toString

        public String toString​(int segments,
                               CharSequence delimiter)
        Prints this version using the specified segment delimiter, zero padded (or truncated) to the specified number of segments.
        Parameters:
        the - number of segments with which to zero pad this version's string representation
        a - version segment delimiter
        Returns:
        a string representation of this version