Add equals/hashcode to FlashMap
Brings consistency with the existing compareTo implementation.
This commit is contained in:
parent
bb8be509cd
commit
1ca0460534
|
|
@ -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
|
|||
}
|
||||
}
|
||||
|
||||
@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…
Reference in New Issue