Record Class Recipient

java.lang.Object
java.lang.Record
io.leandev.appfuse.notification.Recipient
Record Components:
userId - 使用者識別(最多 36 字元;供偏好查詢、稽核、IN_APP 投遞;可為 null)
email - 電子郵件位址(EMAIL;最多 320 字元)
phone - 手機號(SMS;最多 320 字元)
lineUserId - LINE userId(LINE 推播;最多 320 字元)
locale - 收件人語系(null 表示系統預設)

public record Recipient(String userId, String email, String phone, String lineUserId, Locale locale) extends Record

通知收件人

RecipientResolver 從業務脈絡解析而得,或由呼叫端在 NotificationRequest 顯式提供。 框架不認得帳號模型——收件人以不透明的 userId 與各通道的收件位址表達。localeNotificationTemplateResolver 在地化(null 表示系統預設語系)。

多通道定址:每個 ChannelType 對應一種位址——EMAIL→email、SMS→phone、LINE→lineUserId、 IN_APP→userIdaddressFor(ChannelType) 依通道回對應位址;RecipientResolver 解析時填入該收件人各通道的位址 (沒有的留 null,NotificationService 會略過缺位址的通道)。

Since:
4.0.0
  • Constructor Details

    • Recipient

      public Recipient(String userId, String email, String phone, String lineUserId, Locale locale)
      Creates an instance of a Recipient record class.
      Parameters:
      userId - the value for the userId record component
      email - the value for the email record component
      phone - the value for the phone record component
      lineUserId - the value for the lineUserId record component
      locale - the value for the locale record component
  • Method Details

    • ofEmail

      public static Recipient ofEmail(String email)
      以 email 建立收件人(無 userId、用系統預設語系)
      Parameters:
      email - 電子郵件位址
      Returns:
      收件人
    • addressFor

      public String addressFor(ChannelType channel)
      取此收件人在某通道的收件位址
      Parameters:
      channel - 通道
      Returns:
      對應位址(無則 null)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • userId

      public String userId()
      Returns the value of the userId record component.
      Returns:
      the value of the userId record component
    • email

      public String email()
      Returns the value of the email record component.
      Returns:
      the value of the email record component
    • phone

      public String phone()
      Returns the value of the phone record component.
      Returns:
      the value of the phone record component
    • lineUserId

      public String lineUserId()
      Returns the value of the lineUserId record component.
      Returns:
      the value of the lineUserId record component
    • locale

      public Locale locale()
      Returns the value of the locale record component.
      Returns:
      the value of the locale record component