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