Interface QueryService<T,K>

Type Parameters:
T - the type of the entity to be queried
K - the type of the entity's identifying key
All Known Subinterfaces:
CrudService<T,K>

public interface QueryService<T,K>
Specifies the contract of a generic service that handles querying operations on entities.
Author:
mlopez
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    count(QuerySpec filter)
    Count the number of entities that match a certain query specification.
    filter(QuerySpec filter)
    Apply filtering to entities in the system based on a certain query specification.
    Apply filtering to entities in the system based on a certain query specification and retrieve a single result.
    Find all entities.
    findById(K id)
    Find an entity by its identifying key.
  • Method Details

    • findById

      Optional<T> findById(K id)
      Find an entity by its identifying key.
      Parameters:
      id - the entity's identifying key
      Returns:
      an Optional instance containing the entity if it exists; otherwise empty
    • findAll

      List<T> findAll()
      Find all entities.
      Returns:
      a List containing all entities in the system
    • filter

      List<T> filter(QuerySpec filter)
      Apply filtering to entities in the system based on a certain query specification.
      Parameters:
      filter - the query specification used for filtering
      Returns:
      a List containing all entities matching the query specification
    • count

      long count(QuerySpec filter)
      Count the number of entities that match a certain query specification.
      Parameters:
      filter - the query specification used for filtering
      Returns:
      the number of entities that match the query specification
    • filterWithSingleResult

      Optional<T> filterWithSingleResult(QuerySpec filter)
      Apply filtering to entities in the system based on a certain query specification and retrieve a single result.
      Parameters:
      filter - the query specification used for filtering
      Returns:
      an Optional instance containing a single entity matching the query specification if it exists; otherwise empty