Class MailDAO

java.lang.Object
net.flectone.pulse.data.database.dao.MailDAO
All Implemented Interfaces:
BaseDAO<MailSQL>

public class MailDAO extends Object implements BaseDAO<MailSQL>
Data Access Object for mail data in FlectonePulse. Handles mail message creation, retrieval, and deletion.
Since:
0.9.0
  • Constructor Details

    • MailDAO

      @Inject public MailDAO(Database database)
  • Method Details

    • database

      public Database database()
      Description copied from interface: BaseDAO
      Gets the database instance associated with this DAO.
      Specified by:
      database in interface BaseDAO<MailSQL>
      Returns:
      the database instance
    • sqlClass

      public Class<? extends MailSQL> sqlClass()
      Description copied from interface: BaseDAO
      Gets the SQL interface class for this DAO.
      Specified by:
      sqlClass in interface BaseDAO<MailSQL>
      Returns:
      the SQL interface class
    • insert

      public @NonNull Optional<Mail> insert(@NonNull FPlayer sender, @NonNull FPlayer receiver, @NonNull String message)
      Inserts a new mail message.
      Parameters:
      sender - the player who sent the mail
      receiver - the player who received the mail
      message - the mail message content
      Returns:
      the created mail record, or empty if players are unknown
    • delete

      public void delete(@NonNull Mail mail)
      Deletes a mail message.
      Parameters:
      mail - the mail record to delete
    • getReceiver

      public List<Mail> getReceiver(FPlayer fPlayer)
      Gets mail messages received by a player.
      Parameters:
      fPlayer - the player who received the mail
      Returns:
      list of received mail messages, empty list if player is unknown
    • getSender

      public List<Mail> getSender(FPlayer fPlayer)
      Gets mail messages sent by a player.
      Parameters:
      fPlayer - the player who sent the mail
      Returns:
      list of sent mail messages, empty list if player is unknown