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.shoppingcart.business;
35
36 import java.io.Serializable;
37 import java.util.Date;
38
39 import org.apache.commons.lang.StringUtils;
40 import org.apache.commons.lang.time.DateUtils;
41
42
43
44
45
46 public class ShoppingCartItem implements Serializable
47 {
48
49
50
51 public static final int NEW_ID_LOT_FOR_ANONYMOUS_USER = -10;
52
53
54
55 public static final int LAST_ID_LOT_FOR_ANONYMOUS_USER = -1;
56
57
58
59
60 private static final long serialVersionUID = 8367766101486301893L;
61
62 private int _nIdItem;
63 private String _strIdProvider;
64 private int _nIdLot;
65 private String _strIdUser;
66 private String _strResourceType;
67 private String _strIdResource;
68 private double _dItemPrice;
69 private Date _dateCreation;
70
71
72
73
74
75 public int getIdItem( )
76 {
77 return _nIdItem;
78 }
79
80
81
82
83
84 public void setIdItem( int nIdItem )
85 {
86 _nIdItem = nIdItem;
87 }
88
89
90
91
92
93 public String getIdProvider( )
94 {
95 return _strIdProvider;
96 }
97
98
99
100
101
102 public void setIdProvider( String strIdProvider )
103 {
104 _strIdProvider = strIdProvider;
105 }
106
107
108
109
110
111 public int getIdLot( )
112 {
113 return _nIdLot;
114 }
115
116
117
118
119
120 public void setIdLot( int nIdLot )
121 {
122 _nIdLot = nIdLot;
123 }
124
125
126
127
128
129 public String getIdUser( )
130 {
131 return _strIdUser;
132 }
133
134
135
136
137
138 public void setIdUser( String strIdUser )
139 {
140 _strIdUser = strIdUser;
141 }
142
143
144
145
146
147 public String getResourceType( )
148 {
149 return _strResourceType;
150 }
151
152
153
154
155
156
157 public void setResourceType( String strResourceType )
158 {
159 _strResourceType = strResourceType;
160 }
161
162
163
164
165
166 public String getIdResource( )
167 {
168 return _strIdResource;
169 }
170
171
172
173
174
175 public void setIdResource( String strIdResource )
176 {
177 _strIdResource = strIdResource;
178 }
179
180
181
182
183
184 public double getItemPrice( )
185 {
186 return _dItemPrice;
187 }
188
189
190
191
192
193 public void setItemPrice( double dItemPrice )
194 {
195 _dItemPrice = dItemPrice;
196 }
197
198
199
200
201
202 public Date getDateCreation( )
203 {
204 return _dateCreation == null ? null : (Date) _dateCreation.clone( );
205 }
206
207
208
209
210
211 public void setDateCreation( Date dateCreation )
212 {
213 this._dateCreation = dateCreation == null ? null : (Date) dateCreation.clone( );
214 }
215
216
217
218
219 @Override
220 public boolean equals( Object o )
221 {
222 if ( o instanceof ShoppingCartItem )
223 {
224 ShoppingCartItem other = (ShoppingCartItem) o;
225 return getIdItem( ) == other.getIdItem( )
226 && StringUtils.equals( getIdProvider( ), other.getIdProvider( ) )
227 && getIdLot( ) == other.getIdLot( )
228 && StringUtils.equals( getIdUser( ), other.getIdUser( ) )
229 && StringUtils.equals( getResourceType( ), other.getResourceType( ) )
230 && StringUtils.equals( getIdResource( ), other.getIdResource( ) )
231 && getItemPrice( ) == other.getItemPrice( )
232 && ( ( getDateCreation( ) == null && other.getDateCreation( ) == null ) || ( getDateCreation( ) != null
233 && other.getDateCreation( ) != null && DateUtils.isSameDay( getDateCreation( ),
234 other.getDateCreation( ) ) ) );
235 }
236 return false;
237 }
238
239
240
241
242 @Override
243 public int hashCode( )
244 {
245 int nHash = _nIdItem;
246 nHash = 30 * nHash + ( _strIdProvider == null ? 0 : _strIdProvider.hashCode( ) );
247 nHash = 30 * nHash + _nIdLot;
248 nHash = 30 * nHash + ( _strIdUser == null ? 0 : _strIdUser.hashCode( ) );
249 nHash = 30 * nHash + ( _strResourceType == null ? 0 : _strResourceType.hashCode( ) );
250 nHash = 30 * nHash + ( _strIdResource == null ? 0 : _strIdResource.hashCode( ) );
251 nHash = 30 * nHash + ( _dItemPrice > 0d ? Double.valueOf( _dItemPrice ).hashCode( ) : 0 );
252 nHash = 30 * nHash + ( _dateCreation == null ? 0 : _dateCreation.hashCode( ) );
253 return nHash;
254 }
255 }