diff --git a/src/main/java/com/sendgrid/APICallback.java b/src/main/java/com/sendgrid/APICallback.java index 8504f41c..101052d6 100644 --- a/src/main/java/com/sendgrid/APICallback.java +++ b/src/main/java/com/sendgrid/APICallback.java @@ -1,19 +1,22 @@ package com.sendgrid; /** - * An interface describing a callback mechanism for the - * asynchronous, rate limit aware API connection. + * An interface describing a callback mechanism for the asynchronous, rate limit aware API + * connection. */ public interface APICallback { - /** - * Callback method in case of an error. - * @param ex the error that was thrown. - */ - void error(Exception ex); - /** - * Callback method in case of a valid response. - * @param response the valid response. - */ - void response(Response response); + /** + * Callback method in case of an error. + * + * @param ex the error that was thrown. + */ + void error(Exception ex); + + /** + * Callback method in case of a valid response. + * + * @param response the valid response. + */ + void response(Response response); } diff --git a/src/main/java/com/sendgrid/RateLimitException.java b/src/main/java/com/sendgrid/RateLimitException.java index 4912ac92..7a2570ac 100644 --- a/src/main/java/com/sendgrid/RateLimitException.java +++ b/src/main/java/com/sendgrid/RateLimitException.java @@ -1,36 +1,40 @@ package com.sendgrid; /** - * An exception thrown when the maximum number of retries - * have occurred, and the API calls are still rate limited. + * An exception thrown when the maximum number of retries have occurred, and the API calls are still + * rate limited. */ public class RateLimitException extends Exception { - private final Request request; - private final int retryCount; - /** - * Construct a new exception. - * @param request the originating request object. - * @param retryCount the number of times a retry was attempted. - */ - public RateLimitException(Request request, int retryCount) { - this.request = request; - this.retryCount = retryCount; - } + private final Request request; + private final int retryCount; - /** - * Get the originating request object. - * @return the request object. - */ - public Request getRequest() { - return this.request; - } + /** + * Construct a new exception. + * + * @param request the originating request object. + * @param retryCount the number of times a retry was attempted. + */ + public RateLimitException(Request request, int retryCount) { + this.request = request; + this.retryCount = retryCount; + } - /** - * Get the number of times the action was attemted. - * @return the retry count. - */ - public int getRetryCount() { - return this.retryCount; - } + /** + * Get the originating request object. + * + * @return the request object. + */ + public Request getRequest() { + return this.request; + } + + /** + * Get the number of times the action was attemted. + * + * @return the retry count. + */ + public int getRetryCount() { + return this.retryCount; + } } diff --git a/src/main/java/com/sendgrid/helpers/mail/Mail.java b/src/main/java/com/sendgrid/helpers/mail/Mail.java index 29dd2325..24eb19de 100644 --- a/src/main/java/com/sendgrid/helpers/mail/Mail.java +++ b/src/main/java/com/sendgrid/helpers/mail/Mail.java @@ -5,8 +5,13 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.SerializationFeature; -import com.sendgrid.helpers.mail.objects.*; - +import com.sendgrid.helpers.mail.objects.ASM; +import com.sendgrid.helpers.mail.objects.Attachments; +import com.sendgrid.helpers.mail.objects.Content; +import com.sendgrid.helpers.mail.objects.Email; +import com.sendgrid.helpers.mail.objects.MailSettings; +import com.sendgrid.helpers.mail.objects.Personalization; +import com.sendgrid.helpers.mail.objects.TrackingSettings; import java.io.IOException; import java.util.ArrayList; import java.util.HashMap; @@ -14,95 +19,106 @@ import java.util.Map; /** - * Class Mail builds an object that sends an email through Twilio SendGrid. - * Note that this object is not thread safe. + * Class Mail builds an object that sends an email through Twilio SendGrid. Note that this object is + * not thread safe. */ @JsonInclude(Include.NON_DEFAULT) public class Mail { /** The email's from field. */ - @JsonProperty("from") public Email from; + @JsonProperty("from") + public Email from; - /** The email's subject line. This is the global, or - * “message level”, subject of your email. This may - * be overridden by personalizations[x].subject. + /** + * The email's subject line. This is the global, or “message level”, subject of your email. This + * may be overridden by personalizations[x].subject. */ - @JsonProperty("subject") public String subject; + @JsonProperty("subject") + public String subject; - /** - * The email's personalization. Each object within - * personalizations can be thought of as an envelope - * - it defines who should receive an individual message - * and how that message should be handled. + /** + * The email's personalization. Each object within personalizations can be thought of as an + * envelope - it defines who should receive an individual message and how that message should be + * handled. */ - @JsonProperty("personalizations") public List personalization; + @JsonProperty("personalizations") + public List personalization; /** The email's content. */ - @JsonProperty("content") public List content; + @JsonProperty("content") + public List content; /** The email's attachments. */ - @JsonProperty("attachments") public List attachments; + @JsonProperty("attachments") + public List attachments; /** The email's template ID. */ - @JsonProperty("template_id") public String templateId; + @JsonProperty("template_id") + public String templateId; - /** - * The email's sections. An object of key/value pairs that - * define block sections of code to be used as substitutions. + /** + * The email's sections. An object of key/value pairs that define block sections of code to be + * used as substitutions. */ - @JsonProperty("sections") public Map sections; + @JsonProperty("sections") + public Map sections; /** The email's headers. */ - @JsonProperty("headers") public Map headers; + @JsonProperty("headers") + public Map headers; /** The email's categories. */ - @JsonProperty("categories") public List categories; - - /** - * The email's custom arguments. Values that are specific to - * the entire send that will be carried along with the email - * and its activity data. Substitutions will not be made on - * custom arguments, so any string that is entered into this - * parameter will be assumed to be the custom argument that - * you would like to be used. This parameter is overridden by - * personalizations[x].custom_args if that parameter has been - * defined. Total custom args size may not exceed 10,000 bytes. - */ - @JsonProperty("custom_args") public Map customArgs; - - /** - * A unix timestamp allowing you to specify when you want - * your email to be delivered. This may be overridden by - * the personalizations[x].send_at parameter. Scheduling - * more than 72 hours in advance is forbidden. - */ - @JsonProperty("send_at") public long sendAt; - - /** - * This ID represents a batch of emails to be sent at the - * same time. Including a batch_id in your request allows - * you include this email in that batch, and also enables - * you to cancel or pause the delivery of that batch. For - * more information, see https://sendgrid.com/docs/API_Reference/Web_API_v3/cancel_schedule_send. - */ - @JsonProperty("batch_id") public String batchId; + @JsonProperty("categories") + public List categories; + + /** + * The email's custom arguments. Values that are specific to the entire send that will be carried + * along with the email and its activity data. Substitutions will not be made on custom arguments, + * so any string that is entered into this parameter will be assumed to be the custom argument + * that you would like to be used. This parameter is overridden by personalizations[x].custom_args + * if that parameter has been defined. Total custom args size may not exceed 10,000 bytes. + */ + @JsonProperty("custom_args") + public Map customArgs; + + /** + * A unix timestamp allowing you to specify when you want your email to be delivered. This may be + * overridden by the personalizations[x].send_at parameter. Scheduling more than 72 hours in + * advance is forbidden. + */ + @JsonProperty("send_at") + public long sendAt; + + /** + * This ID represents a batch of emails to be sent at the same time. Including a batch_id in your + * request allows you include this email in that batch, and also enables you to cancel or pause + * the delivery of that batch. For more information, see https://sendgrid.com/docs/API_Reference/Web_API_v3/cancel_schedule_send. + */ + @JsonProperty("batch_id") + public String batchId; /** The email's unsubscribe handling object. */ - @JsonProperty("asm") public ASM asm; + @JsonProperty("asm") + public ASM asm; /** The email's IP pool name. */ - @JsonProperty("ip_pool_name") public String ipPoolId; + @JsonProperty("ip_pool_name") + public String ipPoolId; /** The email's mail settings. */ - @JsonProperty("mail_settings") public MailSettings mailSettings; + @JsonProperty("mail_settings") + public MailSettings mailSettings; /** The email's tracking settings. */ - @JsonProperty("tracking_settings") public TrackingSettings trackingSettings; + @JsonProperty("tracking_settings") + public TrackingSettings trackingSettings; /** The email's reply to address. */ - @JsonProperty("reply_to") public Email replyTo; + @JsonProperty("reply_to") + public Email replyTo; private static final ObjectMapper SORTED_MAPPER = new ObjectMapper(); + static { SORTED_MAPPER.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true); } @@ -118,17 +134,17 @@ private List addToList(T element, List defaultList) { } } - private Map addToMap(K key, V value, Map defaultMap) { + private Map addToMap(K key, V value, Map defaultMap) { if (defaultMap != null) { defaultMap.put(key, value); return defaultMap; } else { - Map map = new HashMap(); + Map map = new HashMap(); map.put(key, value); return map; } } - + /** Construct a new Mail object. */ public Mail() { return; @@ -136,13 +152,13 @@ public Mail() { /** * Construct a new Mail object. + * * @param from the email's from address. * @param subject the email's subject line. * @param to the email's recipient. * @param content the email's content. */ - public Mail(Email from, String subject, Email to, Content content) - { + public Mail(Email from, String subject, Email to, Content content) { this.setFrom(from); this.setSubject(subject); Personalization personalization = new Personalization(); @@ -153,6 +169,7 @@ public Mail(Email from, String subject, Email to, Content content) /** * Get the email's from address. + * * @return the email's from address. */ @JsonProperty("from") @@ -162,6 +179,7 @@ public Email getFrom() { /** * Set the email's from address. + * * @param from the email's from address. */ public void setFrom(Email from) { @@ -170,6 +188,7 @@ public void setFrom(Email from) { /** * Get the email's subject line. + * * @return the email's subject line. */ @JsonProperty("subject") @@ -179,6 +198,7 @@ public String getSubject() { /** * Set the email's subject line. + * * @param subject the email's subject line. */ public void setSubject(String subject) { @@ -187,6 +207,7 @@ public void setSubject(String subject) { /** * Get the email's unsubscribe handling object (ASM). + * * @return the email's ASM. */ @JsonProperty("asm") @@ -196,6 +217,7 @@ public ASM getASM() { /** * Set the email's unsubscribe handling object (ASM). + * * @param asm the email's ASM. */ public void setASM(ASM asm) { @@ -203,8 +225,9 @@ public void setASM(ASM asm) { } /** - * Get the email's personalizations. Content added to the returned - * list will be included when sent. + * Get the email's personalizations. Content added to the returned list will be included when + * sent. + * * @return the email's personalizations. */ @JsonProperty("personalizations") @@ -214,6 +237,7 @@ public List getPersonalization() { /** * Add a personalizaton to the email. + * * @param personalization a personalization. */ public void addPersonalization(Personalization personalization) { @@ -221,8 +245,8 @@ public void addPersonalization(Personalization personalization) { } /** - * Get the email's content. Content added to the returned list - * will be included when sent. + * Get the email's content. Content added to the returned list will be included when sent. + * * @return the email's content. */ @JsonProperty("content") @@ -232,6 +256,7 @@ public List getContent() { /** * Add content to this email. + * * @param content content to add to this email. */ public void addContent(Content content) { @@ -242,8 +267,9 @@ public void addContent(Content content) { } /** - * Get the email's attachments. Attachments added to the returned - * list will be included when sent. + * Get the email's attachments. Attachments added to the returned list will be included when + * sent. + * * @return the email's attachments. */ @JsonProperty("attachments") @@ -253,6 +279,7 @@ public List getAttachments() { /** * Add attachments to the email. + * * @param attachments attachments to add. */ public void addAttachments(Attachments attachments) { @@ -267,6 +294,7 @@ public void addAttachments(Attachments attachments) { /** * Get the email's template ID. + * * @return the email's template ID. */ @JsonProperty("template_id") @@ -276,6 +304,7 @@ public String getTemplateId() { /** * Set the email's template ID. + * * @param templateId the email's template ID. */ public void setTemplateId(String templateId) { @@ -283,17 +312,18 @@ public void setTemplateId(String templateId) { } /** - * Get the email's sections. Sections added to the returned list - * will be included when sent. + * Get the email's sections. Sections added to the returned list will be included when sent. + * * @return the email's sections. */ @JsonProperty("sections") - public Map getSections() { + public Map getSections() { return sections; } /** * Add a section to the email. + * * @param key the section's key. * @param value the section's value. */ @@ -302,17 +332,18 @@ public void addSection(String key, String value) { } /** - * Get the email's headers. Headers added to the returned list - * will be included when sent. + * Get the email's headers. Headers added to the returned list will be included when sent. + * * @return the email's headers. */ @JsonProperty("headers") - public Map getHeaders() { + public Map getHeaders() { return headers; } /** * Add a header to the email. + * * @param key the header's key. * @param value the header's value. */ @@ -321,8 +352,8 @@ public void addHeader(String key, String value) { } /** - * Get the email's categories. Categories added to the returned list - * will be included when sent. + * Get the email's categories. Categories added to the returned list will be included when sent. + * * @return the email's categories. */ @JsonProperty("categories") @@ -332,6 +363,7 @@ public List getCategories() { /** * Add a category to the email. + * * @param category the category. */ public void addCategory(String category) { @@ -339,17 +371,19 @@ public void addCategory(String category) { } /** - * Get the email's custom arguments. Custom arguments added to the returned list - * will be included when sent. + * Get the email's custom arguments. Custom arguments added to the returned list will be included + * when sent. + * * @return the email's custom arguments. */ @JsonProperty("custom_args") - public Map getCustomArgs() { + public Map getCustomArgs() { return customArgs; } /** * Add a custom argument to the email. + * * @param key argument's key. * @param value the argument's value. */ @@ -359,6 +393,7 @@ public void addCustomArg(String key, String value) { /** * Get the email's send at time (Unix timestamp). + * * @return the email's send at time. */ @JsonProperty("send_at") @@ -368,6 +403,7 @@ public long sendAt() { /** * Set the email's send at time (Unix timestamp). + * * @param sendAt the send at time. */ public void setSendAt(long sendAt) { @@ -376,6 +412,7 @@ public void setSendAt(long sendAt) { /** * Get the email's batch ID. + * * @return the batch ID. */ @JsonProperty("batch_id") @@ -385,6 +422,7 @@ public String getBatchId() { /** * Set the email's batch ID. + * * @param batchId the batch ID. */ public void setBatchId(String batchId) { @@ -393,6 +431,7 @@ public void setBatchId(String batchId) { /** * Get the email's IP pool ID. + * * @return the IP pool ID. */ @JsonProperty("ip_pool_name") @@ -402,6 +441,7 @@ public String getIpPoolId() { /** * Set the email's IP pool ID. + * * @param ipPoolId the IP pool ID. */ public void setIpPoolId(String ipPoolId) { @@ -410,6 +450,7 @@ public void setIpPoolId(String ipPoolId) { /** * Get the email's settings. + * * @return the settings. */ @JsonProperty("mail_settings") @@ -419,6 +460,7 @@ public MailSettings getMailSettings() { /** * Set the email's settings. + * * @param mailSettings the settings. */ public void setMailSettings(MailSettings mailSettings) { @@ -427,6 +469,7 @@ public void setMailSettings(MailSettings mailSettings) { /** * Get the email's tracking settings. + * * @return the tracking settings. */ @JsonProperty("tracking_settings") @@ -436,6 +479,7 @@ public TrackingSettings getTrackingSettings() { /** * Set the email's tracking settings. + * * @param trackingSettings the tracking settings. */ public void setTrackingSettings(TrackingSettings trackingSettings) { @@ -444,6 +488,7 @@ public void setTrackingSettings(TrackingSettings trackingSettings) { /** * Get the email's reply to address. + * * @return the reply to address. */ @JsonProperty("reply_to") @@ -453,6 +498,7 @@ public Email getReplyto() { /** * Set the email's reply to address. + * * @param replyTo the reply to address. */ public void setReplyTo(Email replyTo) { @@ -461,6 +507,7 @@ public void setReplyTo(Email replyTo) { /** * Create a string represenation of the Mail object JSON. + * * @return a JSON string. * @throws IOException in case of a JSON marshal error. */ @@ -475,6 +522,7 @@ public String build() throws IOException { /** * Create a string represenation of the Mail object JSON and pretty print it. + * * @return a pretty JSON string. * @throws IOException in case of a JSON marshal error. */ @@ -505,55 +553,75 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Mail other = (Mail) obj; if (batchId == null) { - if (other.batchId != null) + if (other.batchId != null) { return false; - } else if (!batchId.equals(other.batchId)) + } + } else if (!batchId.equals(other.batchId)) { return false; + } if (categories == null) { - if (other.categories != null) + if (other.categories != null) { return false; - } else if (!categories.equals(other.categories)) + } + } else if (!categories.equals(other.categories)) { return false; + } if (customArgs == null) { - if (other.customArgs != null) + if (other.customArgs != null) { return false; - } else if (!customArgs.equals(other.customArgs)) + } + } else if (!customArgs.equals(other.customArgs)) { return false; + } if (headers == null) { - if (other.headers != null) + if (other.headers != null) { return false; - } else if (!headers.equals(other.headers)) + } + } else if (!headers.equals(other.headers)) { return false; + } if (ipPoolId == null) { - if (other.ipPoolId != null) + if (other.ipPoolId != null) { return false; - } else if (!ipPoolId.equals(other.ipPoolId)) + } + } else if (!ipPoolId.equals(other.ipPoolId)) { return false; + } if (sections == null) { - if (other.sections != null) + if (other.sections != null) { return false; - } else if (!sections.equals(other.sections)) + } + } else if (!sections.equals(other.sections)) { return false; - if (sendAt != other.sendAt) + } + if (sendAt != other.sendAt) { return false; + } if (subject == null) { - if (other.subject != null) + if (other.subject != null) { return false; - } else if (!subject.equals(other.subject)) + } + } else if (!subject.equals(other.subject)) { return false; + } if (templateId == null) { - if (other.templateId != null) + if (other.templateId != null) { return false; - } else if (!templateId.equals(other.templateId)) + } + } else if (!templateId.equals(other.templateId)) { return false; + } return true; } -} \ No newline at end of file +} diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java b/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java index a34895f2..44ce4228 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/ASM.java @@ -3,28 +3,31 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; - import java.util.Arrays; @JsonInclude(Include.NON_DEFAULT) public class ASM { - @JsonProperty("group_id") private int groupId; - @JsonProperty("groups_to_display") private int[] groupsToDisplay; - + + @JsonProperty("group_id") + private int groupId; + + @JsonProperty("groups_to_display") + private int[] groupsToDisplay; + @JsonProperty("group_id") public int getGroupId() { return groupId; } - + public void setGroupId(int groupId) { this.groupId = groupId; } - + @JsonProperty("groups_to_display") public int[] getGroupsToDisplay() { return groupsToDisplay; } - + public void setGroupsToDisplay(int[] groupsToDisplay) { this.groupsToDisplay = Arrays.copyOf(groupsToDisplay, groupsToDisplay.length); } @@ -40,17 +43,22 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } ASM other = (ASM) obj; - if (groupId != other.groupId) + if (groupId != other.groupId) { return false; - if (!Arrays.equals(groupsToDisplay, other.groupsToDisplay)) + } + if (!Arrays.equals(groupsToDisplay, other.groupsToDisplay)) { return false; + } return true; } } \ No newline at end of file diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java b/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java index 969c1630..9a3ff1b4 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/Attachments.java @@ -4,68 +4,74 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; import org.apache.commons.codec.binary.Base64; -import java.io.*; - /** * An attachment object. */ @JsonInclude(Include.NON_DEFAULT) public class Attachments { - + /** The attachment content. */ - @JsonProperty("content") private String content; + @JsonProperty("content") + private String content; - /** - * The mime type of the content you are attaching. For example, - * “text/plain” or “text/html”. + /** + * The mime type of the content you are attaching. For example, “text/plain” or “text/html”. */ - @JsonProperty("type") private String type; + @JsonProperty("type") + private String type; /** The attachment file name. */ - @JsonProperty("filename") private String filename; + @JsonProperty("filename") + private String filename; /** The attachment disposition. */ - @JsonProperty("disposition") private String disposition; + @JsonProperty("disposition") + private String disposition; - /** - * The attachment content ID. This is used when the - * disposition is set to “inline” and the attachment - * is an image, allowing the file to be displayed within - * the body of your email. + /** + * The attachment content ID. This is used when the disposition is set to “inline” and the + * attachment is an image, allowing the file to be displayed within the body of your email. */ - @JsonProperty("content_id") private String contentId; + @JsonProperty("content_id") + private String contentId; /** * Get the attachment's content. + * * @return the content. */ - @JsonProperty("content") + @JsonProperty("content") public String getContent() { return content; } /** * Set the attachment's content. + * * @param content the content. */ public void setContent(String content) { this.content = content; } - + /** - * Get the mime type of the content you are attaching. For example, - * “text/plain” or “text/html”. + * Get the mime type of the content you are attaching. For example, “text/plain” or “text/html”. + * * @return the mime type. */ - @JsonProperty("type") + @JsonProperty("type") public String getType() { return type; } - + /** * Set the mime type of the content. + * * @param type the mime type. */ public void setType(String type) { @@ -74,38 +80,39 @@ public void setType(String type) { /** * Get the filename for this attachment. + * * @return the file name. */ - @JsonProperty("filename") + @JsonProperty("filename") public String getFilename() { return filename; } - + /** * Set the filename for this attachment. + * * @param filename the filename. */ public void setFilename(String filename) { this.filename = filename; } - + /** - * Get the content-disposition of the attachment specifying - * how you would like the attachment to be displayed. - * For example, “inline” results in the attached file - * being displayed automatically within the message - * while “attachment” results in the attached file - * requiring some action to be taken before it is - * displayed (e.g. opening or downloading the file). + * Get the content-disposition of the attachment specifying how you would like the attachment to + * be displayed. For example, “inline” results in the attached file being displayed automatically + * within the message while “attachment” results in the attached file requiring some action to be + * taken before it is displayed (e.g. opening or downloading the file). + * * @return the disposition. */ - @JsonProperty("disposition") + @JsonProperty("disposition") public String getDisposition() { return disposition; } - + /** * Set the content-disposition of the attachment. + * * @param disposition the disposition. */ public void setDisposition(String disposition) { @@ -113,19 +120,19 @@ public void setDisposition(String disposition) { } /** - * Get the attachment content ID. This is used when the - * disposition is set to “inline” and the attachment - * is an image, allowing the file to be displayed within - * the body of your email. + * Get the attachment content ID. This is used when the disposition is set to “inline” and the + * attachment is an image, allowing the file to be displayed within the body of your email. + * * @return the content ID. */ - @JsonProperty("content_id") + @JsonProperty("content_id") public String getContentId() { return contentId; } - + /** * Set the content ID. + * * @param contentId the content ID. */ public void setContentId(String contentId) { @@ -148,6 +155,7 @@ public static class Builder { /** * Construct a new attachment builder. + * * @param fileName the filename to include. * @param content an input stream for the content. * @throws IllegalArgumentException in case either the fileName or the content is null. @@ -167,6 +175,7 @@ public Builder(String fileName, InputStream content) { /** * Construct a new attachment builder. + * * @param fileName the filename to include. * @param content an input string for the content. * @throws IllegalArgumentException in case either the fileName or the content is null. @@ -187,7 +196,7 @@ public Builder(String fileName, String content) { private String encodeToBase64(InputStream content) { int read = 0; byte[] bytes = new byte[BYTE_BUFFER_SIZE]; - try(ByteArrayOutputStream baos = new ByteArrayOutputStream()) { + try (ByteArrayOutputStream baos = new ByteArrayOutputStream()) { while ((read = content.read(bytes)) != -1) { baos.write(bytes, 0, read); } @@ -200,6 +209,7 @@ private String encodeToBase64(InputStream content) { /** * Set the type of this attachment builder. + * * @param type the attachment type. */ public Builder withType(String type) { @@ -209,6 +219,7 @@ public Builder withType(String type) { /** * Set the disposition of this attachment builder. + * * @param disposition the disposition. */ public Builder withDisposition(String disposition) { @@ -218,6 +229,7 @@ public Builder withDisposition(String disposition) { /** * Set the content ID of this attachment builder. + * * @param contentId the content ID. */ public Builder withContentId(String contentId) { @@ -253,38 +265,51 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Attachments other = (Attachments) obj; if (content == null) { - if (other.content != null) + if (other.content != null) { return false; - } else if (!content.equals(other.content)) + } + } else if (!content.equals(other.content)) { return false; + } if (contentId == null) { - if (other.contentId != null) + if (other.contentId != null) { return false; - } else if (!contentId.equals(other.contentId)) + } + } else if (!contentId.equals(other.contentId)) { return false; + } if (disposition == null) { - if (other.disposition != null) + if (other.disposition != null) { return false; - } else if (!disposition.equals(other.disposition)) + } + } else if (!disposition.equals(other.disposition)) { return false; + } if (filename == null) { - if (other.filename != null) + if (other.filename != null) { return false; - } else if (!filename.equals(other.filename)) + } + } else if (!filename.equals(other.filename)) { return false; + } if (type == null) { - if (other.type != null) + if (other.type != null) { return false; - } else if (!type.equals(other.type)) + } + } else if (!type.equals(other.type)) { return false; + } return true; } } diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java index f43803f1..68d7a535 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/BccSettings.java @@ -5,14 +5,17 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * This object allows you to have a blind carbon copy - * automatically sent to the specified email address - * for every email that is sent. + * This object allows you to have a blind carbon copy automatically sent to the specified email + * address for every email that is sent. */ @JsonInclude(Include.NON_EMPTY) public class BccSettings { - @JsonProperty("enable") private boolean enable; - @JsonProperty("email") private String email; + + @JsonProperty("enable") + private boolean enable; + + @JsonProperty("email") + private String email; @JsonProperty("enable") public boolean getEnable() { @@ -43,20 +46,26 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } BccSettings other = (BccSettings) obj; if (email == null) { - if (other.email != null) + if (other.email != null) { return false; - } else if (!email.equals(other.email)) + } + } else if (!email.equals(other.email)) { return false; - if (enable != other.enable) + } + if (enable != other.enable) { return false; + } return true; } } \ No newline at end of file diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java index ee12fc07..13ce3f13 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/ClickTrackingSetting.java @@ -5,28 +5,32 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * Settings to determine how you would like to track the - * metrics of how your recipients interact with your email. + * Settings to determine how you would like to track the metrics of how your recipients interact + * with your email. */ @JsonInclude(Include.NON_EMPTY) public class ClickTrackingSetting { - @JsonProperty("enable") private boolean enable; - @JsonProperty("enable_text") private boolean enableText; - + + @JsonProperty("enable") + private boolean enable; + + @JsonProperty("enable_text") + private boolean enableText; + @JsonProperty("enable") public boolean getEnable() { return enable; } - + public void setEnable(boolean enable) { this.enable = enable; } - + @JsonProperty("enable_text") public boolean getEnableText() { return enableText; - } - + } + public void setEnableText(boolean enableText) { this.enableText = enableText; } @@ -42,17 +46,22 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } ClickTrackingSetting other = (ClickTrackingSetting) obj; - if (enable != other.enable) + if (enable != other.enable) { return false; - if (enableText != other.enableText) + } + if (enableText != other.enableText) { return false; + } return true; } } \ No newline at end of file diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Email.java b/src/main/java/com/sendgrid/helpers/mail/objects/Email.java index 537b27b6..37e8fbcf 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/Email.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/Email.java @@ -6,8 +6,12 @@ @JsonInclude(Include.NON_DEFAULT) public class Email { - @JsonProperty("name") private String name; - @JsonProperty("email") private String email; + + @JsonProperty("name") + private String name; + + @JsonProperty("email") + private String email; public Email() { return; @@ -51,23 +55,30 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Email other = (Email) obj; if (email == null) { - if (other.email != null) + if (other.email != null) { return false; - } else if (!email.equals(other.email)) + } + } else if (!email.equals(other.email)) { return false; + } if (name == null) { - if (other.name != null) + if (other.name != null) { return false; - } else if (!name.equals(other.name)) + } + } else if (!name.equals(other.name)) { return false; + } return true; } } \ No newline at end of file diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java index 905436ed..6ec12eb2 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/FooterSetting.java @@ -5,15 +5,20 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * An object representing the default footer - * that you would like included on every email. + * An object representing the default footer that you would like included on every email. */ @JsonInclude(Include.NON_EMPTY) public class FooterSetting { - @JsonProperty("enable") private boolean enable; - @JsonProperty("text") private String text; - @JsonProperty("html") private String html; - + + @JsonProperty("enable") + private boolean enable; + + @JsonProperty("text") + private String text; + + @JsonProperty("html") + private String html; + @JsonProperty("enable") public boolean getEnable() { return enable; @@ -22,16 +27,16 @@ public boolean getEnable() { public void setEnable(boolean enable) { this.enable = enable; } - + @JsonProperty("text") public String getText() { return text; } - + public void setText(String text) { this.text = text; } - + @JsonProperty("html") public String getHtml() { return html; @@ -53,25 +58,33 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } FooterSetting other = (FooterSetting) obj; - if (enable != other.enable) + if (enable != other.enable) { return false; + } if (html == null) { - if (other.html != null) + if (other.html != null) { return false; - } else if (!html.equals(other.html)) + } + } else if (!html.equals(other.html)) { return false; + } if (text == null) { - if (other.text != null) + if (other.text != null) { return false; - } else if (!text.equals(other.text)) + } + } else if (!text.equals(other.text)) { return false; + } return true; } } \ No newline at end of file diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java index a01d4df6..e8f12f70 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/GoogleAnalyticsSetting.java @@ -9,22 +9,34 @@ */ @JsonInclude(Include.NON_EMPTY) public class GoogleAnalyticsSetting { - @JsonProperty("enable") private boolean enable; - @JsonProperty("utm_source") private String campaignSource; - @JsonProperty("utm_term") private String campaignTerm; - @JsonProperty("utm_content") private String campaignContent; - @JsonProperty("utm_campaign") private String campaignName; - @JsonProperty("utm_medium") private String campaignMedium; - + + @JsonProperty("enable") + private boolean enable; + + @JsonProperty("utm_source") + private String campaignSource; + + @JsonProperty("utm_term") + private String campaignTerm; + + @JsonProperty("utm_content") + private String campaignContent; + + @JsonProperty("utm_campaign") + private String campaignName; + + @JsonProperty("utm_medium") + private String campaignMedium; + @JsonProperty("enable") public boolean getEnable() { return enable; } - + public void setEnable(boolean enable) { this.enable = enable; } - + @JsonProperty("utm_source") public String getCampaignSource() { return campaignSource; @@ -33,7 +45,7 @@ public String getCampaignSource() { public void setCampaignSource(String campaignSource) { this.campaignSource = campaignSource; } - + @JsonProperty("utm_term") public String getCampaignTerm() { return campaignTerm; @@ -42,30 +54,30 @@ public String getCampaignTerm() { public void setCampaignTerm(String campaignTerm) { this.campaignTerm = campaignTerm; } - + @JsonProperty("utm_content") public String getCampaignContent() { return campaignContent; } - + public void setCampaignContent(String campaignContent) { this.campaignContent = campaignContent; } - + @JsonProperty("utm_campaign") public String getCampaignName() { return campaignName; } - + public void setCampaignName(String campaignName) { this.campaignName = campaignName; } - + @JsonProperty("utm_medium") public String getCampaignMedium() { return campaignMedium; } - + public void setCampaignMedium(String campaignMedium) { this.campaignMedium = campaignMedium; } @@ -85,40 +97,54 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } GoogleAnalyticsSetting other = (GoogleAnalyticsSetting) obj; if (campaignContent == null) { - if (other.campaignContent != null) + if (other.campaignContent != null) { return false; - } else if (!campaignContent.equals(other.campaignContent)) + } + } else if (!campaignContent.equals(other.campaignContent)) { return false; + } if (campaignMedium == null) { - if (other.campaignMedium != null) + if (other.campaignMedium != null) { return false; - } else if (!campaignMedium.equals(other.campaignMedium)) + } + } else if (!campaignMedium.equals(other.campaignMedium)) { return false; + } if (campaignName == null) { - if (other.campaignName != null) + if (other.campaignName != null) { return false; - } else if (!campaignName.equals(other.campaignName)) + } + } else if (!campaignName.equals(other.campaignName)) { return false; + } if (campaignSource == null) { - if (other.campaignSource != null) + if (other.campaignSource != null) { return false; - } else if (!campaignSource.equals(other.campaignSource)) + } + } else if (!campaignSource.equals(other.campaignSource)) { return false; + } if (campaignTerm == null) { - if (other.campaignTerm != null) + if (other.campaignTerm != null) { return false; - } else if (!campaignTerm.equals(other.campaignTerm)) + } + } else if (!campaignTerm.equals(other.campaignTerm)) { return false; - if (enable != other.enable) + } + if (enable != other.enable) { return false; + } return true; } } \ No newline at end of file diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java index 5175642c..bd239880 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/MailSettings.java @@ -5,18 +5,27 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * An object representing a collection of different mail - * settings that you can use to specify how you would - * like this email to be handled. + * An object representing a collection of different mail settings that you can use to specify how + * you would like this email to be handled. */ @JsonInclude(Include.NON_DEFAULT) public class MailSettings { - @JsonProperty("bcc") private BccSettings bccSettings; - @JsonProperty("bypass_list_management") private Setting bypassListManagement; - @JsonProperty("footer") private FooterSetting footerSetting; - @JsonProperty("sandbox_mode") private Setting sandBoxMode; - @JsonProperty("spam_check") private SpamCheckSetting spamCheckSetting; + + @JsonProperty("bcc") + private BccSettings bccSettings; + + @JsonProperty("bypass_list_management") + private Setting bypassListManagement; + + @JsonProperty("footer") + private FooterSetting footerSetting; + + @JsonProperty("sandbox_mode") + private Setting sandBoxMode; + + @JsonProperty("spam_check") + private SpamCheckSetting spamCheckSetting; @JsonProperty("bcc") public BccSettings getBccSettings() { @@ -25,6 +34,7 @@ public BccSettings getBccSettings() { /** * Set the BCC settings. + * * @param bccSettings the BCC settings. */ public void setBccSettings(BccSettings bccSettings) { @@ -32,11 +42,10 @@ public void setBccSettings(BccSettings bccSettings) { } /** - * A setting that allows you to bypass all unsubscribe - * groups and suppressions to ensure that the email is - * delivered to every single recipient. This should only - * be used in emergencies when it is absolutely necessary - * that every recipient receives your email. + * A setting that allows you to bypass all unsubscribe groups and suppressions to ensure that the + * email is delivered to every single recipient. This should only be used in emergencies when it + * is absolutely necessary that every recipient receives your email. + * * @return the bypass list setting. */ @@ -51,6 +60,7 @@ public void setBypassListManagement(Setting bypassListManagement) { /** * Get the the footer settings that you would like included on every email. + * * @return the setting. */ @@ -61,6 +71,7 @@ public FooterSetting getFooterSetting() { /** * Set the the footer settings that you would like included on every email. + * * @param footerSetting the setting. */ public void setFooterSetting(FooterSetting footerSetting) { @@ -68,8 +79,9 @@ public void setFooterSetting(FooterSetting footerSetting) { } /** - * Get sandbox mode. This allows you to send a test email to - * ensure that your request body is valid and formatted correctly. + * Get sandbox mode. This allows you to send a test email to ensure that your request body is + * valid and formatted correctly. + * * @return the sandbox mode setting. */ @@ -80,6 +92,7 @@ public Setting getSandBoxMode() { /** * Set sandbox mode. + * * @param sandBoxMode the sandbox mode setting. */ @JsonProperty("sandbox_mode") @@ -88,8 +101,8 @@ public void setSandboxMode(Setting sandBoxMode) { } /** - * Get the spam check setting. This allows you to test the - * content of your email for spam. + * Get the spam check setting. This allows you to test the content of your email for spam. + * * @return the spam check setting. */ @@ -99,8 +112,8 @@ public SpamCheckSetting getSpamCheck() { } /** - * Set the spam check setting. This allows you to test the - * content of your email for spam. + * Set the spam check setting. This allows you to test the content of your email for spam. + * * @param spamCheckSetting the spam check setting. */ @@ -113,7 +126,8 @@ public int hashCode() { final int prime = 31; int result = 1; result = prime * result + ((bccSettings == null) ? 0 : bccSettings.hashCode()); - result = prime * result + ((bypassListManagement == null) ? 0 : bypassListManagement.hashCode()); + result = + prime * result + ((bypassListManagement == null) ? 0 : bypassListManagement.hashCode()); result = prime * result + ((footerSetting == null) ? 0 : footerSetting.hashCode()); result = prime * result + ((sandBoxMode == null) ? 0 : sandBoxMode.hashCode()); result = prime * result + ((spamCheckSetting == null) ? 0 : spamCheckSetting.hashCode()); @@ -122,38 +136,51 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } MailSettings other = (MailSettings) obj; if (bccSettings == null) { - if (other.bccSettings != null) + if (other.bccSettings != null) { return false; - } else if (!bccSettings.equals(other.bccSettings)) + } + } else if (!bccSettings.equals(other.bccSettings)) { return false; + } if (bypassListManagement == null) { - if (other.bypassListManagement != null) + if (other.bypassListManagement != null) { return false; - } else if (!bypassListManagement.equals(other.bypassListManagement)) + } + } else if (!bypassListManagement.equals(other.bypassListManagement)) { return false; + } if (footerSetting == null) { - if (other.footerSetting != null) + if (other.footerSetting != null) { return false; - } else if (!footerSetting.equals(other.footerSetting)) + } + } else if (!footerSetting.equals(other.footerSetting)) { return false; + } if (sandBoxMode == null) { - if (other.sandBoxMode != null) + if (other.sandBoxMode != null) { return false; - } else if (!sandBoxMode.equals(other.sandBoxMode)) + } + } else if (!sandBoxMode.equals(other.sandBoxMode)) { return false; + } if (spamCheckSetting == null) { - if (other.spamCheckSetting != null) + if (other.spamCheckSetting != null) { return false; - } else if (!spamCheckSetting.equals(other.spamCheckSetting)) + } + } else if (!spamCheckSetting.equals(other.spamCheckSetting)) { return false; + } return true; } } \ No newline at end of file diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java index e4497d9c..a44cb8d8 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/OpenTrackingSetting.java @@ -5,30 +5,33 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * An open tracking settings object. This allows you to track - * whether the email was opened or not, but including a single - * pixel image in the body of the content. When the pixel is - * loaded, we can log that the email was opened. + * An open tracking settings object. This allows you to track whether the email was opened or not, + * but including a single pixel image in the body of the content. When the pixel is loaded, we can + * log that the email was opened. */ @JsonInclude(Include.NON_EMPTY) public class OpenTrackingSetting { - @JsonProperty("enable") private boolean enable; - @JsonProperty("substitution_tag") private String substitutionTag; - + + @JsonProperty("enable") + private boolean enable; + + @JsonProperty("substitution_tag") + private String substitutionTag; + @JsonProperty("enable") public boolean getEnable() { return enable; } - + public void setEnable(boolean enable) { this.enable = enable; } - + @JsonProperty("substitution_tag") public String getSubstitutionTag() { return substitutionTag; } - + public void setSubstitutionTag(String substitutionTag) { this.substitutionTag = substitutionTag; } @@ -44,21 +47,27 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } OpenTrackingSetting other = (OpenTrackingSetting) obj; - if (enable != other.enable) + if (enable != other.enable) { return false; + } if (substitutionTag == null) { - if (other.substitutionTag != null) + if (other.substitutionTag != null) { return false; - } else if (!substitutionTag.equals(other.substitutionTag)) + } + } else if (!substitutionTag.equals(other.substitutionTag)) { return false; + } return true; } - + } \ No newline at end of file diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java index 9a91db5d..82cb3de3 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/Personalization.java @@ -3,29 +3,47 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude.Include; import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.Collections; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @JsonInclude(Include.NON_DEFAULT) public class Personalization { - @JsonProperty("to") private List tos; - @JsonProperty("cc") private List ccs; - @JsonProperty("bcc") private List bccs; - @JsonProperty("subject") private String subject; - @JsonProperty("headers") private Map headers; - @JsonProperty("substitutions") private Map substitutions; - @JsonProperty("custom_args") private Map customArgs; - @JsonProperty("dynamic_template_data") private Map dynamicTemplateData; - @JsonProperty("send_at") private long sendAt; + + @JsonProperty("to") + private List tos; + + @JsonProperty("cc") + private List ccs; + + @JsonProperty("bcc") + private List bccs; + + @JsonProperty("subject") + private String subject; + + @JsonProperty("headers") + private Map headers; + + @JsonProperty("substitutions") + private Map substitutions; + + @JsonProperty("custom_args") + private Map customArgs; + + @JsonProperty("dynamic_template_data") + private Map dynamicTemplateData; + + @JsonProperty("send_at") + private long sendAt; @JsonProperty("to") public List getTos() { - if(tos == null) - return Collections.emptyList(); + if (tos == null) { + return Collections.emptyList(); + } return tos; } @@ -43,8 +61,9 @@ public void addTo(Email email) { @JsonProperty("cc") public List getCcs() { - if(ccs == null) - return Collections.emptyList(); + if (ccs == null) { + return Collections.emptyList(); + } return ccs; } @@ -62,8 +81,9 @@ public void addCc(Email email) { @JsonProperty("bcc") public List getBccs() { - if(bccs == null) - return Collections.emptyList(); + if (bccs == null) { + return Collections.emptyList(); + } return bccs; } @@ -89,15 +109,16 @@ public void setSubject(String subject) { } @JsonProperty("headers") - public Map getHeaders() { - if(headers == null) - return Collections.emptyMap(); + public Map getHeaders() { + if (headers == null) { + return Collections.emptyMap(); + } return headers; } public void addHeader(String key, String value) { if (headers == null) { - headers = new HashMap(); + headers = new HashMap(); headers.put(key, value); } else { headers.put(key, value); @@ -105,15 +126,16 @@ public void addHeader(String key, String value) { } @JsonProperty("substitutions") - public Map getSubstitutions() { - if(substitutions == null) - return Collections.emptyMap(); + public Map getSubstitutions() { + if (substitutions == null) { + return Collections.emptyMap(); + } return substitutions; } public void addSubstitution(String key, String value) { if (substitutions == null) { - substitutions = new HashMap(); + substitutions = new HashMap(); substitutions.put(key, value); } else { substitutions.put(key, value); @@ -121,15 +143,16 @@ public void addSubstitution(String key, String value) { } @JsonProperty("custom_args") - public Map getCustomArgs() { - if(customArgs == null) - return Collections.emptyMap(); + public Map getCustomArgs() { + if (customArgs == null) { + return Collections.emptyMap(); + } return customArgs; } public void addCustomArg(String key, String value) { if (customArgs == null) { - customArgs = new HashMap(); + customArgs = new HashMap(); customArgs.put(key, value); } else { customArgs.put(key, value); @@ -146,14 +169,14 @@ public void setSendAt(long sendAt) { } @JsonProperty("dynamic_template_data") - public Map getDynamicTemplateData() { + public Map getDynamicTemplateData() { return dynamicTemplateData == null - ? Collections.emptyMap() : dynamicTemplateData; + ? Collections.emptyMap() : dynamicTemplateData; } public void addDynamicTemplateData(String key, Object value) { if (dynamicTemplateData == null) { - dynamicTemplateData = new HashMap(); + dynamicTemplateData = new HashMap(); } dynamicTemplateData.put(key, value); } @@ -175,50 +198,68 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Personalization other = (Personalization) obj; if (bccs == null) { - if (other.bccs != null) + if (other.bccs != null) { return false; - } else if (!bccs.equals(other.bccs)) + } + } else if (!bccs.equals(other.bccs)) { return false; + } if (ccs == null) { - if (other.ccs != null) + if (other.ccs != null) { return false; - } else if (!ccs.equals(other.ccs)) + } + } else if (!ccs.equals(other.ccs)) { return false; + } if (customArgs == null) { - if (other.customArgs != null) + if (other.customArgs != null) { return false; - } else if (!customArgs.equals(other.customArgs)) + } + } else if (!customArgs.equals(other.customArgs)) { return false; + } if (headers == null) { - if (other.headers != null) + if (other.headers != null) { return false; - } else if (!headers.equals(other.headers)) + } + } else if (!headers.equals(other.headers)) { return false; - if (sendAt != other.sendAt) + } + if (sendAt != other.sendAt) { return false; + } if (subject == null) { - if (other.subject != null) + if (other.subject != null) { return false; - } else if (!subject.equals(other.subject)) + } + } else if (!subject.equals(other.subject)) { return false; + } if (substitutions == null) { - if (other.substitutions != null) + if (other.substitutions != null) { return false; - } else if (!substitutions.equals(other.substitutions)) + } + } else if (!substitutions.equals(other.substitutions)) { return false; + } if (tos == null) { - if (other.tos != null) + if (other.tos != null) { return false; - } else if (!tos.equals(other.tos)) + } + } else if (!tos.equals(other.tos)) { return false; + } return true; } } diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java b/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java index fd21bcb5..ab5aeca7 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/Setting.java @@ -6,7 +6,9 @@ @JsonInclude(Include.NON_NULL) public class Setting { - @JsonProperty("enable") private boolean enable; + + @JsonProperty("enable") + private boolean enable; @JsonProperty("enable") public boolean getEnable() { @@ -27,15 +29,19 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } Setting other = (Setting) obj; - if (enable != other.enable) + if (enable != other.enable) { return false; + } return true; } } diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java index d2cd79c1..b0939bdb 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/SpamCheckSetting.java @@ -5,38 +5,43 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * A setting object that allows you to test the content of - * your email for spam. + * A setting object that allows you to test the content of your email for spam. */ @JsonInclude(Include.NON_EMPTY) public class SpamCheckSetting { - @JsonProperty("enable") private boolean enable; - @JsonProperty("threshold") private int spamThreshold; - @JsonProperty("post_to_url") private String postToUrl; + + @JsonProperty("enable") + private boolean enable; + + @JsonProperty("threshold") + private int spamThreshold; + + @JsonProperty("post_to_url") + private String postToUrl; @JsonProperty("enable") public boolean getEnable() { return enable; } - + public void setEnable(boolean enable) { this.enable = enable; } - + @JsonProperty("threshold") public int getSpamThreshold() { return spamThreshold; } - + public void setSpamThreshold(int spamThreshold) { this.spamThreshold = spamThreshold; } - + @JsonProperty("post_to_url") public String getPostToUrl() { return postToUrl; } - + public void setPostToUrl(String postToUrl) { this.postToUrl = postToUrl; } @@ -53,22 +58,29 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } SpamCheckSetting other = (SpamCheckSetting) obj; - if (enable != other.enable) + if (enable != other.enable) { return false; + } if (postToUrl == null) { - if (other.postToUrl != null) + if (other.postToUrl != null) { return false; - } else if (!postToUrl.equals(other.postToUrl)) + } + } else if (!postToUrl.equals(other.postToUrl)) { return false; - if (spamThreshold != other.spamThreshold) + } + if (spamThreshold != other.spamThreshold) { return false; + } return true; } } \ No newline at end of file diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java index 6c438cc9..fe0f102e 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/SubscriptionTrackingSetting.java @@ -5,50 +5,56 @@ import com.fasterxml.jackson.annotation.JsonProperty; /** - * A subscription tracking setting object. Subscription tracking - * allows you to insert a subscription management link at the - * bottom of the text and html bodies of your email. If you - * would like to specify the location of the link within your - * email, you may use the substitution_tag. + * A subscription tracking setting object. Subscription tracking allows you to insert a subscription + * management link at the bottom of the text and html bodies of your email. If you would like to + * specify the location of the link within your email, you may use the substitution_tag. */ @JsonInclude(Include.NON_EMPTY) public class SubscriptionTrackingSetting { - @JsonProperty("enable") private boolean enable; - @JsonProperty("text") private String text; - @JsonProperty("html") private String html; - @JsonProperty("substitution_tag") private String substitutionTag; - + + @JsonProperty("enable") + private boolean enable; + + @JsonProperty("text") + private String text; + + @JsonProperty("html") + private String html; + + @JsonProperty("substitution_tag") + private String substitutionTag; + @JsonProperty("enable") public boolean getEnable() { return enable; } - + public void setEnable(boolean enable) { this.enable = enable; } - + @JsonProperty("text") public String getText() { return text; } - + public void setText(String text) { this.text = text; } - + @JsonProperty("html") public String getHtml() { return html; - } + } public void setHtml(String html) { this.html = html; } - + @JsonProperty("substitution_tag") public String getSubstitutionTag() { return substitutionTag; - } + } public void setSubstitutionTag(String substitutionTag) { this.substitutionTag = substitutionTag; @@ -67,30 +73,40 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } SubscriptionTrackingSetting other = (SubscriptionTrackingSetting) obj; - if (enable != other.enable) + if (enable != other.enable) { return false; + } if (html == null) { - if (other.html != null) + if (other.html != null) { return false; - } else if (!html.equals(other.html)) + } + } else if (!html.equals(other.html)) { return false; + } if (substitutionTag == null) { - if (other.substitutionTag != null) + if (other.substitutionTag != null) { return false; - } else if (!substitutionTag.equals(other.substitutionTag)) + } + } else if (!substitutionTag.equals(other.substitutionTag)) { return false; + } if (text == null) { - if (other.text != null) + if (other.text != null) { return false; - } else if (!text.equals(other.text)) + } + } else if (!text.equals(other.text)) { return false; + } return true; } } \ No newline at end of file diff --git a/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java b/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java index 981875c8..08a9b411 100644 --- a/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java +++ b/src/main/java/com/sendgrid/helpers/mail/objects/TrackingSettings.java @@ -6,43 +6,52 @@ @JsonInclude(Include.NON_DEFAULT) public class TrackingSettings { - @JsonProperty("click_tracking") private ClickTrackingSetting clickTrackingSetting; - @JsonProperty("open_tracking") private OpenTrackingSetting openTrackingSetting; - @JsonProperty("subscription_tracking") private SubscriptionTrackingSetting subscriptionTrackingSetting; - @JsonProperty("ganalytics") private GoogleAnalyticsSetting googleAnalyticsSetting; + + @JsonProperty("click_tracking") + private ClickTrackingSetting clickTrackingSetting; + + @JsonProperty("open_tracking") + private OpenTrackingSetting openTrackingSetting; + + @JsonProperty("subscription_tracking") + private SubscriptionTrackingSetting subscriptionTrackingSetting; + + @JsonProperty("ganalytics") + private GoogleAnalyticsSetting googleAnalyticsSetting; @JsonProperty("click_tracking") public ClickTrackingSetting getClickTrackingSetting() { return clickTrackingSetting; } - + public void setClickTrackingSetting(ClickTrackingSetting clickTrackingSetting) { this.clickTrackingSetting = clickTrackingSetting; } - + @JsonProperty("open_tracking") public OpenTrackingSetting getOpenTrackingSetting() { return openTrackingSetting; } - + public void setOpenTrackingSetting(OpenTrackingSetting openTrackingSetting) { this.openTrackingSetting = openTrackingSetting; } - + @JsonProperty("subscription_tracking") public SubscriptionTrackingSetting getSubscriptionTrackingSetting() { return subscriptionTrackingSetting; } - - public void setSubscriptionTrackingSetting(SubscriptionTrackingSetting subscriptionTrackingSetting) { + + public void setSubscriptionTrackingSetting( + SubscriptionTrackingSetting subscriptionTrackingSetting) { this.subscriptionTrackingSetting = subscriptionTrackingSetting; } - + @JsonProperty("ganalytics") public GoogleAnalyticsSetting getGoogleAnalyticsSetting() { return googleAnalyticsSetting; } - + public void setGoogleAnalyticsSetting(GoogleAnalyticsSetting googleAnalyticsSetting) { this.googleAnalyticsSetting = googleAnalyticsSetting; } @@ -51,42 +60,56 @@ public void setGoogleAnalyticsSetting(GoogleAnalyticsSetting googleAnalyticsSett public int hashCode() { final int prime = 31; int result = 1; - result = prime * result + ((clickTrackingSetting == null) ? 0 : clickTrackingSetting.hashCode()); - result = prime * result + ((googleAnalyticsSetting == null) ? 0 : googleAnalyticsSetting.hashCode()); + result = + prime * result + ((clickTrackingSetting == null) ? 0 : clickTrackingSetting.hashCode()); + result = + prime * result + ((googleAnalyticsSetting == null) ? 0 : googleAnalyticsSetting.hashCode()); result = prime * result + ((openTrackingSetting == null) ? 0 : openTrackingSetting.hashCode()); - result = prime * result + ((subscriptionTrackingSetting == null) ? 0 : subscriptionTrackingSetting.hashCode()); + result = prime * result + ((subscriptionTrackingSetting == null) ? 0 + : subscriptionTrackingSetting.hashCode()); return result; } @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } TrackingSettings other = (TrackingSettings) obj; if (clickTrackingSetting == null) { - if (other.clickTrackingSetting != null) + if (other.clickTrackingSetting != null) { return false; - } else if (!clickTrackingSetting.equals(other.clickTrackingSetting)) + } + } else if (!clickTrackingSetting.equals(other.clickTrackingSetting)) { return false; + } if (googleAnalyticsSetting == null) { - if (other.googleAnalyticsSetting != null) + if (other.googleAnalyticsSetting != null) { return false; - } else if (!googleAnalyticsSetting.equals(other.googleAnalyticsSetting)) + } + } else if (!googleAnalyticsSetting.equals(other.googleAnalyticsSetting)) { return false; + } if (openTrackingSetting == null) { - if (other.openTrackingSetting != null) + if (other.openTrackingSetting != null) { return false; - } else if (!openTrackingSetting.equals(other.openTrackingSetting)) + } + } else if (!openTrackingSetting.equals(other.openTrackingSetting)) { return false; + } if (subscriptionTrackingSetting == null) { - if (other.subscriptionTrackingSetting != null) + if (other.subscriptionTrackingSetting != null) { return false; - } else if (!subscriptionTrackingSetting.equals(other.subscriptionTrackingSetting)) + } + } else if (!subscriptionTrackingSetting.equals(other.subscriptionTrackingSetting)) { return false; + } return true; } } \ No newline at end of file diff --git a/src/test/java/com/sendgrid/LicenseTest.java b/src/test/java/com/sendgrid/LicenseTest.java index 493458e6..96bf096c 100644 --- a/src/test/java/com/sendgrid/LicenseTest.java +++ b/src/test/java/com/sendgrid/LicenseTest.java @@ -1,27 +1,28 @@ package com.sendgrid; -import org.junit.Assert; -import org.junit.Test; - import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.util.Calendar; +import org.junit.Assert; +import org.junit.Test; public class LicenseTest { - @Test - public void testLicenseShouldHaveCorrectYear() throws IOException { - String copyrightText = null; - try (BufferedReader br = new BufferedReader(new FileReader("./LICENSE.md"))) { - for (String line; (line = br.readLine()) != null; ) { - if (line.startsWith("Copyright")) { - copyrightText = line; - break; - } - } + @Test + public void testLicenseShouldHaveCorrectYear() throws IOException { + String copyrightText = null; + try (BufferedReader br = new BufferedReader(new FileReader("./LICENSE.md"))) { + for (String line; (line = br.readLine()) != null; ) { + if (line.startsWith("Copyright")) { + copyrightText = line; + break; } - String expectedCopyright = String.format("Copyright (C) %d, Twilio SendGrid, Inc. ", Calendar.getInstance().get(Calendar.YEAR)); - Assert.assertEquals("License has incorrect year", copyrightText, expectedCopyright); + } } + String expectedCopyright = String + .format("Copyright (C) %d, Twilio SendGrid, Inc. ", + Calendar.getInstance().get(Calendar.YEAR)); + Assert.assertEquals("License has incorrect year", copyrightText, expectedCopyright); + } } diff --git a/src/test/java/com/sendgrid/TestRequiredFilesExist.java b/src/test/java/com/sendgrid/TestRequiredFilesExist.java index bb5dd46c..62eda186 100644 --- a/src/test/java/com/sendgrid/TestRequiredFilesExist.java +++ b/src/test/java/com/sendgrid/TestRequiredFilesExist.java @@ -1,94 +1,108 @@ package com.sendgrid; -import org.junit.Test; +import static org.junit.Assert.assertTrue; import java.io.File; - -import static org.junit.Assert.assertTrue; +import org.junit.Test; public class TestRequiredFilesExist { - // ./Docker or docker/Docker - @Test public void checkDockerExists() { - boolean dockerExists = new File("./Dockerfile").exists() || + // ./Docker or docker/Docker + @Test + public void checkDockerExists() { + boolean dockerExists = new File("./Dockerfile").exists() || new File("./docker/Dockerfile").exists(); - assertTrue(dockerExists); - } - - // // ./docker-compose.yml or ./docker/docker-compose.yml - // @Test public void checkDockerComposeExists() { - // boolean dockerComposeExists = new File("./docker-compose.yml").exists() || - // new File("./docker/docker-compose.yml").exists(); - // assertTrue(dockerComposeExists); - // } - - // ./.env_sample - @Test public void checkEnvSampleExists() { - assertTrue(new File("./.env_sample").exists()); - } - - // ./.gitignore - @Test public void checkGitIgnoreExists() { - assertTrue(new File("./.gitignore").exists()); - } - - // ./.travis.yml - @Test public void checkTravisExists() { - assertTrue(new File("./.travis.yml").exists()); - } - - // ./.codeclimate.yml - @Test public void checkCodeClimateExists() { - assertTrue(new File("./.codeclimate.yml").exists()); - } - - // ./CHANGELOG.md - @Test public void checkChangelogExists() { - assertTrue(new File("./CHANGELOG.md").exists()); - } - - // ./CODE_OF_CONDUCT.md - @Test public void checkCodeOfConductExists() { - assertTrue(new File("./CODE_OF_CONDUCT.md").exists()); - } - - // ./CONTRIBUTING.md - @Test public void checkContributingGuideExists() { - assertTrue(new File("./CONTRIBUTING.md").exists()); - } - - // ./ISSUE_TEMPLATE.md - @Test public void checkIssuesTemplateExists() { - assertTrue(new File("./ISSUE_TEMPLATE.md").exists()); - } - - // ./LICENSE.md - @Test public void checkLicenseExists() { - assertTrue(new File("./LICENSE.md").exists()); - } - - // ./PULL_REQUEST_TEMPLATE.md - @Test public void checkPullRequestExists() { - assertTrue(new File("./PULL_REQUEST_TEMPLATE.md").exists()); - } - - // ./README.md - @Test public void checkReadMeExists() { - assertTrue(new File("./README.md").exists()); - } - - // ./TROUBLESHOOTING.md - @Test public void checkTroubleShootingGuideExists() { - assertTrue(new File("./TROUBLESHOOTING.md").exists()); - } - - // ./USAGE.md - @Test public void checkUsageGuideExists() { - assertTrue(new File("./USAGE.md").exists()); - } - - // ./USE_CASES.md - @Test public void checkUseCases() { - assertTrue(new File("./USE_CASES.md").exists()); - } + assertTrue(dockerExists); + } + + // // ./docker-compose.yml or ./docker/docker-compose.yml + // @Test public void checkDockerComposeExists() { + // boolean dockerComposeExists = new File("./docker-compose.yml").exists() || + // new File("./docker/docker-compose.yml").exists(); + // assertTrue(dockerComposeExists); + // } + + // ./.env_sample + @Test + public void checkEnvSampleExists() { + assertTrue(new File("./.env_sample").exists()); + } + + // ./.gitignore + @Test + public void checkGitIgnoreExists() { + assertTrue(new File("./.gitignore").exists()); + } + + // ./.travis.yml + @Test + public void checkTravisExists() { + assertTrue(new File("./.travis.yml").exists()); + } + + // ./.codeclimate.yml + @Test + public void checkCodeClimateExists() { + assertTrue(new File("./.codeclimate.yml").exists()); + } + + // ./CHANGELOG.md + @Test + public void checkChangelogExists() { + assertTrue(new File("./CHANGELOG.md").exists()); + } + + // ./CODE_OF_CONDUCT.md + @Test + public void checkCodeOfConductExists() { + assertTrue(new File("./CODE_OF_CONDUCT.md").exists()); + } + + // ./CONTRIBUTING.md + @Test + public void checkContributingGuideExists() { + assertTrue(new File("./CONTRIBUTING.md").exists()); + } + + // ./ISSUE_TEMPLATE.md + @Test + public void checkIssuesTemplateExists() { + assertTrue(new File("./ISSUE_TEMPLATE.md").exists()); + } + + // ./LICENSE.md + @Test + public void checkLicenseExists() { + assertTrue(new File("./LICENSE.md").exists()); + } + + // ./PULL_REQUEST_TEMPLATE.md + @Test + public void checkPullRequestExists() { + assertTrue(new File("./PULL_REQUEST_TEMPLATE.md").exists()); + } + + // ./README.md + @Test + public void checkReadMeExists() { + assertTrue(new File("./README.md").exists()); + } + + // ./TROUBLESHOOTING.md + @Test + public void checkTroubleShootingGuideExists() { + assertTrue(new File("./TROUBLESHOOTING.md").exists()); + } + + // ./USAGE.md + @Test + public void checkUsageGuideExists() { + assertTrue(new File("./USAGE.md").exists()); + } + + // ./USE_CASES.md + @Test + public void checkUseCases() { + assertTrue(new File("./USE_CASES.md").exists()); + } }