Class SqlWarningDao

java.lang.Object
tk.airshipcraft.commonlib.db.dao.impl.SqlWarningDao
All Implemented Interfaces:
WarningDao, GenericDao<Warning,UUID>

public class SqlWarningDao extends Object implements WarningDao
Provides SQL-specific data access operations for Warning objects. Implements the WarningDao interface using a SQL database.
Since:
2024-01-06
Version:
1.0.0
Author:
notzune
  • Constructor Details

    • SqlWarningDao

      public SqlWarningDao(SqlConnectionManager connectionManager)
      Constructs a SqlWarningDao with a given SqlConnectionManager.
      Parameters:
      connectionManager - The connection manager for database connections.
  • Method Details

    • findById

      public Optional<Warning> findById(UUID id)
      Retrieves a Warning by its unique ID.
      Specified by:
      findById in interface GenericDao<Warning,UUID>
      Specified by:
      findById in interface WarningDao
      Parameters:
      id - The UUID of the Warning.
      Returns:
      An Optional containing the Warning if found, or an empty Optional otherwise.
    • findAll

      public List<Warning> findAll()
      Retrieves all Warnings from the database.
      Specified by:
      findAll in interface GenericDao<Warning,UUID>
      Specified by:
      findAll in interface WarningDao
      Returns:
      A List of all Warnings.
    • create

      public Warning create(Warning entity)
      Creates a new Warning in the database.
      Specified by:
      create in interface GenericDao<Warning,UUID>
      Specified by:
      create in interface WarningDao
      Parameters:
      entity - The Warning to be created.
      Returns:
      The created Warning.
    • update

      public Warning update(Warning entity)
      Updates an existing Warning in the database.
      Specified by:
      update in interface GenericDao<Warning,UUID>
      Specified by:
      update in interface WarningDao
      Parameters:
      entity - The Warning to be updated.
      Returns:
      The updated Warning.
    • deleteById

      public void deleteById(UUID uuid)
      Deletes a Warning from the database by its UUID.
      Specified by:
      deleteById in interface GenericDao<Warning,UUID>
      Specified by:
      deleteById in interface WarningDao
      Parameters:
      uuid - The UUID of the Warning to be deleted.
    • findByUser

      public List<Warning> findByUser(UUID minecraftId, String discordId)
      Retrieves all Warnings issued to a specific Minecraft or Discord user.
      Specified by:
      findByUser in interface WarningDao
      Parameters:
      minecraftId - The UUID of the Minecraft user.
      discordId - The Discord ID of the user.
      Returns:
      A List of Warnings associated with the given user.