View Javadoc
1   /*
2    *    Copyright 2009-2023 the original author or authors.
3    *
4    *    Licensed under the Apache License, Version 2.0 (the "License");
5    *    you may not use this file except in compliance with the License.
6    *    You may obtain a copy of the License at
7    *
8    *       https://www.apache.org/licenses/LICENSE-2.0
9    *
10   *    Unless required by applicable law or agreed to in writing, software
11   *    distributed under the License is distributed on an "AS IS" BASIS,
12   *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *    See the License for the specific language governing permissions and
14   *    limitations under the License.
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 }