Class BeanQueryContext<T>
- Type Parameters:
T- The row (bean) type.
- Direct Known Subclasses:
InMemoryBeanQueryContext,SqlBeanQueryContext
Build a context once, at startup, from its engine's create(...) factory. It holds no rows and no
connections, so it can be shared across threads. Open a BeanQuerySession per request with the engine's
getSession(...) shortcut or with createSession(). Call copy() to derive a variant.
The base class owns every engine-independent check (spec ยง5): the column allow-list, operator/type checks, the
regex gate, the size caps, limit clamping and the count policy. Engines see only a ResolvedQuery.
Example:
- Since:
- 10.0.0
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBeanQueryContext.Builder<T,SELF extends BeanQueryContext.Builder<T, SELF>> The settings every engine's context builder shares. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedBeanQueryContext(BeanQueryContext.Builder<T, ?> builder) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidcheckOrigin(ResolvedQuery query) Confirms thatquerywas produced by resolving against this context (directly, or through a session built from it) before an engine uses it.columns()Returns the declared columns, in order: the allow-list for search, sort and view, and the default view.abstract BeanQueryContext.Builder<T,?> copy()Returns a builder initialized from this context.abstract BeanQuerySession.Builder<T,?> Returns a builder for a session over this context.final SearchTypegetColumnType(String name) Returns the type stored for a declared column: the type given tocolumn, or the type inferred for it (for example,InMemoryBeanQueryContext.create(Class)infers one per bean getter).final intReturns the largest number of search clauses a query may use.final intReturns the largest number of sort keys a query may use.final SearchOperatorSetReturns the default operator set a client may use.final SearchOperatorSetoperatorSet(String column) Returns the operator set a client may use on one column.final ResolvedQueryValidates a query against this context's rules without running it.
-
Constructor Details
-
BeanQueryContext
Constructor. Takes a private copy of the builder's settings and validates it.- Parameters:
builder- The builder. Must not benull .- Throws:
IllegalStateException- If the settings are invalid.
-
-
Method Details
-
columns
Returns the declared columns, in order: the allow-list for search, sort and view, and the default view.- Returns:
- An unmodifiable list.
-
operatorSet
Returns the default operator set a client may use.$regexis absent if regex is disallowed.- Returns:
- The operator set.
-
operatorSet
Returns the operator set a client may use on one column.$regexis absent if regex is disallowed.- Parameters:
column- The column name.- Returns:
- The column's operator set, else the default set.
-
getColumnType
Returns the type stored for a declared column: the type given tocolumn, or the type inferred for it (for example,InMemoryBeanQueryContext.create(Class)infers one per bean getter).- Parameters:
name- The column name.- Returns:
- The column's type. Never
null . - Throws:
IllegalArgumentException- If the column is not declared.
-
getMaxSearchClauses
Returns the largest number of search clauses a query may use.- Returns:
- The cap.
-
getMaxSortKeys
Returns the largest number of sort keys a query may use.- Returns:
- The cap.
-
resolve
Validates a query against this context's rules without running it.- Parameters:
query- The query. Must not benull .- Returns:
- The resolved query.
- Throws:
BeanQuerySyntaxException- If the query breaks a rule.
-
checkOrigin
Confirms thatquerywas produced by resolving against this context (directly, or through a session built from it) before an engine uses it. An engine's rendering/execution code that accepts a caller-suppliedResolvedQuery— rather than one it just resolved itself — calls this first, so a query resolved against a different context's columns is rejected with a clear message instead of silently rendering (or running) against the wrong schema.- Parameters:
query- The query to check. Must not benull .- Throws:
IllegalArgumentException- Ifquerywas not produced by this context.
-
copy
Returns a builder initialized from this context. Building it leaves this context unchanged.- Returns:
- A new builder.
-
createSession
Returns a builder for a session over this context.- Returns:
- A new session builder.
-