File tree 2 files changed +9
-24
lines changed
src/test/java/org/apache/ibatis/submitted
2 files changed +9
-24
lines changed Original file line number Diff line number Diff line change 15
15
*/
16
16
package org .apache .ibatis .submitted .constructor_columnprefix ;
17
17
18
+ import java .util .Objects ;
19
+
18
20
public class EntityKey {
19
21
private Integer id ;
20
22
@@ -28,10 +30,7 @@ public void setId(Integer id) {
28
30
29
31
@ Override
30
32
public int hashCode () {
31
- final int prime = 31 ;
32
- int result = 1 ;
33
- result = prime * result + ((id == null ) ? 0 : id .hashCode ());
34
- return result ;
33
+ return Objects .hash (id );
35
34
}
36
35
37
36
@ Override
@@ -43,11 +42,7 @@ public boolean equals(Object obj) {
43
42
return false ;
44
43
}
45
44
EntityKey other = (EntityKey ) obj ;
46
- if (id == null ) {
47
- if (other .id != null ) {
48
- return false ;
49
- }
50
- } else if (!id .equals (other .id )) {
45
+ if (!Objects .equals (id , other .id )) {
51
46
return false ;
52
47
}
53
48
return true ;
Original file line number Diff line number Diff line change 15
15
*/
16
16
package org .apache .ibatis .submitted .extendresultmap ;
17
17
18
+ import java .util .Objects ;
19
+
18
20
public class TestModel {
19
21
20
22
private String a ;
@@ -46,11 +48,7 @@ public void setB(String b) {
46
48
47
49
@ Override
48
50
public int hashCode () {
49
- final int prime = 31 ;
50
- int result = 1 ;
51
- result = prime * result + ((a == null ) ? 0 : a .hashCode ());
52
- result = prime * result + ((b == null ) ? 0 : b .hashCode ());
53
- return result ;
51
+ return Objects .hash (a , b );
54
52
}
55
53
56
54
@ Override
@@ -62,18 +60,10 @@ public boolean equals(Object obj) {
62
60
return false ;
63
61
}
64
62
TestModel other = (TestModel ) obj ;
65
- if (a == null ) {
66
- if (other .a != null ) {
67
- return false ;
68
- }
69
- } else if (!a .equals (other .a )) {
63
+ if (!Objects .equals (a , other .a )) {
70
64
return false ;
71
65
}
72
- if (b == null ) {
73
- if (other .b != null ) {
74
- return false ;
75
- }
76
- } else if (!b .equals (other .b )) {
66
+ if (!Objects .equals (b , other .b )) {
77
67
return false ;
78
68
}
79
69
return true ;
You can’t perform that action at this time.
0 commit comments