1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.newsletter.business.topic;
35
36 import fr.paris.lutece.plugins.newsletter.service.topic.NewsletterTopicService;
37
38 import org.apache.commons.lang3.StringUtils;
39
40
41
42
43 public class NewsletterTopic implements Comparable<NewsletterTopic>
44 {
45 private int _nId;
46 private int _nIdNewsletter;
47 private String _strTopicTypeCode;
48 private String _strTitle;
49 private int _nOrder;
50 private int _nSection;
51
52
53
54
55
56
57 public int getId( )
58 {
59 return _nId;
60 }
61
62
63
64
65
66
67
68 public void setId( int nId )
69 {
70 this._nId = nId;
71 }
72
73
74
75
76
77
78 public int getIdNewsletter( )
79 {
80 return _nIdNewsletter;
81 }
82
83
84
85
86
87
88
89 public void setIdNewsletter( int nIdNewsletter )
90 {
91 this._nIdNewsletter = nIdNewsletter;
92 }
93
94
95
96
97
98
99 public String getTopicTypeCode( )
100 {
101 return _strTopicTypeCode;
102 }
103
104
105
106
107
108
109 public String getTopicTypeName( )
110 {
111 return NewsletterTopicService.getService( ).getTopicTypeName( getTopicTypeCode( ) );
112 }
113
114
115
116
117
118
119
120 public void setTopicTypeCode( String strTopicTypeCode )
121 {
122 _strTopicTypeCode = strTopicTypeCode;
123 }
124
125
126
127
128
129
130 public String getTitle( )
131 {
132 return _strTitle;
133 }
134
135
136
137
138
139
140
141 public void setTitle( String strTitle )
142 {
143 this._strTitle = strTitle;
144 }
145
146
147
148
149
150
151 public int getOrder( )
152 {
153 return _nOrder;
154 }
155
156
157
158
159
160
161
162 public void setOrder( int nOrder )
163 {
164 this._nOrder = nOrder;
165 }
166
167
168
169
170
171
172 public int getSection( )
173 {
174 return _nSection;
175 }
176
177
178
179
180
181
182
183 public void setSection( int nSection )
184 {
185 this._nSection = nSection;
186 }
187
188
189
190
191 @Override
192 public int compareTo( NewsletterTopic o )
193 {
194 int nRes = 0;
195 if ( getIdNewsletter( ) > o.getIdNewsletter( ) )
196 {
197 nRes = 1;
198 }
199 else
200 {
201 if ( nRes == 0 && getIdNewsletter( ) < o.getIdNewsletter( ) )
202 {
203 nRes = -1;
204 }
205 else
206 {
207 if ( nRes == 0 && getSection( ) > o.getSection( ) )
208 {
209 nRes = 1;
210 }
211 if ( nRes == 0 && getSection( ) < o.getSection( ) )
212 {
213 nRes = -1;
214 }
215 if ( nRes == 0 && getOrder( ) > o.getOrder( ) )
216 {
217 nRes = 1;
218 }
219 if ( nRes == 0 && getOrder( ) < o.getOrder( ) )
220 {
221 nRes = -1;
222 }
223 }
224 }
225
226
227 return nRes;
228 }
229
230
231
232
233 @Override
234 public int hashCode( )
235 {
236 final int prime = 31;
237 int result = 1;
238 result = prime * result + _nSection;
239 result = prime * result + _nId;
240 result = prime * result + _nIdNewsletter;
241 result = prime * result + _nOrder;
242 result = prime * result + ( ( _strTopicTypeCode == null ) ? 0 : _strTopicTypeCode.hashCode( ) );
243 return result;
244 }
245
246
247
248
249 @Override
250 public boolean equals( Object o )
251 {
252 if ( !( o instanceof NewsletterTopic ) )
253 {
254 return false;
255 }
256 NewsletterTopic./../../fr/paris/lutece/plugins/newsletter/business/topic/NewsletterTopic.html#NewsletterTopic">NewsletterTopic otherTopic = (NewsletterTopic) o;
257 return getId( ) == otherTopic.getId( ) && getIdNewsletter( ) == otherTopic.getIdNewsletter( ) && getSection( ) == otherTopic.getSection( )
258 && getOrder( ) == otherTopic.getOrder( ) && StringUtils.equals( getTopicTypeCode( ), otherTopic.getTopicTypeCode( ) );
259 }
260
261 }