|
| 1 | +package co.aurasphere.botmill.telegram.model; |
| 2 | + |
| 3 | +import java.io.Serializable; |
| 4 | + |
| 5 | +import com.google.gson.annotations.SerializedName; |
| 6 | + |
| 7 | +/** |
| 8 | + * This object represents a chat. |
| 9 | + * |
| 10 | + * @author Donato Rimenti |
| 11 | + * @date Dec 25, 2016 |
| 12 | + */ |
| 13 | +public class Chat implements Serializable { |
| 14 | + |
| 15 | + /** |
| 16 | + * The serial version UID. |
| 17 | + */ |
| 18 | + private static final long serialVersionUID = 1L; |
| 19 | + |
| 20 | + /** |
| 21 | + * Unique identifier for this chat. This number may be greater than 32 bits |
| 22 | + * and some programming languages may have difficulty/silent defects in |
| 23 | + * interpreting it. But it smaller than 52 bits, so a signed 64 bit integer |
| 24 | + * or double-precision float type are safe for storing this identifier. |
| 25 | + */ |
| 26 | + private String id; |
| 27 | + |
| 28 | + /** |
| 29 | + * Type of chat, can be either “private”, “group”, “supergroup” or |
| 30 | + * “channel”. |
| 31 | + */ |
| 32 | + private ChatType type; |
| 33 | + |
| 34 | + /** |
| 35 | + * Type of chat, can be either “private”, “group”, “supergroup” or “channel”. |
| 36 | + */ |
| 37 | + private String title; |
| 38 | + |
| 39 | + /** |
| 40 | + * Optional. Username, for private chats, supergroups and channels if available. |
| 41 | + */ |
| 42 | + private String username; |
| 43 | + |
| 44 | + /** |
| 45 | + * Optional. First name of the other party in a private chat. |
| 46 | + */ |
| 47 | + @SerializedName("first_name") |
| 48 | + private String firstName; |
| 49 | + |
| 50 | + /** |
| 51 | + * Optional. Last name of the other party in a private chat. |
| 52 | + */ |
| 53 | + @SerializedName("last_name") |
| 54 | + private String lastName; |
| 55 | + |
| 56 | + /** |
| 57 | + * Optional. True if a group has ‘All Members Are Admins’ enabled. |
| 58 | + */ |
| 59 | + @SerializedName("all_members_are_administrators") |
| 60 | + private boolean allMembersAreAdministrators; |
| 61 | + |
| 62 | + /** |
| 63 | + * Gets the {@link #id}. |
| 64 | + * |
| 65 | + * @return the {@link #id}. |
| 66 | + */ |
| 67 | + public String getId() { |
| 68 | + return id; |
| 69 | + } |
| 70 | + |
| 71 | + /** |
| 72 | + * Sets the {@link #id}. |
| 73 | + * |
| 74 | + * @param id the {@link #id} to set. |
| 75 | + */ |
| 76 | + public void setId(String id) { |
| 77 | + this.id = id; |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * Gets the {@link #type}. |
| 82 | + * |
| 83 | + * @return the {@link #type}. |
| 84 | + */ |
| 85 | + public ChatType getType() { |
| 86 | + return type; |
| 87 | + } |
| 88 | + |
| 89 | + /** |
| 90 | + * Sets the {@link #type}. |
| 91 | + * |
| 92 | + * @param type the {@link #type} to set. |
| 93 | + */ |
| 94 | + public void setType(ChatType type) { |
| 95 | + this.type = type; |
| 96 | + } |
| 97 | + |
| 98 | + /** |
| 99 | + * Gets the {@link #title}. |
| 100 | + * |
| 101 | + * @return the {@link #title}. |
| 102 | + */ |
| 103 | + public String getTitle() { |
| 104 | + return title; |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * Sets the {@link #title}. |
| 109 | + * |
| 110 | + * @param title the {@link #title} to set. |
| 111 | + */ |
| 112 | + public void setTitle(String title) { |
| 113 | + this.title = title; |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * Gets the {@link #username}. |
| 118 | + * |
| 119 | + * @return the {@link #username}. |
| 120 | + */ |
| 121 | + public String getUsername() { |
| 122 | + return username; |
| 123 | + } |
| 124 | + |
| 125 | + /** |
| 126 | + * Sets the {@link #username}. |
| 127 | + * |
| 128 | + * @param username the {@link #username} to set. |
| 129 | + */ |
| 130 | + public void setUsername(String username) { |
| 131 | + this.username = username; |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * Gets the {@link #firstName}. |
| 136 | + * |
| 137 | + * @return the {@link #firstName}. |
| 138 | + */ |
| 139 | + public String getFirstName() { |
| 140 | + return firstName; |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * Sets the {@link #firstName}. |
| 145 | + * |
| 146 | + * @param firstName the {@link #firstName} to set. |
| 147 | + */ |
| 148 | + public void setFirstName(String firstName) { |
| 149 | + this.firstName = firstName; |
| 150 | + } |
| 151 | + |
| 152 | + /** |
| 153 | + * Gets the {@link #lastName}. |
| 154 | + * |
| 155 | + * @return the {@link #lastName}. |
| 156 | + */ |
| 157 | + public String getLastName() { |
| 158 | + return lastName; |
| 159 | + } |
| 160 | + |
| 161 | + /** |
| 162 | + * Sets the {@link #lastName}. |
| 163 | + * |
| 164 | + * @param lastName the {@link #lastName} to set. |
| 165 | + */ |
| 166 | + public void setLastName(String lastName) { |
| 167 | + this.lastName = lastName; |
| 168 | + } |
| 169 | + |
| 170 | + /** |
| 171 | + * Checks if is all members are administrators. |
| 172 | + * |
| 173 | + * @return true, if is all members are administrators |
| 174 | + */ |
| 175 | + public boolean isAllMembersAreAdministrators() { |
| 176 | + return allMembersAreAdministrators; |
| 177 | + } |
| 178 | + |
| 179 | + /** |
| 180 | + * Sets the {@link #allMembersAreAdministrators}. |
| 181 | + * |
| 182 | + * @param allMembersAreAdministrators the {@link #allMembersAreAdministrators} to set. |
| 183 | + */ |
| 184 | + public void setAllMembersAreAdministrators(boolean allMembersAreAdministrators) { |
| 185 | + this.allMembersAreAdministrators = allMembersAreAdministrators; |
| 186 | + } |
| 187 | + |
| 188 | + /* (non-Javadoc) |
| 189 | + * @see java.lang.Object#hashCode() |
| 190 | + */ |
| 191 | + @Override |
| 192 | + public int hashCode() { |
| 193 | + final int prime = 31; |
| 194 | + int result = 1; |
| 195 | + result = prime * result + (allMembersAreAdministrators ? 1231 : 1237); |
| 196 | + result = prime * result |
| 197 | + + ((firstName == null) ? 0 : firstName.hashCode()); |
| 198 | + result = prime * result + ((id == null) ? 0 : id.hashCode()); |
| 199 | + result = prime * result |
| 200 | + + ((lastName == null) ? 0 : lastName.hashCode()); |
| 201 | + result = prime * result + ((title == null) ? 0 : title.hashCode()); |
| 202 | + result = prime * result |
| 203 | + + ((username == null) ? 0 : username.hashCode()); |
| 204 | + return result; |
| 205 | + } |
| 206 | + |
| 207 | + /* (non-Javadoc) |
| 208 | + * @see java.lang.Object#equals(java.lang.Object) |
| 209 | + */ |
| 210 | + @Override |
| 211 | + public boolean equals(Object obj) { |
| 212 | + if (this == obj) |
| 213 | + return true; |
| 214 | + if (obj == null) |
| 215 | + return false; |
| 216 | + if (getClass() != obj.getClass()) |
| 217 | + return false; |
| 218 | + Chat other = (Chat) obj; |
| 219 | + if (allMembersAreAdministrators != other.allMembersAreAdministrators) |
| 220 | + return false; |
| 221 | + if (firstName == null) { |
| 222 | + if (other.firstName != null) |
| 223 | + return false; |
| 224 | + } else if (!firstName.equals(other.firstName)) |
| 225 | + return false; |
| 226 | + if (id == null) { |
| 227 | + if (other.id != null) |
| 228 | + return false; |
| 229 | + } else if (!id.equals(other.id)) |
| 230 | + return false; |
| 231 | + if (lastName == null) { |
| 232 | + if (other.lastName != null) |
| 233 | + return false; |
| 234 | + } else if (!lastName.equals(other.lastName)) |
| 235 | + return false; |
| 236 | + if (title == null) { |
| 237 | + if (other.title != null) |
| 238 | + return false; |
| 239 | + } else if (!title.equals(other.title)) |
| 240 | + return false; |
| 241 | + if (username == null) { |
| 242 | + if (other.username != null) |
| 243 | + return false; |
| 244 | + } else if (!username.equals(other.username)) |
| 245 | + return false; |
| 246 | + return true; |
| 247 | + } |
| 248 | + |
| 249 | + /* (non-Javadoc) |
| 250 | + * @see java.lang.Object#toString() |
| 251 | + */ |
| 252 | + @Override |
| 253 | + public String toString() { |
| 254 | + return "Chat [id=" + id + ", title=" + title + ", username=" + username |
| 255 | + + ", firstName=" + firstName + ", lastName=" + lastName |
| 256 | + + ", allMembersAreAdministrators=" |
| 257 | + + allMembersAreAdministrators + "]"; |
| 258 | + } |
| 259 | + |
| 260 | +} |
0 commit comments