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 author)) {
101 return false;
102 }
103
104 if (id != author.id || (bio != null ? !bio.equals(author.bio) : author.bio != null)
105 || (email != null ? !email.equals(author.email) : author.email != null)
106 || (password != null ? !password.equals(author.password) : author.password != null)) {
107 return false;
108 }
109 return username != null ? username.equals(author.username) : author.username == null && favouriteSection != null
110 ? favouriteSection.equals(author.favouriteSection) : author.favouriteSection == null;
111 }
112
113 @Override
114 public int hashCode() {
115 int result = id;
116 result = 31 * result + (username != null ? username.hashCode() : 0);
117 result = 31 * result + (password != null ? password.hashCode() : 0);
118 result = 31 * result + (email != null ? email.hashCode() : 0);
119 result = 31 * result + (bio != null ? bio.hashCode() : 0);
120 return 31 * result + (favouriteSection != null ? favouriteSection.hashCode() : 0);
121 }
122
123 @Override
124 public String toString() {
125 return "Author : " + id + " : " + username + " : " + email;
126 }
127 }