View Javadoc
1   /*
2    *    Copyright 2009-2021 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 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  }