1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.domain.blog;
17
18 public class ComplexImmutableAuthorId {
19 protected final int id;
20 protected final String email;
21 protected final String username;
22 protected final String password;
23
24 public ComplexImmutableAuthorId(int aId, String aEmail, String aUsername, String aPassword) {
25 id = aId;
26 email = aEmail;
27 username = aUsername;
28 password = aPassword;
29 }
30
31 public int getId() {
32 return id;
33 }
34
35 public String getEmail() {
36 return email;
37 }
38
39 public String getUsername() {
40 return username;
41 }
42
43 public String getPassword() {
44 return password;
45 }
46
47 @Override
48 public boolean equals(Object o) {
49 if (this == o) {
50 return true;
51 }
52 if (o == null || getClass() != o.getClass()) {
53 return false;
54 }
55
56 final ComplexImmutableAuthorId that = (ComplexImmutableAuthorId) o;
57
58 return id == that.id && email != null ? email.equals(that.email)
59 : that.email == null && password != null ? password.equals(that.password)
60 : that.password == null && username != null ? username.equals(that.username) : that.username == null;
61 }
62
63 @Override
64 public int hashCode() {
65 int myresult = id;
66 myresult = 31 * myresult + (email != null ? email.hashCode() : 0);
67 myresult = 31 * myresult + (username != null ? username.hashCode() : 0);
68 return 31 * myresult + (password != null ? password.hashCode() : 0);
69 }
70 }