Skip to content

Add equals and hashcode to UnwrappedMongoPersistentProperty (fixes #3683) #3684

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package org.springframework.data.mongodb.core.mapping;

import java.util.Objects;

/**
* @author Christoph Strobl
* @since 3.2
Expand All @@ -30,4 +32,34 @@ public UnwrapEntityContext(MongoPersistentProperty property) {
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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
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;
Expand Down Expand Up @@ -321,4 +322,33 @@ public <T> PersistentPropertyAccessor<T> getAccessorForOwner(T owner) {
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);
}
}