Package org.apache.commons.lang3
Class IntegerRange
- All Implemented Interfaces:
Serializable
Specializes
NumberRange for Integers.
This class is not designed to interoperate with other NumberRanges
- Since:
- 3.13.0
- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateIntegerRange(Integer number1, Integer number2) Creates a new instance. -
Method Summary
Modifier and TypeMethodDescriptionstatic IntegerRangeof(int fromInclusive, int toInclusive) Creates a closed range with the specified minimum and maximum values (both inclusive).static IntegerRangeCreates a closed range with the specified minimum and maximum values (both inclusive).Returns a sequential orderedIntStreamfromRange.getMinimum()(inclusive) toRange.getMaximum()(inclusive) by an incremental step of1.Methods inherited from class org.apache.commons.lang3.Range
between, between, contains, containsRange, elementCompareTo, equals, fit, getComparator, getMaximum, getMinimum, hashCode, intersectionWith, is, is, isAfter, isAfterRange, isBefore, isBeforeRange, isEndedBy, isNaturalOrdering, isOverlappedBy, isStartedBy, of, of, toString, toString
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
-
Constructor Details
-
IntegerRange
Creates a new instance.- Parameters:
number1- the first element, not nullnumber2- the second element, not null- Throws:
NullPointerException- when element1 is null.NullPointerException- when element2 is null.
-
-
Method Details
-
of
Creates a closed range with the specified minimum and maximum values (both inclusive).The range uses the natural ordering of the elements to determine where values lie in the range.
The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.
- Parameters:
fromInclusive- the first value that defines the edge of the range, inclusive.toInclusive- the second value that defines the edge of the range, inclusive.- Returns:
- the range object, not null.
-
of
Creates a closed range with the specified minimum and maximum values (both inclusive).The range uses the natural ordering of the elements to determine where values lie in the range.
The arguments may be passed in the order (min,max) or (max,min). The getMinimum and getMaximum methods will return the correct values.
- Parameters:
fromInclusive- the first value that defines the edge of the range, inclusive.toInclusive- the second value that defines the edge of the range, inclusive.- Returns:
- the range object, not null.
- Throws:
IllegalArgumentException- if either element is null.
-
toIntStream
Returns a sequential orderedIntStreamfromRange.getMinimum()(inclusive) toRange.getMaximum()(inclusive) by an incremental step of1.- Returns:
- a sequential
IntStreamfor the range ofintelements - Since:
- 3.18.0
-