Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
Message |
|
| 1.7142857142857142;1.714 |
1 | package org.jtheque.core.managers.message; | |
2 | ||
3 | /* | |
4 | * This file is part of JTheque. | |
5 | * | |
6 | * JTheque is free software: you can redistribute it and/or modify | |
7 | * it under the terms of the GNU General Public License as published by | |
8 | * the Free Software Foundation, either version 3 of the License. | |
9 | * | |
10 | * JTheque is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with JTheque. If not, see <http://www.gnu.org/licenses/>. | |
17 | */ | |
18 | ||
19 | import org.jtheque.utils.Constants; | |
20 | import org.jtheque.utils.bean.EqualsUtils; | |
21 | import org.jtheque.utils.bean.IntDate; | |
22 | ||
23 | /** | |
24 | * @author Baptiste Wicht | |
25 | */ | |
26 | 0 | public final class Message implements Comparable<Message> { |
27 | /** | |
28 | * The Id of the message. | |
29 | */ | |
30 | private int id; | |
31 | ||
32 | /** | |
33 | * The title of the message. | |
34 | */ | |
35 | private String title; | |
36 | ||
37 | /** | |
38 | * The text of the message. | |
39 | */ | |
40 | private String message; | |
41 | ||
42 | /** | |
43 | * The date of the message. | |
44 | */ | |
45 | private IntDate date; | |
46 | ||
47 | /** | |
48 | * The source of the message. | |
49 | */ | |
50 | private String source; | |
51 | ||
52 | /** | |
53 | * Return the Id of the message. | |
54 | * | |
55 | * @return The id of the message. | |
56 | */ | |
57 | public int getId() { | |
58 | 0 | return id; |
59 | } | |
60 | ||
61 | /** | |
62 | * Set the Id of the message. | |
63 | * | |
64 | * @param id The Id of the message. | |
65 | */ | |
66 | public void setId(int id) { | |
67 | 0 | this.id = id; |
68 | 0 | } |
69 | ||
70 | /** | |
71 | * Return the title of the message. | |
72 | * | |
73 | * @return The title of the message. | |
74 | */ | |
75 | public String getTitle() { | |
76 | 0 | return title; |
77 | } | |
78 | ||
79 | /** | |
80 | * Set the title of the message. | |
81 | * | |
82 | * @param title The title of the message. | |
83 | */ | |
84 | public void setTitle(String title) { | |
85 | 0 | this.title = title; |
86 | 0 | } |
87 | ||
88 | /** | |
89 | * Return the text of the message. | |
90 | * | |
91 | * @return The text of the message. | |
92 | */ | |
93 | public String getMessage() { | |
94 | 0 | return message; |
95 | } | |
96 | ||
97 | /** | |
98 | * Set the text of the message. | |
99 | * | |
100 | * @param message The text of the message. | |
101 | */ | |
102 | public void setMessage(String message) { | |
103 | 0 | this.message = message; |
104 | 0 | } |
105 | ||
106 | /** | |
107 | * Return the date of the message. | |
108 | * | |
109 | * @return The date of the message. | |
110 | */ | |
111 | public IntDate getDate() { | |
112 | 0 | return date; |
113 | } | |
114 | ||
115 | /** | |
116 | * Set the date of the message. | |
117 | * | |
118 | * @param date The date of the message. | |
119 | */ | |
120 | public void setDate(IntDate date) { | |
121 | 0 | this.date = date; |
122 | 0 | } |
123 | ||
124 | /** | |
125 | * Return the source of the message. | |
126 | * | |
127 | * @return The source of the message. | |
128 | */ | |
129 | public String getSource() { | |
130 | 0 | return source; |
131 | } | |
132 | ||
133 | /** | |
134 | * Set the source of the message. | |
135 | * | |
136 | * @param source The source of the message. | |
137 | */ | |
138 | public void setSource(String source) { | |
139 | 0 | this.source = source; |
140 | 0 | } |
141 | ||
142 | @Override | |
143 | public String toString() { | |
144 | 0 | return "Message{" + |
145 | "id=" + id + | |
146 | ", title='" + title + '\'' + | |
147 | ", message='" + message + '\'' + | |
148 | ", date=" + date + | |
149 | ", source='" + source + '\'' + | |
150 | '}'; | |
151 | } | |
152 | ||
153 | @Override | |
154 | public boolean equals(Object o) { | |
155 | 0 | if (EqualsUtils.areObjectIncompatible(this, o)) { |
156 | 0 | return false; |
157 | } | |
158 | ||
159 | 0 | Message other = (Message) o; |
160 | ||
161 | 0 | if (EqualsUtils.areNotEquals(id, other.id)) { |
162 | 0 | return false; |
163 | } | |
164 | ||
165 | 0 | if (EqualsUtils.areNotEquals(date, other.date)) { |
166 | 0 | return false; |
167 | } | |
168 | ||
169 | 0 | if (EqualsUtils.areNotEquals(message, other.message)) { |
170 | 0 | return false; |
171 | } | |
172 | ||
173 | 0 | if (EqualsUtils.areNotEquals(source, other.source)) { |
174 | 0 | return false; |
175 | } | |
176 | ||
177 | 0 | return !EqualsUtils.areNotEquals(title, other.title); |
178 | } | |
179 | ||
180 | @Override | |
181 | public int hashCode() { | |
182 | 0 | int result = Constants.HASH_CODE_START; |
183 | ||
184 | 0 | result = Constants.HASH_CODE_PRIME * result + id; |
185 | 0 | result = Constants.HASH_CODE_PRIME * result + title.hashCode(); |
186 | 0 | result = Constants.HASH_CODE_PRIME * result + message.hashCode(); |
187 | 0 | result = Constants.HASH_CODE_PRIME * result + date.hashCode(); |
188 | 0 | result = Constants.HASH_CODE_PRIME * result + source.hashCode(); |
189 | ||
190 | 0 | return result; |
191 | } | |
192 | ||
193 | @Override | |
194 | public int compareTo(Message o) { | |
195 | 0 | return date.compareTo(o.date); |
196 | } | |
197 | } |