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 protected final int id;
22 protected final String username;
23 protected final String password;
24 protected final String email;
25 protected final String bio;
26 protected final Section favouriteSection;
27
28 public ImmutableAuthor(int id, String username, String password, String email, String bio, Section section) {
29 this.id = id;
30 this.username = username;
31 this.password = password;
32 this.email = email;
33 this.bio = bio;
34 this.favouriteSection = section;
35 }
36
37 public int getId() {
38 return id;
39 }
40
41 public String getUsername() {
42 return username;
43 }
44
45 public String getPassword() {
46 return password;
47 }
48
49 public String getEmail() {
50 return email;
51 }
52
53 public String getBio() {
54 return bio;
55 }
56
57 public Section getFavouriteSection() {
58 return favouriteSection;
59 }
60
61 @Override
62 public boolean equals(Object o) {
63 if (this == o) return true;
64 if (!(o instanceof Author)) return false;
65
66 Author author = (Author) o;
67
68 if (id != author.id) return false;
69 if (bio != null ? !bio.equals(author.bio) : author.bio != null) return false;
70 if (email != null ? !email.equals(author.email) : author.email != null) return false;
71 if (password != null ? !password.equals(author.password) : author.password != null) return false;
72 if (username != null ? !username.equals(author.username) : author.username != null) return false;
73 if (favouriteSection != null ? !favouriteSection.equals(author.favouriteSection) : author.favouriteSection != null)
74 return false;
75
76 return true;
77 }
78
79 @Override
80 public int hashCode() {
81 int result;
82 result = id;
83 result = 31 * result + (username != null ? username.hashCode() : 0);
84 result = 31 * result + (password != null ? password.hashCode() : 0);
85 result = 31 * result + (email != null ? email.hashCode() : 0);
86 result = 31 * result + (bio != null ? bio.hashCode() : 0);
87 result = 31 * result + (favouriteSection != null ? favouriteSection.hashCode() : 0);
88 return result;
89 }
90
91 @Override
92 public String toString() {
93 return id + " " + username + " " + password + " " + email;
94 }
95 }