Range

data class Range<T : Any>(val elementClass: KClass<T>, val lowerBound: T? = null, val upperBound: T? = null, val isLowerInclusive: Boolean = true, val isUpperInclusive: Boolean = false, val isLowerInfinite: Boolean = lowerBound == null, val isUpperInfinite: Boolean = upperBound == null, val isLowerNull: Boolean = false, val isUpperNull: Boolean = false, val isEmpty: Boolean = false)

Represents a generic, user-friendly PostgreSQL range. This class is designed to be used in application code, mapping directly to/from io.github.octaviusframework.driver.container.PgRange.

The defaults produce PostgreSQL's own [) convention: lower inclusive, upper exclusive, and a bound left null treated as unbounded rather than as a NULL value.

Note that ranges over a discrete subtype - int4range, int8range, daterange - are rewritten by the server into the canonical [) form, so what comes back describes the same span with different bounds than what went out: (1,5] is stored and read back as [2,6). Comparing a returned range field-by-field against the one you sent will not match. Continuous types (numrange, tsrange, tstzrange) have no canonical form and are stored as written.

Type Parameters

T

The type of the range bounds (e.g., Int, LocalDate, or a data class).

Constructors

Link copied to clipboard
constructor(elementClass: KClass<T>, lowerBound: T? = null, upperBound: T? = null, isLowerInclusive: Boolean = true, isUpperInclusive: Boolean = false, isLowerInfinite: Boolean = lowerBound == null, isUpperInfinite: Boolean = upperBound == null, isLowerNull: Boolean = false, isUpperNull: Boolean = false, isEmpty: Boolean = false)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

The class of the bounds, needed to resolve the PostgreSQL range type.

Link copied to clipboard

Whether the range contains nothing at all; use Range.empty to build one.

Link copied to clipboard

Whether the lower bound is part of the range.

Link copied to clipboard

Whether the range is unbounded below.

Link copied to clipboard

Whether the lower bound is present but NULL, as distinct from unbounded.

Link copied to clipboard

Whether the upper bound is part of the range.

Link copied to clipboard

Whether the range is unbounded above.

Link copied to clipboard

Whether the upper bound is present but NULL, as distinct from unbounded.

Link copied to clipboard

The lower bound value, or null for none.

Link copied to clipboard

The upper bound value, or null for none.