@Test public void testSetToList() throws MessagingException { final String to1 = "recipient1@email.com"; final String to2 = "recipient2@email.com"; PersonModelView person1 = new PersonModelView() { { setEmail(to1); } }; PersonModelView person2 = new PersonModelView() { { setEmail(to2); } }; String result = EmailerFactory.buildEmailList(Arrays.asList(person1, person2)); assertEquals(to1 + "," + to2, result); }
public static String buildEmailList(final Iterable< ? extends HasEmail> list) { Iterator<String> iter = new Iterator<String>() { Iterator< ? extends HasEmail> innerIterator = list.iterator(); @Override public boolean hasNext() { return innerIterator.hasNext(); } @Override public String next() { return innerIterator.next().getEmail(); } @Override public void remove() { } }; return StringUtils.join(iter, ','); }
EmailerFactory { public static String buildEmailList(final Iterable< ? extends HasEmail> list) { Iterator<String> iter = new Iterator<String>() { Iterator< ? extends HasEmail> innerIterator = list.iterator(); @Override public boolean hasNext() { return innerIterator.hasNext(); } @Override public String next() { return innerIterator.next().getEmail(); } @Override public void remove() { } }; return StringUtils.join(iter, ','); } }
EmailerFactory { public static String buildEmailList(final Iterable< ? extends HasEmail> list) { Iterator<String> iter = new Iterator<String>() { Iterator< ? extends HasEmail> innerIterator = list.iterator(); @Override public boolean hasNext() { return innerIterator.hasNext(); } @Override public String next() { return innerIterator.next().getEmail(); } @Override public void remove() { } }; return StringUtils.join(iter, ','); } EmailerFactory(final String inMailTransportProtocol, final Map<String, String> inTransportConfiguration,
            final String inDefaultFromAddress); }
EmailerFactory { public static String buildEmailList(final Iterable< ? extends HasEmail> list) { Iterator<String> iter = new Iterator<String>() { Iterator< ? extends HasEmail> innerIterator = list.iterator(); @Override public boolean hasNext() { return innerIterator.hasNext(); } @Override public String next() { return innerIterator.next().getEmail(); } @Override public void remove() { } }; return StringUtils.join(iter, ','); } EmailerFactory(final String inMailTransportProtocol, final Map<String, String> inTransportConfiguration,
            final String inDefaultFromAddress); static String buildEmailList(final Iterable< ? extends HasEmail> list); void sendMail(final Message message); MimeMessage createMessage(); void setTo(final MimeMessage message, final String emailToString); void setCc(final MimeMessage message, final String emailToString); void setBcc(final MimeMessage message, final String emailToString); void setFrom(final MimeMessage message, final String emailFromString); void setReplyTo(final MimeMessage message, final String addressString); void setSubject(final MimeMessage message, final String subject); void setTextBody(final MimeMessage message, final String textBody); void setHtmlBody(final MimeMessage message, final String htmlBody); Part addAttachmentPart(final Message message); Part addAttachmentMessage(final Message message, final Message attachedMessage); }
EmailerFactory { public static String buildEmailList(final Iterable< ? extends HasEmail> list) { Iterator<String> iter = new Iterator<String>() { Iterator< ? extends HasEmail> innerIterator = list.iterator(); @Override public boolean hasNext() { return innerIterator.hasNext(); } @Override public String next() { return innerIterator.next().getEmail(); } @Override public void remove() { } }; return StringUtils.join(iter, ','); } EmailerFactory(final String inMailTransportProtocol, final Map<String, String> inTransportConfiguration,
            final String inDefaultFromAddress); static String buildEmailList(final Iterable< ? extends HasEmail> list); void sendMail(final Message message); MimeMessage createMessage(); void setTo(final MimeMessage message, final String emailToString); void setCc(final MimeMessage message, final String emailToString); void setBcc(final MimeMessage message, final String emailToString); void setFrom(final MimeMessage message, final String emailFromString); void setReplyTo(final MimeMessage message, final String addressString); void setSubject(final MimeMessage message, final String subject); void setTextBody(final MimeMessage message, final String textBody); void setHtmlBody(final MimeMessage message, final String htmlBody); Part addAttachmentPart(final Message message); Part addAttachmentMessage(final Message message, final Message attachedMessage);  }