Class QueryImpl<T extends BaseDataEntity<String>>
java.lang.Object
com.ultikits.ultitools.interfaces.impl.data.QueryImpl<T>
- Type Parameters:
T- the entity type
- All Implemented Interfaces:
Query<T>
Default implementation of
Query that wraps a DataOperator.
Equality conditions are delegated to the underlying DataOperator's getAll() method. Non-equality conditions (ne, gt, lt, gte, lte, like, in) are applied as in-memory filters. Ordering, limit, and offset are applied as in-memory post-processing.
Query接口的默认实现,包装了DataOperator。
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static interfaceSimple functional interface for in-memory filtering (Java 8 compatible). -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Stringprivate final List<WhereCondition> private final List<QueryImpl.Predicate<T>> private intprivate intprivate final DataOperator<T> private Stringprivate boolean -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionAdd an AND condition on a column.private intcompareField(T entity, String columnName, Object refValue) Compare an entity's field value against a reference value.private intcompareValues(Object a, Object b) Compare two values.longcount()Count the number of matching results.intdelete()Delete all matching results and return the count of deleted rows.Equal to.booleanexists()Check if any results match the query.first()Execute the query and return the first matching result, or null if none.private ObjectgetFieldValue(T entity, String columnName) Get a field value from an entity by column name.Greater than.Greater than or equal to.in(Collection<?> values) Value is in the given collection.SQL LIKE pattern matching.limit(int count) Limit the number of results.list()Execute the query and return all matching results.Less than.Less than or equal to.Not equal to.offset(int start) Skip a number of results.Order results by column ascending.orderByDesc(String column) Order results by column descending.Start a where condition on a column.
-
Field Details
-
operator
-
eqConditions
-
filters
-
currentColumn
-
orderByColumn
-
orderDesc
private boolean orderDesc -
limitCount
private int limitCount -
offsetStart
private int offsetStart
-
-
Constructor Details
-
QueryImpl
-
-
Method Details
-
where
Description copied from interface:QueryStart a where condition on a column.开始一个列的查询条件。
- Specified by:
wherein interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
column- the column name- Returns:
- this query for chaining
-
and
Description copied from interface:QueryAdd an AND condition on a column.添加一个AND条件。
- Specified by:
andin interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
column- the column name- Returns:
- this query for chaining
-
eq
Description copied from interface:QueryEqual to.等于。
- Specified by:
eqin interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
ne
Description copied from interface:QueryNot equal to.不等于。
- Specified by:
nein interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
gt
Description copied from interface:QueryGreater than.大于。
- Specified by:
gtin interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
lt
Description copied from interface:QueryLess than.小于。
- Specified by:
ltin interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
gte
Description copied from interface:QueryGreater than or equal to.大于等于。
- Specified by:
gtein interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
lte
Description copied from interface:QueryLess than or equal to.小于等于。
- Specified by:
ltein interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
value- the value to compare- Returns:
- this query for chaining
-
like
Description copied from interface:QuerySQL LIKE pattern matching.SQL LIKE模式匹配。
- Specified by:
likein interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
pattern- the LIKE pattern (use % for wildcard)- Returns:
- this query for chaining
-
in
Description copied from interface:QueryValue is in the given collection.值在给定集合中。
- Specified by:
inin interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
values- the collection of allowed values- Returns:
- this query for chaining
-
orderBy
Description copied from interface:QueryOrder results by column ascending.按列升序排列结果。
- Specified by:
orderByin interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
column- the column to order by- Returns:
- this query for chaining
-
orderByDesc
Description copied from interface:QueryOrder results by column descending.按列降序排列结果。
- Specified by:
orderByDescin interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
column- the column to order by- Returns:
- this query for chaining
-
limit
Description copied from interface:QueryLimit the number of results.限制结果数量。
- Specified by:
limitin interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
count- the maximum number of results- Returns:
- this query for chaining
-
offset
Description copied from interface:QuerySkip a number of results.跳过指定数量的结果。
- Specified by:
offsetin interfaceQuery<T extends BaseDataEntity<String>>- Parameters:
start- the number of results to skip- Returns:
- this query for chaining
-
list
Description copied from interface:QueryExecute the query and return all matching results.执行查询并返回所有匹配结果。
- Specified by:
listin interfaceQuery<T extends BaseDataEntity<String>>- Returns:
- list of matching entities
-
first
Description copied from interface:QueryExecute the query and return the first matching result, or null if none.执行查询并返回第一个匹配结果,如果没有则返回null。
- Specified by:
firstin interfaceQuery<T extends BaseDataEntity<String>>- Returns:
- the first matching entity, or null
-
exists
public boolean exists()Description copied from interface:QueryCheck if any results match the query.检查是否有匹配查询的结果。
- Specified by:
existsin interfaceQuery<T extends BaseDataEntity<String>>- Returns:
- true if at least one result exists
-
count
public long count()Description copied from interface:QueryCount the number of matching results.计算匹配结果的数量。
- Specified by:
countin interfaceQuery<T extends BaseDataEntity<String>>- Returns:
- the count of matching results
-
delete
public int delete()Description copied from interface:QueryDelete all matching results and return the count of deleted rows.删除所有匹配结果并返回已删除的行数。
- Specified by:
deletein interfaceQuery<T extends BaseDataEntity<String>>- Returns:
- the count of deleted rows
-
getFieldValue
Get a field value from an entity by column name. Maps column name (snake_case) to Java field via @Column annotation. -
compareField
Compare an entity's field value against a reference value. Returns negative, zero, or positive. -
compareValues
Compare two values. Handles Comparable types and null safety.
-