Ensure when equals() is implemented so is hashCode()
Update classes that override `equals()` to ensure that they also implement `hashCode()`. Issue: SPR-16968
This commit is contained in:
committed by
Juergen Hoeller
parent
9de3689f63
commit
634f5c2792
@@ -192,6 +192,14 @@ public abstract class MethodMatchers {
|
|||||||
return (targetClass != null && this.cf2.matches(targetClass));
|
return (targetClass != null && this.cf2.matches(targetClass));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int hashCode = 17;
|
||||||
|
hashCode = 37 * hashCode + this.cf1.hashCode();
|
||||||
|
hashCode = 37 * hashCode + this.cf2.hashCode();
|
||||||
|
return hashCode;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import org.springframework.core.MethodParameter;
|
|||||||
import org.springframework.core.ParameterNameDiscoverer;
|
import org.springframework.core.ParameterNameDiscoverer;
|
||||||
import org.springframework.core.ResolvableType;
|
import org.springframework.core.ResolvableType;
|
||||||
import org.springframework.lang.Nullable;
|
import org.springframework.lang.Nullable;
|
||||||
|
import org.springframework.util.ObjectUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Descriptor for a specific dependency that is about to be injected.
|
* Descriptor for a specific dependency that is about to be injected.
|
||||||
@@ -374,7 +375,6 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object other) {
|
public boolean equals(Object other) {
|
||||||
if (this == other) {
|
if (this == other) {
|
||||||
@@ -388,6 +388,16 @@ public class DependencyDescriptor extends InjectionPoint implements Serializable
|
|||||||
this.nestingLevel == otherDesc.nestingLevel && this.containingClass == otherDesc.containingClass);
|
this.nestingLevel == otherDesc.nestingLevel && this.containingClass == otherDesc.containingClass);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
final int prime = 31;
|
||||||
|
int result = ObjectUtils.nullSafeHashCode(this.containingClass);
|
||||||
|
result = prime * result + Boolean.hashCode(this.eager);
|
||||||
|
result = prime * result + this.nestingLevel;
|
||||||
|
result = prime * result + Boolean.hashCode(this.required);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------
|
//---------------------------------------------------------------------
|
||||||
// Serialization support
|
// Serialization support
|
||||||
|
|||||||
@@ -580,6 +580,16 @@ public class CachingConnectionFactory extends SingleConnectionFactory {
|
|||||||
this.durable == otherKey.durable);
|
this.durable == otherKey.durable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
int prime = 31;
|
||||||
|
int result = ObjectUtils.nullSafeHashCode(this.selector);
|
||||||
|
result = prime * result + ObjectUtils.nullSafeHashCode(this.noLocal);
|
||||||
|
result = prime * result + ObjectUtils.nullSafeHashCode(this.subscription);
|
||||||
|
result = prime * result + Boolean.hashCode(this.durable);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return super.toString() + " [selector=" + this.selector + ", noLocal=" + this.noLocal +
|
return super.toString() + " [selector=" + this.selector + ", noLocal=" + this.noLocal +
|
||||||
|
|||||||
Reference in New Issue
Block a user