Package org.jboss.staxmapper
Class IntVersion
- java.lang.Object
-
- org.jboss.staxmapper.IntVersion
-
- All Implemented Interfaces:
Comparable<IntVersion>
public final class IntVersion extends Object implements Comparable<IntVersion>
An integer based version supporting a variable number of segments.- Author:
- Paul Ferraro
-
-
Field Summary
Fields Modifier and Type Field Description static CharSequenceDEFAULT_DELIMITER
-
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 intcompareTo(IntVersion version)booleanequals(Object object)inthashCode()intmajor()Convenience method that returns the 1st segment of this version.intmicro()Convenience method that returns the 3rd segment of this version.intminor()Convenience method that returns the 2nd segment of this version.intsegment(int index)Returns the version segment at the specified index.intsegments()Returns the number of segments with which this version was constructed, excluding any trailing zeros.IntStreamstream()Returns a stream of the segments of this version, excluding any trailing zeros.IntStreamstream(int segments)Returns a stream of the segments of this version, zero padded (or truncated) to the specified number of segments.StringtoString()Equivalent tothis.toString(this.segments())StringtoString(int segments)Prints this version using theDEFAULT_DELIMITERsegment delimiter, zero padded (or truncated) to the specified number of segments.StringtoString(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
-
-
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 tothis.segment(0).- Returns:
- the 1st segment of this version.
-
minor
public int minor()
Convenience method that returns the 2nd segment of this version. Equivalent tothis.segment(1).- Returns:
- the 2nd segment of this version.
-
micro
public int micro()
Convenience method that returns the 3rd segment of this version. Equivalent tothis.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. Usestream(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
-
compareTo
public int compareTo(IntVersion version)
- Specified by:
compareToin interfaceComparable<IntVersion>
-
toString
public String toString()
Equivalent tothis.toString(this.segments())
-
toString
public String toString(int segments)
Prints this version using theDEFAULT_DELIMITERsegment delimiter, zero padded (or truncated) to the specified number of segments. Equivalent tothis.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 representationa- version segment delimiter- Returns:
- a string representation of this version
-
-