Package jenkins.plugins.nodejs.tools
Class NodeJSVersionRange
java.lang.Object
jenkins.plugins.nodejs.tools.NodeJSVersionRange
Version range. A version range is an interval describing a set of
versions
.
A range has a left (lower) endpoint and a right (upper) endpoint. Each endpoint can be open (excluded from the set) or closed (included in the set).
NodeJSVersionRange
objects are immutable.
-
Field Summary
Modifier and TypeFieldDescriptionstatic final char
The left endpoint is closed and is included in the range.static final char
The left endpoint is open and is excluded from the range.static final char
The right endpoint is closed and is included in the range.static final char
The right endpoint is open and is excluded from the range. -
Constructor Summary
ConstructorDescriptionNodeJSVersionRange
(String range) Creates a version range from the specified string. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Compares thisVersionRange
object to another object.getLeft()
Returns the left endpoint of this version range.char
Returns the type of the left endpoint of this version range.getRight()
Returns the right endpoint of this version range.char
Returns the type of the right endpoint of this version range.int
hashCode()
Returns a hash code value for the object.boolean
includes
(NodeJSVersion version) Returns whether this version range includes the specified version.boolean
isEmpty()
Returns whether this version range is empty.toString()
Returns the string representation of this version range.
-
Field Details
-
LEFT_OPEN
public static final char LEFT_OPENThe left endpoint is open and is excluded from the range.The value of
LEFT_OPEN
is'('
.- See Also:
-
LEFT_CLOSED
public static final char LEFT_CLOSEDThe left endpoint is closed and is included in the range.The value of
LEFT_CLOSED
is'['
.- See Also:
-
RIGHT_OPEN
public static final char RIGHT_OPENThe right endpoint is open and is excluded from the range.The value of
RIGHT_OPEN
is')'
.- See Also:
-
RIGHT_CLOSED
public static final char RIGHT_CLOSEDThe right endpoint is closed and is included in the range.The value of
RIGHT_CLOSED
is']'
.- See Also:
-
-
Constructor Details
-
NodeJSVersionRange
Creates a version range from the specified string.Version range string grammar:
range ::= interval | atleast interval ::= ( '[' | '(' ) left ',' right ( ']' | ')' ) left ::= version right ::= version atleast ::= version
- Parameters:
range
- String representation of the version range. The versions in the range must contain no whitespace. Other whitespace in the range string is ignored.- Throws:
IllegalArgumentException
- Ifrange
is improperly formatted.
-
-
Method Details
-
getLeft
Returns the left endpoint of this version range.- Returns:
- The left endpoint.
-
getRight
Returns the right endpoint of this version range.- Returns:
- The right endpoint. May be
null
which indicates the right endpoint is Infinity.
-
getLeftType
public char getLeftType()Returns the type of the left endpoint of this version range.- Returns:
LEFT_CLOSED
if the left endpoint is closed orLEFT_OPEN
if the left endpoint is open.
-
getRightType
public char getRightType()Returns the type of the right endpoint of this version range.- Returns:
RIGHT_CLOSED
if the right endpoint is closed orRIGHT_OPEN
if the right endpoint is open.
-
includes
Returns whether this version range includes the specified version.- Parameters:
version
- The version to test for inclusion in this version range.- Returns:
true
if the specified version is included in this version range;false
otherwise.
-
isEmpty
public boolean isEmpty()Returns whether this version range is empty. A version range is empty if the set of versions defined by the interval is empty.- Returns:
true
if this version range is empty;false
otherwise.
-
toString
Returns the string representation of this version range.The format of the version range string will be a version string if the right end point is Infinity (
null
) or an interval string. -
hashCode
public int hashCode()Returns a hash code value for the object. -
equals
Compares thisVersionRange
object to another object.A version range is considered to be equal to another version range if both the endpoints and their types are equal or if both version ranges are
empty
.
-