QueryField

sealed interface QueryField<T>

A logical field of a query model, by its path (state.price, aggregateId, items.0.sku), typed by the values T it holds: the DSL's comparisons take a value of that type, checked at compile time (STATE__PRICE gte BigDecimal("5.00")). The generated <State>Properties and <Context>Contract constants are typed by their state's fields; a dynamic key, named only at run time, is a QueryField<Any?> (QueryField of a path) and takes any value.

Two fields are equal when their paths are, whatever they are typed as: the type only checks code at compile time and never reaches the wire, where a field is its path. T is invariant, so a QueryField<String> takes no Int. Fields are built by QueryField and of; an application does not implement this interface.

Cases may be added in a minor release, so a when over it keeps an else branch.

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
abstract val path: String

Functions

Link copied to clipboard
open fun absoluteTo(parent: QueryField<*>?): QueryField<T>

This field, absolute: under parent unless its path already lies under it, the one rule of a path under a prefix, which the filter and projection DSLs' blocks follow. A name equal to the parent's is under it: state in state is state.state. The rule cannot tell one case: a path that starts with the parent's path and a dot reads as already absolute, so a field of that same name one level down is written from the root (state.state.name, not state.name). That is what lets a generated field constant, which is absolute, be used inside a block.

Link copied to clipboard
open fun append(relative: QueryField<*>): QueryField<Any?>

The field at relative under this one.

Link copied to clipboard
open fun relativeTo(parent: QueryField<*>): QueryField<T>?

This field relative to parent, or null when it is not under it.