|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2017 the original author or authors. |
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -83,15 +83,9 @@ public class SimpleMailMessage implements MailMessage, Serializable { |
|
|
|
Assert.notNull(original, "'original' message argument must not be null"); |
|
|
|
Assert.notNull(original, "'original' message argument must not be null"); |
|
|
|
this.from = original.getFrom(); |
|
|
|
this.from = original.getFrom(); |
|
|
|
this.replyTo = original.getReplyTo(); |
|
|
|
this.replyTo = original.getReplyTo(); |
|
|
|
if (original.getTo() != null) { |
|
|
|
this.to = copyOrNull(original.getTo()); |
|
|
|
this.to = copy(original.getTo()); |
|
|
|
this.cc = copyOrNull(original.getCc()); |
|
|
|
} |
|
|
|
this.bcc = copyOrNull(original.getBcc()); |
|
|
|
if (original.getCc() != null) { |
|
|
|
|
|
|
|
this.cc = copy(original.getCc()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (original.getBcc() != null) { |
|
|
|
|
|
|
|
this.bcc = copy(original.getBcc()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
this.sentDate = original.getSentDate(); |
|
|
|
this.sentDate = original.getSentDate(); |
|
|
|
this.subject = original.getSubject(); |
|
|
|
this.subject = original.getSubject(); |
|
|
|
this.text = original.getText(); |
|
|
|
this.text = original.getText(); |
|
|
|
@ -199,7 +193,7 @@ public class SimpleMailMessage implements MailMessage, Serializable { |
|
|
|
* @param target the {@code MailMessage} to copy to |
|
|
|
* @param target the {@code MailMessage} to copy to |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public void copyTo(MailMessage target) { |
|
|
|
public void copyTo(MailMessage target) { |
|
|
|
Assert.notNull(target, "'target' message argument must not be null"); |
|
|
|
Assert.notNull(target, "'target' MailMessage must not be null"); |
|
|
|
if (getFrom() != null) { |
|
|
|
if (getFrom() != null) { |
|
|
|
target.setFrom(getFrom()); |
|
|
|
target.setFrom(getFrom()); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -207,13 +201,13 @@ public class SimpleMailMessage implements MailMessage, Serializable { |
|
|
|
target.setReplyTo(getReplyTo()); |
|
|
|
target.setReplyTo(getReplyTo()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (getTo() != null) { |
|
|
|
if (getTo() != null) { |
|
|
|
target.setTo(getTo()); |
|
|
|
target.setTo(copy(getTo())); |
|
|
|
} |
|
|
|
} |
|
|
|
if (getCc() != null) { |
|
|
|
if (getCc() != null) { |
|
|
|
target.setCc(getCc()); |
|
|
|
target.setCc(copy(getCc())); |
|
|
|
} |
|
|
|
} |
|
|
|
if (getBcc() != null) { |
|
|
|
if (getBcc() != null) { |
|
|
|
target.setBcc(getBcc()); |
|
|
|
target.setBcc(copy(getBcc())); |
|
|
|
} |
|
|
|
} |
|
|
|
if (getSentDate() != null) { |
|
|
|
if (getSentDate() != null) { |
|
|
|
target.setSentDate(getSentDate()); |
|
|
|
target.setSentDate(getSentDate()); |
|
|
|
@ -227,20 +221,6 @@ public class SimpleMailMessage implements MailMessage, Serializable { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String toString() { |
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder("SimpleMailMessage: "); |
|
|
|
|
|
|
|
sb.append("from=").append(this.from).append("; "); |
|
|
|
|
|
|
|
sb.append("replyTo=").append(this.replyTo).append("; "); |
|
|
|
|
|
|
|
sb.append("to=").append(StringUtils.arrayToCommaDelimitedString(this.to)).append("; "); |
|
|
|
|
|
|
|
sb.append("cc=").append(StringUtils.arrayToCommaDelimitedString(this.cc)).append("; "); |
|
|
|
|
|
|
|
sb.append("bcc=").append(StringUtils.arrayToCommaDelimitedString(this.bcc)).append("; "); |
|
|
|
|
|
|
|
sb.append("sentDate=").append(this.sentDate).append("; "); |
|
|
|
|
|
|
|
sb.append("subject=").append(this.subject).append("; "); |
|
|
|
|
|
|
|
sb.append("text=").append(this.text); |
|
|
|
|
|
|
|
return sb.toString(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean equals(Object other) { |
|
|
|
public boolean equals(Object other) { |
|
|
|
if (this == other) { |
|
|
|
if (this == other) { |
|
|
|
@ -252,9 +232,9 @@ public class SimpleMailMessage implements MailMessage, Serializable { |
|
|
|
SimpleMailMessage otherMessage = (SimpleMailMessage) other; |
|
|
|
SimpleMailMessage otherMessage = (SimpleMailMessage) other; |
|
|
|
return (ObjectUtils.nullSafeEquals(this.from, otherMessage.from) && |
|
|
|
return (ObjectUtils.nullSafeEquals(this.from, otherMessage.from) && |
|
|
|
ObjectUtils.nullSafeEquals(this.replyTo, otherMessage.replyTo) && |
|
|
|
ObjectUtils.nullSafeEquals(this.replyTo, otherMessage.replyTo) && |
|
|
|
java.util.Arrays.equals(this.to, otherMessage.to) && |
|
|
|
ObjectUtils.nullSafeEquals(this.to, otherMessage.to) && |
|
|
|
java.util.Arrays.equals(this.cc, otherMessage.cc) && |
|
|
|
ObjectUtils.nullSafeEquals(this.cc, otherMessage.cc) && |
|
|
|
java.util.Arrays.equals(this.bcc, otherMessage.bcc) && |
|
|
|
ObjectUtils.nullSafeEquals(this.bcc, otherMessage.bcc) && |
|
|
|
ObjectUtils.nullSafeEquals(this.sentDate, otherMessage.sentDate) && |
|
|
|
ObjectUtils.nullSafeEquals(this.sentDate, otherMessage.sentDate) && |
|
|
|
ObjectUtils.nullSafeEquals(this.subject, otherMessage.subject) && |
|
|
|
ObjectUtils.nullSafeEquals(this.subject, otherMessage.subject) && |
|
|
|
ObjectUtils.nullSafeEquals(this.text, otherMessage.text)); |
|
|
|
ObjectUtils.nullSafeEquals(this.text, otherMessage.text)); |
|
|
|
@ -262,23 +242,38 @@ public class SimpleMailMessage implements MailMessage, Serializable { |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public int hashCode() { |
|
|
|
public int hashCode() { |
|
|
|
int hashCode = (this.from == null ? 0 : this.from.hashCode()); |
|
|
|
int hashCode = ObjectUtils.nullSafeHashCode(this.from); |
|
|
|
hashCode = 29 * hashCode + (this.replyTo == null ? 0 : this.replyTo.hashCode()); |
|
|
|
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.replyTo); |
|
|
|
for (int i = 0; this.to != null && i < this.to.length; i++) { |
|
|
|
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.to); |
|
|
|
hashCode = 29 * hashCode + (this.to == null ? 0 : this.to[i].hashCode()); |
|
|
|
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.cc); |
|
|
|
} |
|
|
|
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.bcc); |
|
|
|
for (int i = 0; this.cc != null && i < this.cc.length; i++) { |
|
|
|
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.sentDate); |
|
|
|
hashCode = 29 * hashCode + (this.cc == null ? 0 : this.cc[i].hashCode()); |
|
|
|
hashCode = 29 * hashCode + ObjectUtils.nullSafeHashCode(this.subject); |
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; this.bcc != null && i < this.bcc.length; i++) { |
|
|
|
|
|
|
|
hashCode = 29 * hashCode + (this.bcc == null ? 0 : this.bcc[i].hashCode()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
hashCode = 29 * hashCode + (this.sentDate == null ? 0 : this.sentDate.hashCode()); |
|
|
|
|
|
|
|
hashCode = 29 * hashCode + (this.subject == null ? 0 : this.subject.hashCode()); |
|
|
|
|
|
|
|
hashCode = 29 * hashCode + (this.text == null ? 0 : this.text.hashCode()); |
|
|
|
|
|
|
|
return hashCode; |
|
|
|
return hashCode; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public String toString() { |
|
|
|
|
|
|
|
StringBuilder sb = new StringBuilder("SimpleMailMessage: "); |
|
|
|
|
|
|
|
sb.append("from=").append(this.from).append("; "); |
|
|
|
|
|
|
|
sb.append("replyTo=").append(this.replyTo).append("; "); |
|
|
|
|
|
|
|
sb.append("to=").append(StringUtils.arrayToCommaDelimitedString(this.to)).append("; "); |
|
|
|
|
|
|
|
sb.append("cc=").append(StringUtils.arrayToCommaDelimitedString(this.cc)).append("; "); |
|
|
|
|
|
|
|
sb.append("bcc=").append(StringUtils.arrayToCommaDelimitedString(this.bcc)).append("; "); |
|
|
|
|
|
|
|
sb.append("sentDate=").append(this.sentDate).append("; "); |
|
|
|
|
|
|
|
sb.append("subject=").append(this.subject).append("; "); |
|
|
|
|
|
|
|
sb.append("text=").append(this.text); |
|
|
|
|
|
|
|
return sb.toString(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
|
|
|
private static String[] copyOrNull(@Nullable String[] state) { |
|
|
|
|
|
|
|
if (state == null) { |
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return copy(state); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static String[] copy(String[] state) { |
|
|
|
private static String[] copy(String[] state) { |
|
|
|
String[] copy = new String[state.length]; |
|
|
|
String[] copy = new String[state.length]; |
|
|
|
|