Polishing

This commit is contained in:
Juergen Hoeller
2014-08-23 01:28:10 +02:00
parent 54ba5c5e7b
commit 93ad7f8def
3 changed files with 23 additions and 25 deletions

View File

@@ -107,19 +107,19 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
public UUID getId() {
return this.get(ID, UUID.class);
return get(ID, UUID.class);
}
public Long getTimestamp() {
return this.get(TIMESTAMP, Long.class);
return get(TIMESTAMP, Long.class);
}
public Object getReplyChannel() {
return this.get(REPLY_CHANNEL);
return get(REPLY_CHANNEL);
}
public Object getErrorChannel() {
return this.get(ERROR_CHANNEL);
return get(ERROR_CHANNEL);
}
@SuppressWarnings("unchecked")
@@ -156,7 +156,7 @@ public final class MessageHeaders implements Map<String, Object>, Serializable {
}
// Map implementation
// Delegating Map implementation
public boolean containsKey(Object key) {
return this.headers.containsKey(key);

View File

@@ -71,20 +71,21 @@ public class GenericMessage<T> implements Message<T>, Serializable {
}
public boolean equals(Object obj) {
if (this == obj) {
public boolean equals(Object other) {
if (this == other) {
return true;
}
if (obj != null && obj instanceof GenericMessage<?>) {
GenericMessage<?> other = (GenericMessage<?>) obj;
return (ObjectUtils.nullSafeEquals(this.headers.getId(), other.headers.getId()) &&
this.headers.equals(other.headers) && this.payload.equals(other.payload));
if (!(other instanceof GenericMessage)) {
return false;
}
return false;
GenericMessage<?> otherMsg = (GenericMessage<?>) other;
// Using nullSafeEquals for proper array equals comparisons
return (ObjectUtils.nullSafeEquals(this.payload, otherMsg.payload) && this.headers.equals(otherMsg.headers));
}
public int hashCode() {
return (this.headers.hashCode() * 23 + ObjectUtils.nullSafeHashCode(this.payload));
// Using nullSafeHashCode for proper array hashCode handling
return (ObjectUtils.nullSafeHashCode(this.payload) * 23 + this.headers.hashCode());
}
public String toString() {