-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.in
53 lines (40 loc) · 1.23 KB
/
README.in
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
## 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](https://www.osgi.org/)
* [JPMS-ready](https://en.wikipedia.org/wiki/Java_Platform_Module_System)
* 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`