Interface Range<A>
- Type Parameters:
A- the element type of the range
- All Known Implementing Classes:
Range.Bounded,Range.Empty
PostgreSQL range type. Represents a range of values of type
A with full bound inclusivity
information.
A range can be:
- Empty — no values are in the range
- Bounded — with an optional lower and/or upper bound. A
nulllower bound means negative infinity; anullupper bound means positive infinity. Infinite bounds are always exclusive regardless of the inclusivity flag.
The standard PostgreSQL range types are:
int4range—Range<Integer>int8range—Range<Long>numrange—Range<java.math.BigDecimal>tsrange—Range<java.time.LocalDateTime>tstzrange—Range<java.time.Instant>daterange—Range<java.time.LocalDate>
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final recordA bounded range with explicit bound inclusivity.static final recordAn empty range containing no values. -
Method Summary
Static MethodsModifier and TypeMethodDescriptionstatic <A> Range<A> bounded(A lower, A upper) Creates a half-open range[lower, upper)— inclusive lower, exclusive upper.static <A> Range<A> empty()Creates an empty range.static <A> Range<A> of(A lower, boolean lowerInclusive, A upper, boolean upperInclusive) Creates a range with the given bounds and their inclusivity.static <A> Range<A> Creates an unbounded range(,)— from negative infinity to positive infinity.
-
Method Details
-
empty
Creates an empty range. -
of
Creates a range with the given bounds and their inclusivity.- Parameters:
lower- lower bound, ornullfor negative infinity (always exclusive)lowerInclusive- whether the lower bound is inclusiveupper- upper bound, ornullfor positive infinity (always exclusive)upperInclusive- whether the upper bound is inclusive
-
bounded
Creates a half-open range[lower, upper)— inclusive lower, exclusive upper. This is the canonical form for discrete range types (int4range,int8range,daterange). -
unbounded
Creates an unbounded range(,)— from negative infinity to positive infinity.
-