Skip to content

Return empty collections in place of nulls #211

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 17, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.annotation.JsonProperty;

import java.util.Collections;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
Expand All @@ -19,9 +20,11 @@ public class Personalization {
@JsonProperty("substitutions") private Map<String,String> substitutions;
@JsonProperty("custom_args") private Map<String,String> customArgs;
@JsonProperty("send_at") private long sendAt;

@JsonProperty("to")
public List<Email> getTos() {
if(tos == null)
return Collections.<Email>emptyList();
return tos;
}

Expand All @@ -39,6 +42,8 @@ public void addTo(Email email) {

@JsonProperty("cc")
public List<Email> getCcs() {
if(ccs == null)
return Collections.<Email>emptyList();
return ccs;
}

Expand All @@ -56,6 +61,8 @@ public void addCc(Email email) {

@JsonProperty("bcc")
public List<Email> getBccs() {
if(bccs == null)
return Collections.<Email>emptyList();
return bccs;
}

Expand All @@ -82,6 +89,8 @@ public void setSubject(String subject) {

@JsonProperty("headers")
public Map<String,String> getHeaders() {
if(headers == null)
return Collections.<String,String>emptyMap();
return headers;
}

Expand All @@ -96,6 +105,8 @@ public void addHeader(String key, String value) {

@JsonProperty("substitutions")
public Map<String,String> getSubstitutions() {
if(substitutions == null)
return Collections.<String,String>emptyMap();
return substitutions;
}

Expand All @@ -110,6 +121,8 @@ public void addSubstitution(String key, String value) {

@JsonProperty("custom_args")
public Map<String,String> getCustomArgs() {
if(customArgs == null)
return Collections.<String,String>emptyMap();
return customArgs;
}

Expand All @@ -130,4 +143,5 @@ public long sendAt() {
public void setSendAt(long sendAt) {
this.sendAt = sendAt;
}
}

}