Browse Source

Add equals/hashcode to FlashMap

Brings consistency with the existing compareTo implementation.
pull/629/head
Rossen Stoyanchev 10 years ago
parent
commit
1ca0460534
  1. 24
      spring-webmvc/src/main/java/org/springframework/web/servlet/FlashMap.java

24
spring-webmvc/src/main/java/org/springframework/web/servlet/FlashMap.java

@ -20,6 +20,7 @@ import java.util.HashMap; @@ -20,6 +20,7 @@ import java.util.HashMap;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
/**
@ -146,6 +147,29 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl @@ -146,6 +147,29 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
}
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj != null && obj instanceof FlashMap) {
FlashMap other = (FlashMap) obj;
if (this.targetRequestParams.equals(other.targetRequestParams) &&
ObjectUtils.nullSafeEquals(this.targetRequestPath, other.targetRequestPath)) {
return true;
}
}
return false;
}
@Override
public int hashCode() {
int result = super.hashCode();
result = 31 * result + (this.targetRequestPath != null ? this.targetRequestPath.hashCode() : 0);
result = 31 * result + this.targetRequestParams.hashCode();
return result;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();

Loading…
Cancel
Save