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.
-
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.- 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.- 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.- 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.
-