Add equals and hashCode to UnwrappedMongoPersistentProperty.
Fixes #3683 Original Pull Request: #3684
This commit is contained in:
@@ -15,8 +15,11 @@
|
||||
*/
|
||||
package org.springframework.data.mongodb.core.mapping;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Rogério Meneguelli Gatto
|
||||
* @since 3.2
|
||||
*/
|
||||
class UnwrapEntityContext {
|
||||
@@ -30,4 +33,34 @@ class UnwrapEntityContext {
|
||||
public MongoPersistentProperty getProperty() {
|
||||
return property;
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(property);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UnwrapEntityContext other = (UnwrapEntityContext) obj;
|
||||
|
||||
return Objects.equals(property, other.property);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.data.mongodb.core.mapping;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.data.mapping.Association;
|
||||
import org.springframework.data.mapping.PersistentEntity;
|
||||
@@ -29,6 +30,7 @@ import org.springframework.lang.Nullable;
|
||||
* Unwrapped variant of {@link MongoPersistentProperty}.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Rogério Meneguelli Gatto
|
||||
* @since 3.2
|
||||
* @see Unwrapped
|
||||
*/
|
||||
@@ -321,4 +323,33 @@ class UnwrappedMongoPersistentProperty implements MongoPersistentProperty {
|
||||
return delegate.getAccessorForOwner(owner);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(delegate, context);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see java.lang.Object#equals(java.lang.Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (obj == null || getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
UnwrappedMongoPersistentProperty other = (UnwrappedMongoPersistentProperty) obj;
|
||||
|
||||
return Objects.equals(delegate, other.delegate) && Objects.equals(context, other.context);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user