Skip to content

Commit bb7d64c

Browse files
committed
Improve javadocs for ObjectNode#putPOJO
1 parent 849a9a8 commit bb7d64c

File tree

2 files changed

+28
-13
lines changed

2 files changed

+28
-13
lines changed

src/main/java/com/fasterxml/jackson/databind/ObjectMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1061,7 +1061,7 @@ public ObjectMapper registerModules(Iterable<? extends Module> modules)
10611061
* The set of {@link Module} typeIds that are registered in this
10621062
* ObjectMapper, if (and only if!)
10631063
* {@link MapperFeature#IGNORE_DUPLICATE_MODULE_REGISTRATIONS}
1064-
* is enabled AND module being added returns non-{@null} value
1064+
* is enabled AND module being added returns non-{@code null} value
10651065
* for its {@link Module#getTypeId()}.
10661066
*<p>
10671067
* NOTE: when using the default {@link com.fasterxml.jackson.databind.module.SimpleModule}

src/main/java/com/fasterxml/jackson/databind/node/ObjectNode.java

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ public ObjectNode retain(String... fieldNames) {
653653

654654
/**
655655
* Method that will construct an ArrayNode and add it as a
656-
* field of this ObjectNode, replacing old value, if any.
656+
* property of this {@code ObjectNode}, replacing old value, if any.
657657
*<p>
658658
* <b>NOTE</b>: Unlike all <b>put(...)</b> methods, return value
659659
* is <b>NOT</b> this <code>ObjectNode</code>, but the
@@ -662,16 +662,16 @@ public ObjectNode retain(String... fieldNames) {
662662
* @return Newly constructed ArrayNode (NOT the old value,
663663
* which could be of any type)
664664
*/
665-
public ArrayNode putArray(String fieldName)
665+
public ArrayNode putArray(String propertyName)
666666
{
667667
ArrayNode n = arrayNode();
668-
_put(fieldName, n);
668+
_put(propertyName, n);
669669
return n;
670670
}
671671

672672
/**
673673
* Method that will construct an ObjectNode and add it as a
674-
* field of this ObjectNode, replacing old value, if any.
674+
* property of this {@code ObjectNode}, replacing old value, if any.
675675
*<p>
676676
* <b>NOTE</b>: Unlike all <b>put(...)</b> methods, return value
677677
* is <b>NOT</b> this <code>ObjectNode</code>, but the
@@ -680,29 +680,44 @@ public ArrayNode putArray(String fieldName)
680680
* @return Newly constructed ObjectNode (NOT the old value,
681681
* which could be of any type)
682682
*/
683-
public ObjectNode putObject(String fieldName)
683+
public ObjectNode putObject(String propertyName)
684684
{
685685
ObjectNode n = objectNode();
686-
_put(fieldName, n);
686+
_put(propertyName, n);
687687
return n;
688688
}
689689

690690
/**
691-
* @return This node (to allow chaining)
691+
* Method for adding an opaque Java value as the value of specified property.
692+
* Value can be serialized like any other property, as long as Jackson can
693+
* serialize it. Despite term "POJO" this allows use of about any Java type, including
694+
* {@link java.util.Map}s, {@link java.util.Collection}s, as well as Beans (POJOs),
695+
* primitives/wrappers and even {@link JsonNode}s.
696+
* Method is most commonly useful when composing content to serialize from heterogenous
697+
* sources.
698+
*<p>
699+
* NOTE: if using {@link JsonNode#toString()} (or {@link JsonNode#toPrettyString()}
700+
* support for serialization may be more limited, compared to serializing node
701+
* with specifically configured {@link ObjectMapper}.
702+
*
703+
* @param propertyName Name of property to set.
704+
* @param pojo Java value to set as the property value
705+
*
706+
* @return This {@code ObjectNode} (to allow chaining)
692707
*/
693-
public ObjectNode putPOJO(String fieldName, Object pojo) {
694-
return _put(fieldName, pojoNode(pojo));
708+
public ObjectNode putPOJO(String propertyName, Object pojo) {
709+
return _put(propertyName, pojoNode(pojo));
695710
}
696711

697712
/**
698713
* @since 2.6
699714
*/
700-
public ObjectNode putRawValue(String fieldName, RawValue raw) {
701-
return _put(fieldName, rawValueNode(raw));
715+
public ObjectNode putRawValue(String propertyName, RawValue raw) {
716+
return _put(propertyName, rawValueNode(raw));
702717
}
703718

704719
/**
705-
* @return This node (to allow chaining)
720+
* @return This {@code ObjectNode} (to allow chaining)
706721
*/
707722
public ObjectNode putNull(String fieldName)
708723
{

0 commit comments

Comments
 (0)