Q
- the generic parameter of the effective query classE
- the generic type of the entity being queriedpublic abstract class BaseQuery<Q,E extends BaseEntity<?>> extends Object
Modifier and Type | Field and Description |
---|---|
protected EntityDescriptor |
descriptor
Contains the descriptor of the entities being queried.
|
protected int |
limit
Contains the max number of items to fetch (or 0 for "unlimited")
|
static int |
MAX_LIST_SIZE
Contains the maximal number of elements to be returned in
queryList() . |
protected static Mixing |
mixing |
protected int |
skip
Contains the the number of items to skip before items are added to the result
|
Modifier | Constructor and Description |
---|---|
protected |
BaseQuery(EntityDescriptor descriptor)
Creates a new query for entities of the given type.
|
Modifier and Type | Method and Description |
---|---|
protected void |
failOnOverflow(List<E> result) |
Optional<E> |
first()
Returns the first item matched by the query.
|
EntityDescriptor |
getDescriptor()
Returns the underlying descriptor
|
protected sirius.kernel.commons.Limit |
getLimit() |
abstract void |
iterate(Function<E,Boolean> handler)
Calls the given function on all items in the result, as long as it returns true.
|
void |
iterateAll(Consumer<E> consumer)
Calls the given consumer on all items in the result.
|
Q |
limit(int limit)
Specifies the max. number of items to fetch.
|
Optional<E> |
one()
Returns the single item matched by the query.
|
E |
queryFirst()
Returns the first item matched by the query.
|
List<E> |
queryList()
Returns a list of all items in the result.
|
E |
queryOne()
Returns the first item matched by the query.
|
Q |
skip(int skip)
Specifies the number of items to skip before items are added to the result.
|
public static final int MAX_LIST_SIZE
queryList()
.
For larger results iterate(Function)
mit be used as it can be more efficient
protected int limit
protected int skip
protected static Mixing mixing
protected final EntityDescriptor descriptor
protected BaseQuery(EntityDescriptor descriptor)
descriptor
- the descriptor of the entity type to queryprotected sirius.kernel.commons.Limit getLimit()
public EntityDescriptor getDescriptor()
public Q limit(int limit)
limit
- the max. number of items to fetch. Value <= 0 indicate "unlimited".public Q skip(int skip)
skip
- the number of items to skip. Value <= 0 are ignored.public abstract void iterate(Function<E,Boolean> handler)
Note that this method is intended for large results as not all items in the result need to be kept in memory when iterating through them.
handler
- the handle to be invoked for each item in the resultpublic void iterateAll(Consumer<E> consumer)
Note that this method is intended for large results as not all items in the result need to be kept in memory when iterating through them.
consumer
- the handle to be invoked for each item in the resultpublic List<E> queryList()
Note that large results should be processed using iterate(Function)
or
iterateAll(Consumer)
as they are more memory efficient.
public Optional<E> first()
public E queryFirst()
public Optional<E> one()
public E queryOne()
Copyright © 2018. All rights reserved.