Class Messages

java.lang.Object
ch.tocco.nice2.messaging.mail.spi.Messages

public final class Messages extends Object
  • Field Details

  • Method Details

    • toEmailAddress

      public static Function<@Nullable jakarta.mail.internet.InternetAddress, @Nullable String> toEmailAddress()
      Returns a function that converts InternetAddresses to strings, while returning only the address part. Groups are resolved to a comma separated list of addresses. Returns null, if input is null. The function may throw an IllegalArgumentException if group parsing fails.
    • toInternetAddresses

      public static @Nullable Iterable<jakarta.mail.internet.InternetAddress> toInternetAddresses(@Nullable jakarta.mail.Address[] addresses)
      Filters the specified iterable of Addresses and returns a iterable that contains all elements from the argument that are of type InternetAddress.
    • joinEmailAddresses

      public static @Nullable String joinEmailAddresses(@Nullable Iterable<jakarta.mail.internet.InternetAddress> addresses, String split)
    • getFrom

      public static jakarta.mail.internet.InternetAddress getFrom(jakarta.mail.Message message) throws jakarta.mail.MessagingException
      Returns the single InternetAddress in the from header.
      Throws:
      jakarta.mail.MessagingException
    • getRecipients

      public static Iterable<jakarta.mail.internet.InternetAddress> getRecipients(jakarta.mail.Message message, @Nullable jakarta.mail.Message.RecipientType type)
      Returns an iterable over the recipients addresses of the given type.

      If type is null all recipients are returned.

    • getReplyTos

      public static Iterable<jakarta.mail.internet.InternetAddress> getReplyTos(jakarta.mail.Message message)
    • getAllHeaders

      public static Map<String, Iterable<String>> getAllHeaders(jakarta.mail.Message message) throws jakarta.mail.MessagingException
      Transforms all headers of the message into a map. Empty header lines will be skipped such that the mapped iterable only contains not-null and non-empty strings.
      Throws:
      jakarta.mail.MessagingException
    • parseHeaderLines

      public static Map<String, Iterable<String>> parseHeaderLines(List<String> headerLines)
      Transforms the given string list into a map header map. Splits the line at the first colon followed by a space. The part before the first ": " is used as key, the rest as value. If a line does not contain ": " it is ignored.
    • toInternetAddress

      public static Function<jakarta.mail.Address, jakarta.mail.internet.InternetAddress> toInternetAddress()