@@ -142,7 +142,7 @@ default JsonWriter<T> withSuffix(String suffix) {
142142 * @return a {@link JsonWriter} instance
143143 */
144144 static <T > JsonWriter <T > standard () {
145- return of (Members ::addSelf );
145+ return of (Members ::add );
146146 }
147147
148148 /**
@@ -306,8 +306,8 @@ public String toString() {
306306 * the various {@code add(...)} methods. Typically, members are declared with a
307307 * {@code "name"} and a {@link Function} that will extract the value from the
308308 * 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.
311311 * <p>
312312 * Members can be added without a {@code name} when a {@code Member.using(...)} method
313313 * is used to complete the definition.
@@ -343,7 +343,7 @@ final class Members<T> {
343343 * @param name the member name
344344 * @return the added {@link Member} which may be configured further
345345 */
346- public Member <T > addSelf (String name ) {
346+ public Member <T > add (String name ) {
347347 return add (name , (instance ) -> instance );
348348 }
349349
@@ -389,58 +389,55 @@ public <V> Member<V> add(String name, Function<T, V> extractor) {
389389 * complete the configuration.
390390 * @return the added {@link Member} which may be configured further
391391 */
392- public Member <T > addSelf () {
393- return add (( instance ) -> instance );
392+ public Member <T > add () {
393+ return from ( Function . identity () );
394394 }
395395
396396 /**
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
400400 * @param <V> the value type
401- * @param value the member value
401+ * @param extractor a function to extract the map
402402 * @return the added {@link Member} which may be configured further
403403 */
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 );
406406 }
407407
408408 /**
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.
412411 * @param <V> the value type
413- * @param supplier a supplier of the value
412+ * @param value the member value
414413 * @return the added {@link Member} which may be configured further
415414 */
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 );
419417 }
420418
421419 /**
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.
425422 * @param <V> the value type
426- * @param extractor a function to extract the value
423+ * @param supplier a supplier of the value
427424 * @return the added {@link Member} which may be configured further
428425 */
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 () );
432429 }
433430
434431 /**
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.
438434 * @param <V> the value type
439- * @param extractor a function to extract the map
435+ * @param extractor a function to extract the value
440436 * @return the added {@link Member} which may be configured further
441437 */
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 );
444441 }
445442
446443 private <V > Member <V > addMember (String name , Function <T , V > extractor ) {
0 commit comments