@Test public void fromAddressListShouldReturnEmptyWhenNullAddress() { assertThat(Emailer.fromAddressList(null)) .isEmpty(); }
public static List<Emailer> fromAddressList(AddressList list) { return Optional.ofNullable(list) .map(addresses -> addresses.flatten() .stream() .map(Emailer::fromMailbox) .collect(Guavate.toImmutableList())) .orElse(ImmutableList.of()); }
Emailer { public static List<Emailer> fromAddressList(AddressList list) { return Optional.ofNullable(list) .map(addresses -> addresses.flatten() .stream() .map(Emailer::fromMailbox) .collect(Guavate.toImmutableList())) .orElse(ImmutableList.of()); } }
Emailer { public static List<Emailer> fromAddressList(AddressList list) { return Optional.ofNullable(list) .map(addresses -> addresses.flatten() .stream() .map(Emailer::fromMailbox) .collect(Guavate.toImmutableList())) .orElse(ImmutableList.of()); } @VisibleForTesting  Emailer(Optional<String> name, Optional<String> email); }
Emailer { public static List<Emailer> fromAddressList(AddressList list) { return Optional.ofNullable(list) .map(addresses -> addresses.flatten() .stream() .map(Emailer::fromMailbox) .collect(Guavate.toImmutableList())) .orElse(ImmutableList.of()); } @VisibleForTesting  Emailer(Optional<String> name, Optional<String> email); static List<Emailer> fromAddressList(AddressList list); static Optional<Emailer> firstFromMailboxList(MailboxList list); static Builder builder(); Optional<String> getName(); Optional<String> getEmail(); @JsonIgnore MailAddress toMailAddress(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); }
Emailer { public static List<Emailer> fromAddressList(AddressList list) { return Optional.ofNullable(list) .map(addresses -> addresses.flatten() .stream() .map(Emailer::fromMailbox) .collect(Guavate.toImmutableList())) .orElse(ImmutableList.of()); } @VisibleForTesting  Emailer(Optional<String> name, Optional<String> email); static List<Emailer> fromAddressList(AddressList list); static Optional<Emailer> firstFromMailboxList(MailboxList list); static Builder builder(); Optional<String> getName(); Optional<String> getEmail(); @JsonIgnore MailAddress toMailAddress(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString();  }