JVM | Platform | Status |
---|---|---|
OpenJDK (Temurin) Current | Linux | |
OpenJDK (Temurin) LTS | Linux | |
OpenJDK (Temurin) Current | Windows | |
OpenJDK (Temurin) LTS | Windows |
A set of functions and types for dealing with ranges and intervals.
- Immutable range types, for specifying ranges over all the available integral and floating point types.
- Functions for checking that values fall within given ranges.
- High coverage test suite.
- OSGi-ready
- JPMS-ready
- ISC license.
Use the RangeCheck
class to perform range checks:
RangeCheck.checkIncludedInLong(
23L,
"Number of assignments",
RangeInclusiveL.of(0L, 99),
"Valid number of assignments"
);
RangeCheck.checkIncludedInLong(
130L,
"Number of assignments",
RangeInclusiveL.of(0L, 99),
"Valid number of assignments"
);
The second call will throw a RangeCheckException
with a message similar to
Range check failed: 0 <= Number of assignments (130) <= 99 (Valid number of assignments) == false
.
The package exposes numerous immutable half-open and inclusive range types, specialized to various Java numeric types:
RangeHalfOpenB
RangeHalfOpenD
RangeHalfOpenI
RangeHalfOpenL
RangeInclusiveB
RangeInclusiveD
RangeInclusiveI
RangeInclusiveL