public final class QueryBuilder extends TargetBuilder<io.spine.client.Query,QueryBuilder>
Query
instances.
None of the parameters set by the builder methods are required. Call QueryBuilder.build()
to
retrieve the resulting Query
instance.
Usage example:
ActorRequestFactory factory = ... ;
Query query = factory.query()
.select(Customer.class)
.byId(westCoastCustomerIds())
.withMask("name", "address", "email")
.where(eq("type", "permanent"),
eq("discountPercent", 10),
eq("companySize", Company.Size.SMALL))
.orderBy("name", ASCENDING)
.limit(20)
.build();
Arguments for the TargetBuilder.where(Filter...)
method can be composed using the Filters
utility class.
Filters
,
TargetBuilder
Modifier and Type | Method and Description |
---|---|
io.spine.client.Query |
build()
Generates a new
Query instance with current builder configuration. |
QueryBuilder |
limit(int count)
Limits the number of results returned by the query.
|
QueryBuilder |
orderBy(java.lang.String column,
io.spine.client.OrderBy.Direction direction)
Sets the sorting order by the target column and order direction.
|
public QueryBuilder orderBy(java.lang.String column, io.spine.client.OrderBy.Direction direction)
column
- the entity column to sort bydirection
- sorting directionpublic QueryBuilder limit(int count)
count
- the number of results to be returnedpublic io.spine.client.Query build()
Query
instance with current builder configuration.build
in class TargetBuilder<io.spine.client.Query,QueryBuilder>
Query