18
18
import java .util .Arrays ;
19
19
import java .util .Collection ;
20
20
import java .util .Collections ;
21
- import java .util .Set ;
22
21
23
22
import org .bson .Document ;
24
- import org .springframework .data .mongodb .core .aggregation .Aggregation .SystemVariable ;
25
23
import org .springframework .util .Assert ;
26
24
27
25
/**
@@ -135,7 +133,7 @@ public ObjectToArray toArray() {
135
133
* @since 4.0
136
134
*/
137
135
public GetField getField (String fieldName ) {
138
- return GetField .getField (fieldName ).from (value );
136
+ return GetField .getField (fieldName ).of (value );
139
137
}
140
138
141
139
/**
@@ -145,7 +143,7 @@ public GetField getField(String fieldName) {
145
143
* @since 4.0
146
144
*/
147
145
public SetField setField (String fieldName ) {
148
- return SetField .setField (fieldName ).of (value );
146
+ return SetField .field (fieldName ).input (value );
149
147
}
150
148
151
149
/**
@@ -155,7 +153,7 @@ public SetField setField(String fieldName) {
155
153
* @since 4.0
156
154
*/
157
155
public AggregationExpression removeField (String fieldName ) {
158
- return SetField .setField (fieldName ).of (value ).toValue (SystemVariable .REMOVE );
156
+ return SetField .field (fieldName ).input (value ).toValue (SystemVariable .REMOVE );
159
157
}
160
158
}
161
159
@@ -329,23 +327,49 @@ protected GetField(Object value) {
329
327
super (value );
330
328
}
331
329
330
+ /**
331
+ * Creates new {@link GetField aggregation expression} that takes the value pointed to by given {@code fieldName}.
332
+ *
333
+ * @param fieldName must not be {@literal null}.
334
+ * @return new instance of {@link GetField}.
335
+ */
332
336
public static GetField getField (String fieldName ) {
333
337
return new GetField (Collections .singletonMap ("field" , fieldName ));
334
338
}
335
339
340
+ /**
341
+ * Creates new {@link GetField aggregation expression} that takes the value pointed to by given {@link Field}.
342
+ *
343
+ * @param field must not be {@literal null}.
344
+ * @return new instance of {@link GetField}.
345
+ */
336
346
public static GetField getField (Field field ) {
337
347
return getField (field .getTarget ());
338
348
}
339
349
340
- public GetField from (String fieldRef ) {
341
- return from (Fields .field (fieldRef ));
350
+ /**
351
+ * Creates new {@link GetField aggregation expression} that takes the value pointed to by given
352
+ * {@code field reference}.
353
+ *
354
+ * @param fieldRef must not be {@literal null}.
355
+ * @return new instance of {@link GetField}.
356
+ */
357
+ public GetField of (String fieldRef ) {
358
+ return of (Fields .field (fieldRef ));
342
359
}
343
360
344
- public GetField from (AggregationExpression expression ) {
345
- return from ((Object ) expression );
361
+ /**
362
+ * Creates new {@link GetField aggregation expression} that takes the value pointed to by given
363
+ * {@link AggregationExpression}.
364
+ *
365
+ * @param expression must not be {@literal null}.
366
+ * @return new instance of {@link GetField}.
367
+ */
368
+ public GetField of (AggregationExpression expression ) {
369
+ return of ((Object ) expression );
346
370
}
347
371
348
- private GetField from (Object fieldRef ) {
372
+ private GetField of (Object fieldRef ) {
349
373
return new GetField (append ("input" , fieldRef ));
350
374
}
351
375
@@ -367,34 +391,87 @@ protected SetField(Object value) {
367
391
super (value );
368
392
}
369
393
370
- public static SetField setField (String fieldName ) {
394
+ /**
395
+ * Creates new {@link SetField aggregation expression} that takes the value pointed to by given input
396
+ * {@code fieldName}.
397
+ *
398
+ * @param fieldName must not be {@literal null}.
399
+ * @return new instance of {@link SetField}.
400
+ */
401
+ public static SetField field (String fieldName ) {
371
402
return new SetField (Collections .singletonMap ("field" , fieldName ));
372
403
}
373
404
374
- public static SetField setField (Field field ) {
375
- return setField (field .getTarget ());
405
+ /**
406
+ * Creates new {@link SetField aggregation expression} that takes the value pointed to by given input {@link Field}.
407
+ *
408
+ * @param field must not be {@literal null}.
409
+ * @return new instance of {@link SetField}.
410
+ */
411
+ public static SetField field (Field field ) {
412
+ return field (field .getTarget ());
376
413
}
377
414
378
- public SetField of (String fieldRef ) {
379
- return of (Fields .field (fieldRef ));
415
+ /**
416
+ * Creates new {@link GetField aggregation expression} that takes the value pointed to by given input
417
+ * {@code field reference}.
418
+ *
419
+ * @param fieldRef must not be {@literal null}.
420
+ * @return new instance of {@link GetField}.
421
+ */
422
+ public SetField input (String fieldRef ) {
423
+ return input (Fields .field (fieldRef ));
380
424
}
381
425
382
- public SetField of (AggregationExpression expression ) {
383
- return of ((Object ) expression );
426
+ /**
427
+ * Creates new {@link SetField aggregation expression} that takes the value pointed to by given input
428
+ * {@link AggregationExpression}.
429
+ *
430
+ * @param expression must not be {@literal null}.
431
+ * @return new instance of {@link SetField}.
432
+ */
433
+ public SetField input (AggregationExpression expression ) {
434
+ return input ((Object ) expression );
384
435
}
385
436
386
- private SetField of (Object fieldRef ) {
437
+ /**
438
+ * Creates new {@link SetField aggregation expression} that takes the value pointed to by given input
439
+ * {@code field reference}.
440
+ *
441
+ * @param fieldRef must not be {@literal null}.
442
+ * @return new instance of {@link SetField}.
443
+ */
444
+ private SetField input (Object fieldRef ) {
387
445
return new SetField (append ("input" , fieldRef ));
388
446
}
389
447
448
+ /**
449
+ * Creates new {@link SetField aggregation expression} providing the {@code value} using {@literal fieldReference}.
450
+ *
451
+ * @param fieldReference must not be {@literal null}.
452
+ * @return new instance of {@link SetField}.
453
+ */
390
454
public SetField toValueOf (String fieldReference ) {
391
455
return toValue (Fields .field (fieldReference ));
392
456
}
393
457
458
+ /**
459
+ * Creates new {@link SetField aggregation expression} providing the {@code value} using
460
+ * {@link AggregationExpression}.
461
+ *
462
+ * @param expression must not be {@literal null}.
463
+ * @return new instance of {@link SetField}.
464
+ */
394
465
public SetField toValueOf (AggregationExpression expression ) {
395
466
return toValue (expression );
396
467
}
397
468
469
+ /**
470
+ * Creates new {@link SetField aggregation expression} providing the {@code value}.
471
+ *
472
+ * @param value
473
+ * @return new instance of {@link SetField}.
474
+ */
398
475
public SetField toValue (Object value ) {
399
476
return new SetField (append ("value" , value ));
400
477
}
0 commit comments