java.lang.Object
com.irurueta.authserver.authorization.infrastructure.sms.SmsOutbox
All Implemented Interfaces:
SmsInbox

public final class SmsOutbox extends Object implements SmsInbox
Bounded, thread-safe, in-memory record of the messages the LoggingSmsSender "sent", so the development inbox can show them, which reads it through the domain port SmsInbox. The oldest message is evicted when the capacity is reached.
  • Field Details

    • messages

      private final Deque<SentSms> messages
      Messages, oldest first.
    • capacity

      private final int capacity
      Maximum number of messages kept.
  • Constructor Details

    • SmsOutbox

      public SmsOutbox(int capacity)
      Creates the outbox.
      Parameters:
      capacity - maximum number of messages kept.
      Throws:
      IllegalArgumentException - if the capacity is not positive.
  • Method Details

    • add

      public void add(SentSms message)
      Records a message, evicting the oldest ones beyond the capacity.
      Parameters:
      message - the message.
    • messages

      public List<SentSms> messages()
      Reads the recorded messages.
      Returns:
      an immutable snapshot, oldest first.
    • entries

      public List<SmsInboxEntry> entries()
      Lists the recorded messages as the inbox port describes them.
      Specified by:
      entries in interface SmsInbox
      Returns:
      an immutable snapshot, oldest first.