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 ImmutableAuthor implements Serializable {
21 private static final long serialVersionUID = 1L;
22 protected final int id;
23 protected final String username;
24 protected final String password;
25 protected final String email;
26 protected final String bio;
27 protected final Section favouriteSection;
28
29 public ImmutableAuthor(int id, String username, String password, String email, String bio, Section section) {
30 this.id = id;
31 this.username = username;
32 this.password = password;
33 this.email = email;
34 this.bio = bio;
35 this.favouriteSection = section;
36 }
37
38 public int getId() {
39 return id;
40 }
41
42 public String getUsername() {
43 return username;
44 }
45
46 public String getPassword() {
47 return password;
48 }
49
50 public String getEmail() {
51 return email;
52 }
53
54 public String getBio() {
55 return bio;
56 }
57
58 public Section getFavouriteSection() {
59 return favouriteSection;
60 }
61
62 @Override
63 public boolean equals(Object o) {
64 if (this == o) {
65 return true;
66 }
67 if (!(o instanceof Author author)) {
68 return false;
69 }
70
71 if (id != author.id || (bio != null ? !bio.equals(author.bio) : author.bio != null)
72 || (email != null ? !email.equals(author.email) : author.email != null)
73 || (password != null ? !password.equals(author.password) : author.password != null)) {
74 return false;
75 }
76 return username != null ? username.equals(author.username) : author.username == null && favouriteSection != null
77 ? favouriteSection.equals(author.favouriteSection) : author.favouriteSection == null;
78 }
79
80 @Override
81 public int hashCode() {
82 int 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 return 31 * result + (favouriteSection != null ? favouriteSection.hashCode() : 0);
88 }
89
90 @Override
91 public String toString() {
92 return id + " " + username + " " + password + " " + email;
93 }
94 }