@@ -142,7 +142,7 @@ default JsonWriter<T> withSuffix(String suffix) {
142
142
* @return a {@link JsonWriter} instance
143
143
*/
144
144
static <T > JsonWriter <T > standard () {
145
- return of (Members ::addSelf );
145
+ return of (Members ::add );
146
146
}
147
147
148
148
/**
@@ -306,8 +306,8 @@ public String toString() {
306
306
* the various {@code add(...)} methods. Typically, members are declared with a
307
307
* {@code "name"} and a {@link Function} that will extract the value from the
308
308
* instance. Members can also be declared using a static value or a {@link Supplier}.
309
- * The {@link #addSelf (String)} and {@link #addSelf ()} methods may be used to access
310
- * the actual instance being written.
309
+ * The {@link #add (String)} and {@link #add ()} methods may be used to access the
310
+ * actual instance being written.
311
311
* <p>
312
312
* Members can be added without a {@code name} when a {@code Member.using(...)} method
313
313
* is used to complete the definition.
@@ -343,7 +343,7 @@ final class Members<T> {
343
343
* @param name the member name
344
344
* @return the added {@link Member} which may be configured further
345
345
*/
346
- public Member <T > addSelf (String name ) {
346
+ public Member <T > add (String name ) {
347
347
return add (name , (instance ) -> instance );
348
348
}
349
349
@@ -389,58 +389,55 @@ public <V> Member<V> add(String name, Function<T, V> extractor) {
389
389
* complete the configuration.
390
390
* @return the added {@link Member} which may be configured further
391
391
*/
392
- public Member <T > addSelf () {
393
- return add (( instance ) -> instance );
392
+ public Member <T > add () {
393
+ return from ( Function . identity () );
394
394
}
395
395
396
396
/**
397
- * Add a new member with a static value. The member is added without a name, so
398
- * one of the {@code Member.using(...)} methods must be used to complete the
399
- * configuration.
397
+ * Add all entries from the given {@link Map} to the JSON.
398
+ * @param <M> the map type
399
+ * @param <K> the key type
400
400
* @param <V> the value type
401
- * @param value the member value
401
+ * @param extractor a function to extract the map
402
402
* @return the added {@link Member} which may be configured further
403
403
*/
404
- public <V > Member <V > add ( V value ) {
405
- return add (( instance ) -> value );
404
+ public <M extends Map < K , V >, K , V > Member <M > addMapEntries ( Function < T , M > extractor ) {
405
+ return from ( extractor ). usingPairs ( Map :: forEach );
406
406
}
407
407
408
408
/**
409
- * Add a new member with a supplied value.The member is added without a name, so
410
- * one of the {@code Member.using(...)} methods must be used to complete the
411
- * configuration.
409
+ * Add members from a static value. One of the {@code Member.using(...)} methods
410
+ * must be used to complete the configuration.
412
411
* @param <V> the value type
413
- * @param supplier a supplier of the value
412
+ * @param value the member value
414
413
* @return the added {@link Member} which may be configured further
415
414
*/
416
- public <V > Member <V > add (Supplier <V > supplier ) {
417
- Assert .notNull (supplier , "'supplier' must not be null" );
418
- return add ((instance ) -> supplier .get ());
415
+ public <V > Member <V > from (V value ) {
416
+ return from ((instance ) -> value );
419
417
}
420
418
421
419
/**
422
- * Add a new member with an extracted value. The member is added without a name,
423
- * so one of the {@code Member.using(...)} methods must be used to complete the
424
- * configuration.
420
+ * Add members from a supplied value. One of the {@code Member.using(...)} methods
421
+ * must be used to complete the configuration.
425
422
* @param <V> the value type
426
- * @param extractor a function to extract the value
423
+ * @param supplier a supplier of the value
427
424
* @return the added {@link Member} which may be configured further
428
425
*/
429
- public <V > Member <V > add ( Function < T , V > extractor ) {
430
- Assert .notNull (extractor , "'extractor ' must not be null" );
431
- return addMember ( null , extractor );
426
+ public <V > Member <V > from ( Supplier < V > supplier ) {
427
+ Assert .notNull (supplier , "'supplier ' must not be null" );
428
+ return from (( instance ) -> supplier . get () );
432
429
}
433
430
434
431
/**
435
- * Add all entries from the given {@link Map} to the JSON.
436
- * @param <M> the map type
437
- * @param <K> the key type
432
+ * Add members from an extracted value. One of the {@code Member.using(...)}
433
+ * methods must be used to complete the configuration.
438
434
* @param <V> the value type
439
- * @param extractor a function to extract the map
435
+ * @param extractor a function to extract the value
440
436
* @return the added {@link Member} which may be configured further
441
437
*/
442
- public <M extends Map <K , V >, K , V > Member <M > addMapEntries (Function <T , M > extractor ) {
443
- return add (extractor ).usingPairs (Map ::forEach );
438
+ public <V > Member <V > from (Function <T , V > extractor ) {
439
+ Assert .notNull (extractor , "'extractor' must not be null" );
440
+ return addMember (null , extractor );
444
441
}
445
442
446
443
private <V > Member <V > addMember (String name , Function <T , V > extractor ) {
0 commit comments