Record Class InvitationMessage

java.lang.Object
java.lang.Record
org.jwcarman.who.emaillink.InvitationMessage
Record Components:
address - the invited address, and the recipient
link - the sign-in link, carrying the token in its fragment
code - the raw normalized sign-in code
expiresAt - when the link and the code stop working
validFor - how long the link and the code work from when the email is sent
roles - the names of the roles the invitation gave the identity; empty for none
All Implemented Interfaces:
WhoEmail

public record InvitationMessage(String address, String link, String code, Instant expiresAt, Duration validFor, Set<String> roles) extends Record implements WhoEmail
An email inviting a person to the application: the link and the typed code that both sign them in with the invited address, which is accepting the invitation. It is what InvitationService sends, so a sender can word an invitation differently from a sign-in.
  • Constructor Details

    • InvitationMessage

      public InvitationMessage(String address, String link, String code, Instant expiresAt, Duration validFor, Set<String> roles)
      Compact constructor: validates that no field is null and copies the roles.
  • Method Details

    • toString

      public 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
    • formattedCode

      public String formattedCode()
      Returns the code laid out for reading, for example K7F-2QM.
      Returns:
      the formatted code
    • expiresIn

      public String expiresIn()
      Returns how long the link and the code work, for reading: 15 minutes, 1 minute.
      Returns:
      the time left, in whole minutes rounded up
    • template

      public String template()
      Returns invitation, the name of this email's template.
      Specified by:
      template in interface WhoEmail
      Returns:
      the template's name
    • 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.
    • address

      public String address()
      Returns the value of the address record component.
      Specified by:
      address in interface WhoEmail
      Returns:
      the value of the address record component
    • link

      public String link()
      Returns the value of the link record component.
      Returns:
      the value of the link record component
    • code

      public String code()
      Returns the value of the code record component.
      Returns:
      the value of the code record component
    • expiresAt

      public Instant expiresAt()
      Returns the value of the expiresAt record component.
      Returns:
      the value of the expiresAt record component
    • validFor

      public Duration validFor()
      Returns the value of the validFor record component.
      Returns:
      the value of the validFor record component
    • roles

      public Set<String> roles()
      Returns the value of the roles record component.
      Returns:
      the value of the roles record component