@@ -231,20 +231,6 @@ public EmailBuilder textHTML(@Nullable final String textHTML) {
231231 return this ;
232232 }
233233
234- /**
235- * Adds a new {@link Recipient} to the list on account of name, address with recipient type {@link Message.RecipientType#TO}.
236- *
237- * @param name The name of the recipient.
238- * @param address The emailaddress of the recipient.
239- * @see #recipients
240- * @see Recipient
241- */
242- public EmailBuilder to (@ Nullable final String name , @ Nonnull final String address ) {
243- checkNonEmptyArgument (address , "address" );
244- recipients .add (new Recipient (name , address , Message .RecipientType .TO ));
245- return this ;
246- }
247-
248234 /**
249235 * Adds new {@link Recipient} instances to the list on account of name, address with recipient type {@link Message.RecipientType#TO}.
250236 *
@@ -260,23 +246,31 @@ public EmailBuilder to(@Nonnull final Recipient... recipientsToAdd) {
260246 }
261247
262248 /**
263- * Adds anew {@link Recipient} instances to the list on account of empty name, address with recipient type {@link Message.RecipientType#TO}. List can be
264- * comma ',' or semicolon ';' separated.
249+ * Delegates to {@link #to(String, String)} while omitting the name used for the recipient(s).
250+ */
251+ public EmailBuilder to (@ Nonnull final String emailAddressList ) {
252+ return to (null , emailAddressList );
253+ }
254+
255+ /**
256+ * Adds anew {@link Recipient} instances to the list on account of given name, address with recipient type {@link Message.RecipientType#TO}.
257+ * List can be comma ',' or semicolon ';' separated.
265258 *
266- * @param emailAddressList The recipients whose address to use for both name and address
259+ * @param name The name of the recipient(s).
260+ * @param emailAddressList The emailaddresses of the recipients (will be singular in most use cases).
267261 * @see #recipients
268262 * @see Recipient
269263 */
270- public EmailBuilder to (@ Nonnull final String emailAddressList ) {
264+ public EmailBuilder to (@ Nullable final String name , @ Nonnull final String emailAddressList ) {
271265 checkNonEmptyArgument (emailAddressList , "emailAddressList" );
272- return addCommaOrSemicolonSeparatedEmailAddresses (emailAddressList , Message .RecipientType .TO );
266+ return addCommaOrSemicolonSeparatedEmailAddresses (name , emailAddressList , Message .RecipientType .TO );
273267 }
274268
275269 @ Nonnull
276- private EmailBuilder addCommaOrSemicolonSeparatedEmailAddresses (@ Nonnull final String emailAddressList , @ Nonnull final Message .RecipientType type ) {
270+ private EmailBuilder addCommaOrSemicolonSeparatedEmailAddresses (@ Nullable final String name , @ Nonnull final String emailAddressList , @ Nonnull final Message .RecipientType type ) {
277271 checkNonEmptyArgument (type , "type" );
278272 for (final String emailAddress : extractEmailAddresses (checkNonEmptyArgument (emailAddressList , "emailAddressList" ))) {
279- recipients .add (new Recipient (null , emailAddress , type ));
273+ recipients .add (new Recipient (name , emailAddress , type ));
280274 }
281275 return this ;
282276 }
@@ -295,21 +289,6 @@ public EmailBuilder to(@Nonnull final String... emailAddresses) {
295289 return this ;
296290 }
297291
298- /**
299- * Adds a new {@link Recipient} to the list on account of name, address with recipient type {@link Message.RecipientType#CC}.
300- *
301- * @param name The name of the recipient.
302- * @param address The emailaddress of the recipient.
303- * @see #recipients
304- * @see Recipient
305- */
306- @ SuppressWarnings ({ "WeakerAccess" , "QuestionableName" })
307- public EmailBuilder cc (@ Nullable final String name , @ Nonnull final String address ) {
308- checkNonEmptyArgument (address , "address" );
309- recipients .add (new Recipient (name , address , Message .RecipientType .CC ));
310- return this ;
311- }
312-
313292 /**
314293 * Adds new {@link Recipient} instances to the list on account of empty name, address with recipient type {@link Message.RecipientType#CC}.
315294 *
@@ -324,19 +303,29 @@ public EmailBuilder cc(@Nonnull final String... emailAddresses) {
324303 }
325304 return this ;
326305 }
306+
307+
308+ /**
309+ * Delegates to {@link #cc(String, String)} while omitting the name for the CC recipient(s).
310+ */
311+ @ SuppressWarnings ("QuestionableName" )
312+ public EmailBuilder cc (@ Nonnull final String emailAddressList ) {
313+ return cc (null , emailAddressList );
314+ }
327315
328316 /**
329317 * Adds anew {@link Recipient} instances to the list on account of empty name, address with recipient type {@link Message.RecipientType#CC}. List can be
330318 * comma ',' or semicolon ';' separated.
331319 *
320+ * @param name The name of the recipient(s).
332321 * @param emailAddressList The recipients whose address to use for both name and address
333322 * @see #recipients
334323 * @see Recipient
335324 */
336325 @ SuppressWarnings ("QuestionableName" )
337- public EmailBuilder cc (@ Nonnull final String emailAddressList ) {
326+ public EmailBuilder cc (@ Nullable String name , @ Nonnull final String emailAddressList ) {
338327 checkNonEmptyArgument (emailAddressList , "emailAddressList" );
339- return addCommaOrSemicolonSeparatedEmailAddresses (emailAddressList , Message .RecipientType .CC );
328+ return addCommaOrSemicolonSeparatedEmailAddresses (name , emailAddressList , Message .RecipientType .CC );
340329 }
341330
342331 /**
@@ -354,21 +343,6 @@ public EmailBuilder cc(@Nonnull final Recipient... recipientsToAdd) {
354343 return this ;
355344 }
356345
357- /**
358- * Adds a new {@link Recipient} to the list on account of name, address with recipient type {@link Message.RecipientType#BCC}.
359- *
360- * @param name The name of the recipient.
361- * @param address The emailaddress of the recipient.
362- * @see #recipients
363- * @see Recipient
364- */
365- @ SuppressWarnings ("WeakerAccess" )
366- public EmailBuilder bcc (@ Nullable final String name , @ Nonnull final String address ) {
367- checkNonEmptyArgument (address , "address" );
368- recipients .add (new Recipient (name , address , Message .RecipientType .BCC ));
369- return this ;
370- }
371-
372346 /**
373347 * Adds new {@link Recipient} instances to the list on account of empty name, address with recipient type {@link Message.RecipientType#BCC}.
374348 *
@@ -382,18 +356,26 @@ public EmailBuilder bcc(@Nonnull final String... emailAddresses) {
382356 }
383357 return this ;
384358 }
359+
360+ /**
361+ * Delegates to {@link #bcc(String, String)} while omitting the name for the BCC recipient(s).
362+ */
363+ public EmailBuilder bcc (@ Nonnull final String emailAddressList ) {
364+ return bcc (null , emailAddressList );
365+ }
385366
386367 /**
387368 * Adds anew {@link Recipient} instances to the list on account of empty name, address with recipient type {@link Message.RecipientType#BCC}. List can be
388369 * comma ',' or semicolon ';' separated.
389370 *
371+ * @param name The name of the recipient(s).
390372 * @param emailAddressList The recipients whose address to use for both name and address
391373 * @see #recipients
392374 * @see Recipient
393375 */
394- public EmailBuilder bcc (@ Nonnull final String emailAddressList ) {
376+ public EmailBuilder bcc (@ Nullable String name , @ Nonnull final String emailAddressList ) {
395377 checkNonEmptyArgument (emailAddressList , "emailAddressList" );
396- return addCommaOrSemicolonSeparatedEmailAddresses (emailAddressList , Message .RecipientType .BCC );
378+ return addCommaOrSemicolonSeparatedEmailAddresses (name , emailAddressList , Message .RecipientType .BCC );
397379 }
398380
399381 /**
0 commit comments