Skip to content
This repository was archived by the owner on Jun 26, 2026. It is now read-only.

Repository files navigation

jranges

Maven Central Maven Central (snapshot) Codecov Java Version

com.io7m.jranges

JVM Platform Status
OpenJDK (Temurin) Current Linux Build (OpenJDK (Temurin) Current, Linux)
OpenJDK (Temurin) LTS Linux Build (OpenJDK (Temurin) LTS, Linux)
OpenJDK (Temurin) Current Windows Build (OpenJDK (Temurin) Current, Windows)
OpenJDK (Temurin) LTS Windows Build (OpenJDK (Temurin) LTS, Windows)

Repository Relocation

Development of this project has moved to an open-source but not open-contribution model.

Source code and commits will remain publicly available perpetually, but issues and/or pull requests will be rejected and/or ignored. Additionally, this project will now only be available via a read-only mirror at:

https://codeberg.org/io7m-com/jranges

jranges

A set of functions and types for dealing with ranges and intervals.

Features

  • 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.

Usage

Range Checks

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.

Range Types

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

Releases

Used by

Contributors

Languages