18
18
import java .lang .annotation .Annotation ;
19
19
import java .lang .reflect .Field ;
20
20
import java .lang .reflect .Method ;
21
- import java .util .Objects ;
22
21
23
22
import org .springframework .data .mapping .Association ;
24
23
import org .springframework .data .mapping .PersistentEntity ;
25
24
import org .springframework .data .mapping .PersistentPropertyAccessor ;
26
25
import org .springframework .data .util .TypeInformation ;
27
26
import org .springframework .lang .Nullable ;
27
+ import org .springframework .util .ObjectUtils ;
28
28
29
29
/**
30
30
* Unwrapped variant of {@link MongoPersistentProperty}.
@@ -325,21 +325,11 @@ public <T> PersistentPropertyAccessor<T> getAccessorForOwner(T owner) {
325
325
326
326
/*
327
327
* (non-Javadoc)
328
- *
329
- * @see java.lang.Object#hashCode()
330
- */
331
- @ Override
332
- public int hashCode () {
333
- return Objects .hash (delegate , context );
334
- }
335
-
336
- /*
337
- * (non-Javadoc)
338
- *
339
328
* @see java.lang.Object#equals(java.lang.Object)
340
329
*/
341
330
@ Override
342
331
public boolean equals (Object obj ) {
332
+
343
333
if (this == obj ) {
344
334
return true ;
345
335
}
@@ -348,8 +338,22 @@ public boolean equals(Object obj) {
348
338
return false ;
349
339
}
350
340
351
- UnwrappedMongoPersistentProperty other = (UnwrappedMongoPersistentProperty ) obj ;
341
+ UnwrappedMongoPersistentProperty that = (UnwrappedMongoPersistentProperty ) obj ;
342
+ if (!ObjectUtils .nullSafeEquals (delegate , that .delegate )) {
343
+ return false ;
344
+ }
345
+ return ObjectUtils .nullSafeEquals (context , that .context );
346
+ }
347
+
348
+ /*
349
+ * (non-Javadoc)
350
+ * @see java.lang.Object#hashCode()
351
+ */
352
+ @ Override
353
+ public int hashCode () {
352
354
353
- return Objects .equals (delegate , other .delegate ) && Objects .equals (context , other .context );
355
+ int result = ObjectUtils .nullSafeHashCode (delegate );
356
+ result = 31 * result + ObjectUtils .nullSafeHashCode (context );
357
+ return result ;
354
358
}
355
359
}
0 commit comments