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 Author implements Serializable {
21
22 private static final long serialVersionUID = 1L;
23 protected int id;
24 protected String username;
25 protected String password;
26 protected String email;
27 protected String bio;
28 protected Section favouriteSection;
29
30 public Author() {
31 this(-1, null, null, null, null, null);
32 }
33
34 public Author(Integer id, String username, String password, String email, String bio, Section section) {
35 this.id = id;
36 this.username = username;
37 this.password = password;
38 this.email = email;
39 this.bio = bio;
40 this.favouriteSection = section;
41 }
42
43 public Author(int id) {
44 this(id, null, null, null, null, null);
45 }
46
47 public void setId(int id) {
48 this.id = id;
49 }
50
51 public void setUsername(String username) {
52 this.username = username;
53 }
54
55 public void setPassword(String password) {
56 this.password = password;
57 }
58
59 public void setEmail(String email) {
60 this.email = email;
61 }
62
63 public void setBio(String bio) {
64 this.bio = bio;
65 }
66
67 public void setFavouriteSection(Section favouriteSection) {
68 this.favouriteSection = favouriteSection;
69 }
70
71 public int getId() {
72 return id;
73 }
74
75 public String getUsername() {
76 return username;
77 }
78
79 public String getPassword() {
80 return password;
81 }
82
83 public String getEmail() {
84 return email;
85 }
86
87 public String getBio() {
88 return bio;
89 }
90
91 public Section getFavouriteSection() {
92 return favouriteSection;
93 }
94
95 @Override
96 public boolean equals(Object o) {
97 if (this == o) {
98 return true;
99 }
100 if (!(o instanceof Author)) {
101 return false;
102 }
103
104 Author author = (Author) o;
105
106 if ((id != author.id) || (bio != null ? !bio.equals(author.bio) : author.bio != null)
107 || (email != null ? !email.equals(author.email) : author.email != null)
108 || (password != null ? !password.equals(author.password) : author.password != null)) {
109 return false;
110 }
111 if (username != null ? !username.equals(author.username) : author.username != null) {
112 return false;
113 }
114 if (favouriteSection != null ? !favouriteSection.equals(author.favouriteSection)
115 : author.favouriteSection != null) {
116 return false;
117 }
118
119 return true;
120 }
121
122 @Override
123 public int hashCode() {
124 int result;
125 result = id;
126 result = 31 * result + (username != null ? username.hashCode() : 0);
127 result = 31 * result + (password != null ? password.hashCode() : 0);
128 result = 31 * result + (email != null ? email.hashCode() : 0);
129 result = 31 * result + (bio != null ? bio.hashCode() : 0);
130 return 31 * result + (favouriteSection != null ? favouriteSection.hashCode() : 0);
131 }
132
133 @Override
134 public String toString() {
135 return "Author : " + id + " : " + username + " : " + email;
136 }
137 }