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}.
@@ -309,21 +309,11 @@ public <T> PersistentPropertyAccessor<T> getAccessorForOwner(T owner) {
309
309
310
310
/*
311
311
* (non-Javadoc)
312
- *
313
- * @see java.lang.Object#hashCode()
314
- */
315
- @ Override
316
- public int hashCode () {
317
- return Objects .hash (delegate , context );
318
- }
319
-
320
- /*
321
- * (non-Javadoc)
322
- *
323
312
* @see java.lang.Object#equals(java.lang.Object)
324
313
*/
325
314
@ Override
326
315
public boolean equals (Object obj ) {
316
+
327
317
if (this == obj ) {
328
318
return true ;
329
319
}
@@ -332,8 +322,22 @@ public boolean equals(Object obj) {
332
322
return false ;
333
323
}
334
324
335
- UnwrappedMongoPersistentProperty other = (UnwrappedMongoPersistentProperty ) obj ;
325
+ UnwrappedMongoPersistentProperty that = (UnwrappedMongoPersistentProperty ) obj ;
326
+ if (!ObjectUtils .nullSafeEquals (delegate , that .delegate )) {
327
+ return false ;
328
+ }
329
+ return ObjectUtils .nullSafeEquals (context , that .context );
330
+ }
331
+
332
+ /*
333
+ * (non-Javadoc)
334
+ * @see java.lang.Object#hashCode()
335
+ */
336
+ @ Override
337
+ public int hashCode () {
336
338
337
- return Objects .equals (delegate , other .delegate ) && Objects .equals (context , other .context );
339
+ int result = ObjectUtils .nullSafeHashCode (delegate );
340
+ result = 31 * result + ObjectUtils .nullSafeHashCode (context );
341
+ return result ;
338
342
}
339
343
}
0 commit comments