1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.ibatis.domain.blog;
17
18 import java.io.Serializable;
19
20 public class ImmutableAuthor implements Serializable {
21 private static final long serialVersionUID = 1L;
22 protected final int id;
23 protected final String username;
24 protected final String password;
25 protected final String email;
26 protected final String bio;
27 protected final Section favouriteSection;
28
29 public ImmutableAuthor(int id, String username, String password, String email, String bio, Section section) {
30 this.id = id;
31 this.username = username;
32 this.password = password;
33 this.email = email;
34 this.bio = bio;
35 this.favouriteSection = section;
36 }
37
38 public int getId() {
39 return id;
40 }
41
42 public String getUsername() {
43 return username;
44 }
45
46 public String getPassword() {
47 return password;
48 }
49
50 public String getEmail() {
51 return email;
52 }
53
54 public String getBio() {
55 return bio;
56 }
57
58 public Section getFavouriteSection() {
59 return favouriteSection;
60 }
61
62 @Override
63 public boolean equals(Object o) {
64 if (this == o) {
65 return true;
66 }
67 if (!(o instanceof Author)) {
68 return false;
69 }
70
71 Author author = (Author) o;
72
73 if ((id != author.id) || (bio != null ? !bio.equals(author.bio) : author.bio != null)
74 || (email != null ? !email.equals(author.email) : author.email != null)
75 || (password != null ? !password.equals(author.password) : author.password != null)) {
76 return false;
77 }
78 if (username != null ? !username.equals(author.username) : author.username != null) {
79 return false;
80 }
81 if (favouriteSection != null ? !favouriteSection.equals(author.favouriteSection)
82 : author.favouriteSection != null) {
83 return false;
84 }
85
86 return true;
87 }
88
89 @Override
90 public int hashCode() {
91 int result;
92 result = id;
93 result = 31 * result + (username != null ? username.hashCode() : 0);
94 result = 31 * result + (password != null ? password.hashCode() : 0);
95 result = 31 * result + (email != null ? email.hashCode() : 0);
96 result = 31 * result + (bio != null ? bio.hashCode() : 0);
97 return 31 * result + (favouriteSection != null ? favouriteSection.hashCode() : 0);
98 }
99
100 @Override
101 public String toString() {
102 return id + " " + username + " " + password + " " + email;
103 }
104 }