Range
A range of numbers. A Range is made up of two RangeNodes, which can either be inclusive or exclusive.
Methods
Range(RangeNode minimum, RangeNode maximum)
Constructs a new Range with two RangeNodes defining its minimum and maximum boundaries. Throws an IllegalArgumentException if the minimum node's value is greater than the maximum node's value.
Range(Range range)
Constructs a new Range by copying an existing one.
inclusive(double minimum, double maximum)
Static factory method. Creates a new Range with inclusive end points.
exclusive(double minimum, double maximum)
Static factory method. Creates a new Range with exclusive end points.
infinite(double value, boolean isInclusive, boolean isPositive)
Static factory method. Creates a range extending infinitely in one direction. If isPositive is true, the range extends towards positive infinity from value. If false, it extends towards negative infinity from value.
infinite(RangeNode node, boolean isPositive)
Static factory method. Creates a range extending infinitely in one direction, based on a RangeNode.
doRangesOverlap(Range a, Range b)
Static method. Checks if two Range objects overlap.
minimum()
Returns the RangeNode representing the minimum boundary of the range.
maximum()
Returns the RangeNode representing the maximum boundary of the range.
includes(double value)
Checks if the range includes a given value.
excludes(double value)
Checks if the range excludes a given value.
includesAll(double... values)
Checks if the range includes all of the provided values.
includesAny(double... values)
Checks if the range includes any of the provided values.
excludesAll(double... values)
Checks if the range excludes all of the provided values.
excludesAny(double... values)
Checks if the range excludes any of the provided values.
size()
Returns the size of the range (maximum value - minimum value).
equals(Object obj)
Compares this Range to another object for equality. Two Range objects are equal if their minimum and maximum RangeNodes are equal.
hashCode()
Returns a hash code for the Range.
toString()
Returns a string representation of the Range (e.g., "[min, max]" or "]min, max[").
compareTo(Range range)
Compares this Range to another Range based on their sizes.