Skip to content

Commit

Permalink
Fix code smells
Browse files Browse the repository at this point in the history
  • Loading branch information
guillermocalvo committed Jul 21, 2023
1 parent acae562 commit 1d8a179
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@
import java.nio.ByteBuffer;
import java.util.Properties;

import static java.util.stream.Collectors.toList;

/**
* @author Sergio del Amo
* @since 1.0.0
Expand Down Expand Up @@ -100,7 +98,7 @@ private SendEmailRequest sendEmailRequest(@NonNull Email email) {
.message(message(email));
if (CollectionUtils.isNotEmpty(email.getReplyToCollection())) {
requestBuilder = requestBuilder.replyToAddresses(
email.getReplyToCollection().stream().map(Contact::getEmail).collect(toList()));
email.getReplyToCollection().stream().map(Contact::getEmail).toList());
}
return requestBuilder.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ public MailjetRequest compose(@NonNull @NotNull @Valid Email email) throws Email
JSONObject message = new JSONObject();
message.put(Emailv31.Message.FROM, createJsonObject(email.getFrom()));
if (CollectionUtils.isNotEmpty(email.getReplyToCollection())) {
if (email.getReplyToCollection().size() > 1) {
if (LOG.isWarnEnabled()) {
LOG.warn("Mailjet does not support multiple 'replyTo' addresses (Email has {} replyTo addresses)", email.getReplyToCollection().size());
}
if (email.getReplyToCollection().size() > 1 && LOG.isWarnEnabled()) {
LOG.warn("Mailjet does not support multiple 'replyTo' addresses (Email has {} replyTo addresses)", email.getReplyToCollection().size());
}
message.put(Emailv31.Message.REPLYTO, createJsonObject(CollectionUtils.last(email.getReplyToCollection())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,8 @@ public Message compose(@NonNull @NotNull @Valid Email email) throws EmailExcepti
message.setTo(email.getTo().stream().map(Contact::getEmail).collect(Collectors.toList()));
}
if (CollectionUtils.isNotEmpty(email.getReplyToCollection())) {
if (email.getReplyToCollection().size() > 1) {
if (LOG.isWarnEnabled()) {
LOG.warn("Postmark does not support multiple 'replyTo' addresses (Email has {} replyTo addresses)", email.getReplyToCollection().size());
}
if (email.getReplyToCollection().size() > 1 && LOG.isWarnEnabled()) {
LOG.warn("Postmark does not support multiple 'replyTo' addresses (Email has {} replyTo addresses)", email.getReplyToCollection().size());
}
message.setReplyTo(CollectionUtils.last(email.getReplyToCollection()).getEmail());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,8 @@ private Mail createMail(@NonNull Email email) {
private Optional<com.sendgrid.helpers.mail.objects.Email> createReplyTo(@NonNull Email email) {
if (CollectionUtils.isEmpty(email.getReplyToCollection())) {
return Optional.empty();
} else if (email.getReplyToCollection().size() > 1) {
if (LOG.isWarnEnabled()) {
LOG.warn("Sendgrid does not support multiple 'replyTo' addresses (Email has {} replyTo addresses)", email.getReplyToCollection().size());
}
} else if (email.getReplyToCollection().size() > 1 && LOG.isWarnEnabled()) {
LOG.warn("Sendgrid does not support multiple 'replyTo' addresses (Email has {} replyTo addresses)", email.getReplyToCollection().size());
}
final Contact contact = CollectionUtils.last(email.getReplyToCollection());
com.sendgrid.helpers.mail.objects.Email replyTo = new com.sendgrid.helpers.mail.objects.Email();
Expand Down

0 comments on commit 1d8a179

Please sign in to comment.