@@ -146,7 +146,7 @@ public WriteConcern( int w , int wtimeout , boolean fsync ){
146
146
* @param j whether writes should wait for a journaling group commit
147
147
*/
148
148
public WriteConcern ( int w , int wtimeout , boolean fsync , boolean j ){
149
- _wValue = w ;
149
+ _w = w ;
150
150
_wtimeout = wtimeout ;
151
151
_fsync = fsync ;
152
152
_j = j ;
@@ -169,7 +169,7 @@ public WriteConcern( int w , int wtimeout , boolean fsync , boolean j ){
169
169
* @param j whether writes should wait for a journaling group commit
170
170
*/
171
171
public WriteConcern ( String w , int wtimeout , boolean fsync , boolean j ){
172
- _wValue = w ;
172
+ _w = w ;
173
173
_wtimeout = wtimeout ;
174
174
_fsync = fsync ;
175
175
_j = j ;
@@ -182,9 +182,9 @@ public WriteConcern( String w , int wtimeout , boolean fsync, boolean j ){
182
182
public BasicDBObject getCommand (){
183
183
BasicDBObject _command = new BasicDBObject ( "getlasterror" , 1 );
184
184
185
- if ( _wValue instanceof Integer && ( (Integer ) _wValue > 0 ) ||
186
- ( _wValue instanceof String && _wValue != null ) ){
187
- _command .put ( "w" , _wValue );
185
+ if ( _w instanceof Integer && ( (Integer ) _w > 0 ) ||
186
+ ( _w instanceof String && _w != null ) ){
187
+ _command .put ( "w" , _w );
188
188
_command .put ( "wtimeout" , _wtimeout );
189
189
}
190
190
@@ -201,40 +201,42 @@ public BasicDBObject getCommand(){
201
201
* Sets the w value (the write strategy)
202
202
* @param wValue
203
203
*/
204
- public void setWObject (Object wValue ) {
205
- this ._wValue = wValue ;
204
+ public void setWObject (Object w ) {
205
+ if ( ! (w instanceof Integer ) && ! (w instanceof String ) )
206
+ throw new IllegalArgumentException ("The w parameter must be an int or a String" );
207
+ this ._w = w ;
206
208
}
207
209
208
210
/**
209
211
* Gets the w value (the write strategy)
210
212
* @return
211
213
*/
212
214
public Object getWObject (){
213
- return _wValue ;
215
+ return _w ;
214
216
}
215
217
216
218
/**
217
219
* Sets the w value (the write strategy)
218
220
* @param w
219
221
*/
220
222
public void setW (int w ) {
221
- _wValue = w ;
223
+ _w = w ;
222
224
}
223
225
224
226
/**
225
227
* Gets the w parameter (the write strategy)
226
228
* @return
227
229
*/
228
230
public int getW (){
229
- return (Integer ) _wValue ;
231
+ return (Integer ) _w ;
230
232
}
231
233
232
234
/**
233
235
* Gets the w parameter (the write strategy) in String format
234
236
* @return
235
237
*/
236
238
public String getWString (){
237
- return _wValue .toString ();
239
+ return _w .toString ();
238
240
}
239
241
240
242
/**
@@ -282,19 +284,19 @@ public boolean fsync(){
282
284
* @return
283
285
*/
284
286
public boolean raiseNetworkErrors (){
285
- if (_wValue instanceof Integer )
286
- return (Integer ) _wValue >= 0 ;
287
- return _wValue != null ;
287
+ if (_w instanceof Integer )
288
+ return (Integer ) _w >= 0 ;
289
+ return _w != null ;
288
290
}
289
291
290
292
/**
291
293
* Returns whether "getlasterror" should be called (w > 0)
292
294
* @return
293
295
*/
294
296
public boolean callGetLastError (){
295
- if (_wValue instanceof Integer )
296
- return (Integer ) _wValue > 0 ;
297
- return _wValue != null ;
297
+ if (_w instanceof Integer )
298
+ return (Integer ) _w > 0 ;
299
+ return _w != null ;
298
300
}
299
301
300
302
/**
@@ -334,7 +336,7 @@ public boolean equals( Object o ){
334
336
if ( o == null || getClass () != o .getClass () ) return false ;
335
337
336
338
WriteConcern that = (WriteConcern ) o ;
337
- return _fsync == that ._fsync && _wValue == that ._wValue && _wtimeout == that ._wtimeout && _j == that ._j && _continueOnErrorForInsert == that ._continueOnErrorForInsert ;
339
+ return _fsync == that ._fsync && _w == that ._w && _wtimeout == that ._wtimeout && _j == that ._j && _continueOnErrorForInsert == that ._continueOnErrorForInsert ;
338
340
}
339
341
340
342
/**
@@ -384,7 +386,7 @@ public static Majority majorityWriteConcern( int wtimeout, boolean fsync, boolea
384
386
}
385
387
386
388
387
- Object _wValue = 0 ;
389
+ Object _w = 0 ;
388
390
int _wtimeout = 0 ;
389
391
boolean _fsync = false ;
390
392
boolean _j = false ;
0 commit comments