FlashMap's equals implementation needs to call super.equals(...) as well
This commit is contained in:
parent
af6ef5f74c
commit
891335a604
|
|
@ -59,16 +59,15 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide a URL path to help identify the target request for this FlashMap.
|
* Provide a URL path to help identify the target request for this FlashMap.
|
||||||
* The path may be absolute (e.g. /application/resource) or relative to the
|
* <p>The path may be absolute (e.g. "/application/resource") or relative to the
|
||||||
* current request (e.g. ../resource).
|
* current request (e.g. "../resource").
|
||||||
* @param path the URI path
|
|
||||||
*/
|
*/
|
||||||
public void setTargetRequestPath(String path) {
|
public void setTargetRequestPath(String path) {
|
||||||
this.targetRequestPath = path;
|
this.targetRequestPath = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the target URL path or {@code null}.
|
* Return the target URL path (or {@code null} if none specified).
|
||||||
*/
|
*/
|
||||||
public String getTargetRequestPath() {
|
public String getTargetRequestPath() {
|
||||||
return this.targetRequestPath;
|
return this.targetRequestPath;
|
||||||
|
|
@ -76,7 +75,7 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide request parameters identifying the request for this FlashMap.
|
* Provide request parameters identifying the request for this FlashMap.
|
||||||
* @param params a Map with the names and values of expected parameters.
|
* @param params a Map with the names and values of expected parameters
|
||||||
*/
|
*/
|
||||||
public FlashMap addTargetRequestParams(MultiValueMap<String, String> params) {
|
public FlashMap addTargetRequestParams(MultiValueMap<String, String> params) {
|
||||||
if (params != null) {
|
if (params != null) {
|
||||||
|
|
@ -91,8 +90,8 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide a request parameter identifying the request for this FlashMap.
|
* Provide a request parameter identifying the request for this FlashMap.
|
||||||
* @param name the expected parameter name, skipped if empty or {@code null}
|
* @param name the expected parameter name (skipped if empty or {@code null})
|
||||||
* @param value the expected value, skipped if empty or {@code null}
|
* @param value the expected value (skipped if empty or {@code null})
|
||||||
*/
|
*/
|
||||||
public FlashMap addTargetRequestParam(String name, String value) {
|
public FlashMap addTargetRequestParam(String name, String value) {
|
||||||
if (StringUtils.hasText(name) && StringUtils.hasText(value)) {
|
if (StringUtils.hasText(name) && StringUtils.hasText(value)) {
|
||||||
|
|
@ -118,18 +117,15 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether this instance has expired depending on the amount of elapsed
|
* Return whether this instance has expired depending on the amount of
|
||||||
* time since the call to {@link #startExpirationPeriod}.
|
* elapsed time since the call to {@link #startExpirationPeriod}.
|
||||||
*/
|
*/
|
||||||
public boolean isExpired() {
|
public boolean isExpired() {
|
||||||
if (this.expirationStartTime != 0) {
|
return (this.expirationStartTime != 0 &&
|
||||||
return (System.currentTimeMillis() - this.expirationStartTime > this.timeToLive * 1000);
|
(System.currentTimeMillis() - this.expirationStartTime > this.timeToLive * 1000));
|
||||||
}
|
|
||||||
else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compare two FlashMaps and prefer the one that specifies a target URL
|
* Compare two FlashMaps and prefer the one that specifies a target URL
|
||||||
* path or has more target URL parameters. Before comparing FlashMap
|
* path or has more target URL parameters. Before comparing FlashMap
|
||||||
|
|
@ -148,24 +144,23 @@ public final class FlashMap extends HashMap<String, Object> implements Comparabl
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object other) {
|
||||||
if (this == obj) {
|
if (this == other) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (obj != null && obj instanceof FlashMap) {
|
if (!(other instanceof FlashMap)) {
|
||||||
FlashMap other = (FlashMap) obj;
|
|
||||||
if (this.targetRequestParams.equals(other.targetRequestParams) &&
|
|
||||||
ObjectUtils.nullSafeEquals(this.targetRequestPath, other.targetRequestPath)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
FlashMap otherFlashMap = (FlashMap) other;
|
||||||
|
return (super.equals(otherFlashMap) &&
|
||||||
|
ObjectUtils.nullSafeEquals(this.targetRequestPath, otherFlashMap.targetRequestPath) &&
|
||||||
|
this.targetRequestParams.equals(otherFlashMap.targetRequestParams));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int result = super.hashCode();
|
int result = super.hashCode();
|
||||||
result = 31 * result + (this.targetRequestPath != null ? this.targetRequestPath.hashCode() : 0);
|
result = 31 * result + ObjectUtils.nullSafeHashCode(this.targetRequestPath);
|
||||||
result = 31 * result + this.targetRequestParams.hashCode();
|
result = 31 * result + this.targetRequestParams.hashCode();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue