Interface IGenericService<T,ID>

Type Parameters:
T - The type of entity.
ID - The type of the entity's identifier.
All Known Subinterfaces:
IAdvertiserService, IPermissionService, IProfileService, IRoleService, IUserService
All Known Implementing Classes:
AdvertiserServiceImpl, GenericServiceImpl, PermissionServiceImpl, ProfileServiceImpl, RoleServiceImpl, UserServiceImpl

public interface IGenericService<T,ID>
Generic service interface providing common CRUD operations.
  • Method Details

    • findById

      T findById(ID id)
      Finds an entity by its identifier.
      Parameters:
      id - The identifier of the entity - must not be null.
      Returns:
      The entity if found.
      Throws:
      BadRequestException - if the ID is null.
      NotFoundException - if the entity is not found.
    • findAllByIds

      List<T> findAllByIds(Collection<ID> ids)
      Finds all entities by their identifiers.
      Parameters:
      ids - A collection of entity identifiers - must not be null or empty.
      Returns:
      A list of found entities.
      Throws:
      BadRequestException - if the IDs are null or empty.
      NotFoundException - if any entity is not found.
    • findAllByIdsToSet

      Set<T> findAllByIdsToSet(Collection<ID> ids)
      Finds all entities by their identifiers and returns them as a set.
      Parameters:
      ids - A collection of entity identifiers - must not be null or empty.
      Returns:
      A set of found entities.
      Throws:
      BadRequestException - if the IDs are null or empty.
      NotFoundException - if any entity is not found.
    • save

      T save(T t)
      Saves a new entity.
      Parameters:
      t - The entity to save - must not be null.
      Returns:
      The saved entity.
      Throws:
      BadRequestException - if the entity is null or already exists.
    • saveAll

      List<T> saveAll(Collection<T> t)
      Saves multiple entities.
      Parameters:
      t - A collection of entities to save - must not be null or empty.
      Returns:
      A list of saved entities.
      Throws:
      BadRequestException - if the list is null or empty.
    • updateById

      T updateById(T t, ID id)
      Updates an existing entity by its identifier.
      Parameters:
      t - The updated entity data - must not be null.
      id - The identifier of the entity to update - must not be null.
      Returns:
      The updated entity.
      Throws:
      BadRequestException - if the ID or entity is null.
      NotFoundException - if the entity does not exist.
    • deleteById

      void deleteById(ID id)
      Deletes an entity by its identifier.
      Parameters:
      id - The identifier of the entity to delete - must not be null.
      Throws:
      BadRequestException - if the ID is null.
      NotFoundException - if the entity does not exist.
    • findAll

      List<T> findAll()
      Retrieves all entities.
      Returns:
      A list of all entities.
    • findAllPage

      org.springframework.data.domain.Page<T> findAllPage(org.springframework.data.domain.Pageable pageable)
      Retrieves all entities with pagination support.
      Parameters:
      pageable - The pagination configuration - must not be null.
      Returns:
      A Page containing the paginated entities.
      Throws:
      BadRequestException - if the pageable parameter is null.
    • existsById

      boolean existsById(ID id)
      Checks if an entity exists by its identifier.
      Parameters:
      id - The identifier of the entity - must not be null.
      Returns:
      true if the entity exists, otherwise false.
    • existsAllByIds

      boolean existsAllByIds(Collection<ID> ids)
      Checks if multiple entities exist by their identifiers.
      Parameters:
      ids - A collection of entity identifiers - must not be null or empty.
      Returns:
      true if all entities exist, otherwise false.
    • existsByUniqueProperties

      boolean existsByUniqueProperties(T t)
      Checks if an entity exists based on its unique properties.
      Parameters:
      t - The entity containing unique properties to check - must not be null.
      Returns:
      true if an entity with the same unique properties exists, otherwise false.