java.lang.Object
com.ultikits.ultitools.interfaces.impl.data.QueryImpl<T>
Type Parameters:
T - the entity type
All Implemented Interfaces:
Query<T>

public class QueryImpl<T extends BaseDataEntity<String>> extends Object implements 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。

  • Field Details

  • Constructor Details

  • Method Details

    • where

      public Query<T> where(String column)
      Description copied from interface: Query
      Start a where condition on a column.

      开始一个列的查询条件。

      Specified by:
      where in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      column - the column name
      Returns:
      this query for chaining
    • and

      public Query<T> and(String column)
      Description copied from interface: Query
      Add an AND condition on a column.

      添加一个AND条件。

      Specified by:
      and in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      column - the column name
      Returns:
      this query for chaining
    • eq

      public Query<T> eq(Object value)
      Description copied from interface: Query
      Equal to.

      等于。

      Specified by:
      eq in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • ne

      public Query<T> ne(Object value)
      Description copied from interface: Query
      Not equal to.

      不等于。

      Specified by:
      ne in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • gt

      public Query<T> gt(Object value)
      Description copied from interface: Query
      Greater than.

      大于。

      Specified by:
      gt in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • lt

      public Query<T> lt(Object value)
      Description copied from interface: Query
      Less than.

      小于。

      Specified by:
      lt in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • gte

      public Query<T> gte(Object value)
      Description copied from interface: Query
      Greater than or equal to.

      大于等于。

      Specified by:
      gte in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • lte

      public Query<T> lte(Object value)
      Description copied from interface: Query
      Less than or equal to.

      小于等于。

      Specified by:
      lte in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      value - the value to compare
      Returns:
      this query for chaining
    • like

      public Query<T> like(String pattern)
      Description copied from interface: Query
      SQL LIKE pattern matching.

      SQL LIKE模式匹配。

      Specified by:
      like in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      pattern - the LIKE pattern (use % for wildcard)
      Returns:
      this query for chaining
    • in

      public Query<T> in(Collection<?> values)
      Description copied from interface: Query
      Value is in the given collection.

      值在给定集合中。

      Specified by:
      in in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      values - the collection of allowed values
      Returns:
      this query for chaining
    • orderBy

      public Query<T> orderBy(String column)
      Description copied from interface: Query
      Order results by column ascending.

      按列升序排列结果。

      Specified by:
      orderBy in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      column - the column to order by
      Returns:
      this query for chaining
    • orderByDesc

      public Query<T> orderByDesc(String column)
      Description copied from interface: Query
      Order results by column descending.

      按列降序排列结果。

      Specified by:
      orderByDesc in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      column - the column to order by
      Returns:
      this query for chaining
    • limit

      public Query<T> limit(int count)
      Description copied from interface: Query
      Limit the number of results.

      限制结果数量。

      Specified by:
      limit in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      count - the maximum number of results
      Returns:
      this query for chaining
    • offset

      public Query<T> offset(int start)
      Description copied from interface: Query
      Skip a number of results.

      跳过指定数量的结果。

      Specified by:
      offset in interface Query<T extends BaseDataEntity<String>>
      Parameters:
      start - the number of results to skip
      Returns:
      this query for chaining
    • list

      public List<T> list()
      Description copied from interface: Query
      Execute the query and return all matching results.

      执行查询并返回所有匹配结果。

      Specified by:
      list in interface Query<T extends BaseDataEntity<String>>
      Returns:
      list of matching entities
    • first

      public T first()
      Description copied from interface: Query
      Execute the query and return the first matching result, or null if none.

      执行查询并返回第一个匹配结果,如果没有则返回null。

      Specified by:
      first in interface Query<T extends BaseDataEntity<String>>
      Returns:
      the first matching entity, or null
    • exists

      public boolean exists()
      Description copied from interface: Query
      Check if any results match the query.

      检查是否有匹配查询的结果。

      Specified by:
      exists in interface Query<T extends BaseDataEntity<String>>
      Returns:
      true if at least one result exists
    • count

      public long count()
      Description copied from interface: Query
      Count the number of matching results.

      计算匹配结果的数量。

      Specified by:
      count in interface Query<T extends BaseDataEntity<String>>
      Returns:
      the count of matching results
    • delete

      public int delete()
      Description copied from interface: Query
      Delete all matching results and return the count of deleted rows.

      删除所有匹配结果并返回已删除的行数。

      Specified by:
      delete in interface Query<T extends BaseDataEntity<String>>
      Returns:
      the count of deleted rows
    • getFieldValue

      private Object getFieldValue(T entity, String columnName)
      Get a field value from an entity by column name. Maps column name (snake_case) to Java field via @Column annotation.
    • compareField

      private int compareField(T entity, String columnName, Object refValue)
      Compare an entity's field value against a reference value. Returns negative, zero, or positive.
    • compareValues

      private int compareValues(Object a, Object b)
      Compare two values. Handles Comparable types and null safety.