EmailAddressUtil { public static Collection<EmailAddress> parse(final String userInput) { return Collections2.transform( EmailAddressTokenizer.tokenize(userInput), new Function<EmailAddressToken, EmailAddress>() { @NullableDecl @Override public EmailAddress apply(@NullableDecl EmailAddressToken token) { return token != null ? token.getEmailAddress() : null; } } ); }  static String toString(EmailAddress emailAddress); static String toHeaderValue(Collection<EmailAddress> emailAddresses); static boolean equalCollections(final Collection<EmailAddress> a, final Collection<EmailAddress> b); static boolean isValid(final EmailAddress emailAddress); static boolean isValid(final String email); static Collection<EmailAddress> parse(final String userInput); static String shorten(final String input);  }
@Test public void twoEmailAddressesWithLabel() { final String input = "\"Last, First\" <first.last@example.com>, Test <test@example.com>"; final Collection<EmailAddress> expected = ImmutableList.of( EmailAddress.builder().email("first.last@example.com").name("Last, First").build(), EmailAddress.builder().email("test@example.com").name("Test").build() ); final Collection<EmailAddress> actual = EmailAddressUtil.parse(input); Assert.assertArrayEquals( expected.toArray(new EmailAddress[0]), actual.toArray(new EmailAddress[0]) ); }