Skip to content

Commit faa2484

Browse files
committed
Further improvements to ObjectNode javadocs
1 parent bb7d64c commit faa2484

File tree

1 file changed

+61
-57
lines changed

1 file changed

+61
-57
lines changed

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

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,8 @@ public Iterator<JsonNode> elements() {
105105
public JsonNode get(int index) { return null; }
106106

107107
@Override
108-
public JsonNode get(String fieldName) {
109-
return _children.get(fieldName);
108+
public JsonNode get(String propertyName) {
109+
return _children.get(propertyName);
110110
}
111111

112112
@Override
@@ -120,26 +120,26 @@ public JsonNode path(int index) {
120120
}
121121

122122
@Override
123-
public JsonNode path(String fieldName)
123+
public JsonNode path(String propertyName)
124124
{
125-
JsonNode n = _children.get(fieldName);
125+
JsonNode n = _children.get(propertyName);
126126
if (n != null) {
127127
return n;
128128
}
129129
return MissingNode.getInstance();
130130
}
131131

132132
@Override
133-
public JsonNode required(String fieldName) {
134-
JsonNode n = _children.get(fieldName);
133+
public JsonNode required(String propertyName) {
134+
JsonNode n = _children.get(propertyName);
135135
if (n != null) {
136136
return n;
137137
}
138-
return _reportRequiredViolation("No value for property '%s' of `ObjectNode`", fieldName);
138+
return _reportRequiredViolation("No value for property '%s' of `ObjectNode`", propertyName);
139139
}
140140

141141
/**
142-
* Method to use for accessing all fields (with both names
142+
* Method to use for accessing all properties (with both names
143143
* and values) of this JSON Object.
144144
*/
145145
@Override
@@ -213,13 +213,13 @@ public boolean equals(Comparator<JsonNode> comparator, JsonNode o)
213213
*/
214214

215215
@Override
216-
public JsonNode findValue(String fieldName)
216+
public JsonNode findValue(String propertyName)
217217
{
218218
for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
219-
if (fieldName.equals(entry.getKey())) {
219+
if (propertyName.equals(entry.getKey())) {
220220
return entry.getValue();
221221
}
222-
JsonNode value = entry.getValue().findValue(fieldName);
222+
JsonNode value = entry.getValue().findValue(propertyName);
223223
if (value != null) {
224224
return value;
225225
}
@@ -228,46 +228,46 @@ public JsonNode findValue(String fieldName)
228228
}
229229

230230
@Override
231-
public List<JsonNode> findValues(String fieldName, List<JsonNode> foundSoFar)
231+
public List<JsonNode> findValues(String propertyName, List<JsonNode> foundSoFar)
232232
{
233233
for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
234-
if (fieldName.equals(entry.getKey())) {
234+
if (propertyName.equals(entry.getKey())) {
235235
if (foundSoFar == null) {
236236
foundSoFar = new ArrayList<JsonNode>();
237237
}
238238
foundSoFar.add(entry.getValue());
239239
} else { // only add children if parent not added
240-
foundSoFar = entry.getValue().findValues(fieldName, foundSoFar);
240+
foundSoFar = entry.getValue().findValues(propertyName, foundSoFar);
241241
}
242242
}
243243
return foundSoFar;
244244
}
245245

246246
@Override
247-
public List<String> findValuesAsText(String fieldName, List<String> foundSoFar)
247+
public List<String> findValuesAsText(String propertyName, List<String> foundSoFar)
248248
{
249249
for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
250-
if (fieldName.equals(entry.getKey())) {
250+
if (propertyName.equals(entry.getKey())) {
251251
if (foundSoFar == null) {
252252
foundSoFar = new ArrayList<String>();
253253
}
254254
foundSoFar.add(entry.getValue().asText());
255255
} else { // only add children if parent not added
256-
foundSoFar = entry.getValue().findValuesAsText(fieldName,
256+
foundSoFar = entry.getValue().findValuesAsText(propertyName,
257257
foundSoFar);
258258
}
259259
}
260260
return foundSoFar;
261261
}
262262

263263
@Override
264-
public ObjectNode findParent(String fieldName)
264+
public ObjectNode findParent(String propertyName)
265265
{
266266
for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
267-
if (fieldName.equals(entry.getKey())) {
267+
if (propertyName.equals(entry.getKey())) {
268268
return this;
269269
}
270-
JsonNode value = entry.getValue().findParent(fieldName);
270+
JsonNode value = entry.getValue().findParent(propertyName);
271271
if (value != null) {
272272
return (ObjectNode) value;
273273
}
@@ -276,22 +276,22 @@ public ObjectNode findParent(String fieldName)
276276
}
277277

278278
@Override
279-
public List<JsonNode> findParents(String fieldName, List<JsonNode> foundSoFar)
279+
public List<JsonNode> findParents(String propertyName, List<JsonNode> foundSoFar)
280280
{
281281
for (Map.Entry<String, JsonNode> entry : _children.entrySet()) {
282-
if (fieldName.equals(entry.getKey())) {
282+
if (propertyName.equals(entry.getKey())) {
283283
if (foundSoFar == null) {
284284
foundSoFar = new ArrayList<JsonNode>();
285285
}
286286
foundSoFar.add(this);
287287
} else { // only add children if parent not added
288288
foundSoFar = entry.getValue()
289-
.findParents(fieldName, foundSoFar);
289+
.findParents(propertyName, foundSoFar);
290290
}
291291
}
292292
return foundSoFar;
293293
}
294-
294+
295295
/*
296296
/**********************************************************
297297
/* Public API, serialization
@@ -364,7 +364,7 @@ public void serializeWithType(JsonGenerator g, SerializerProvider provider,
364364
*/
365365

366366
/**
367-
* Method that will set specified field, replacing old value, if any.
367+
* Method that will set specified property, replacing old value, if any.
368368
* Note that this is identical to {@link #replace(String, JsonNode)},
369369
* except for return value.
370370
*<p>
@@ -440,36 +440,36 @@ public <T extends JsonNode> T setAll(ObjectNode other)
440440
* Method for replacing value of specific property with passed
441441
* value, and returning value (or null if none).
442442
*
443-
* @param fieldName Property of which value to replace
443+
* @param propertyName Property of which value to replace
444444
* @param value Value to set property to, replacing old value if any
445445
*
446446
* @return Old value of the property; null if there was no such property
447447
* with value
448448
*
449449
* @since 2.1
450450
*/
451-
public JsonNode replace(String fieldName, JsonNode value)
451+
public JsonNode replace(String propertyName, JsonNode value)
452452
{
453453
if (value == null) { // let's not store 'raw' nulls but nodes
454454
value = nullNode();
455455
}
456-
return _children.put(fieldName, value);
456+
return _children.put(propertyName, value);
457457
}
458458

459459
/**
460-
* Method for removing field entry from this ObjectNode, and
460+
* Method for removing property from this ObjectNode, and
461461
* returning instance after removal.
462462
*<p>
463463
* NOTE: co-variant return type since 2.10
464464
*
465-
* @return This node after removing entry (if any)
465+
* @return This node after removing property (if any)
466466
*
467467
* @since 2.1
468468
*/
469469
@SuppressWarnings("unchecked")
470-
public <T extends JsonNode> T without(String fieldName)
470+
public <T extends JsonNode> T without(String propertyName)
471471
{
472-
_children.remove(fieldName);
472+
_children.remove(propertyName);
473473
return (T) this;
474474
}
475475

@@ -479,16 +479,16 @@ public <T extends JsonNode> T without(String fieldName)
479479
*<p>
480480
* NOTE: co-variant return type since 2.10
481481
*
482-
* @param fieldNames Names of fields to remove
482+
* @param propertyNames Names of properties to remove
483483
*
484484
* @return This node after removing entries
485485
*
486486
* @since 2.1
487487
*/
488488
@SuppressWarnings("unchecked")
489-
public <T extends JsonNode> T without(Collection<String> fieldNames)
489+
public <T extends JsonNode> T without(Collection<String> propertyNames)
490490
{
491-
_children.keySet().removeAll(fieldNames);
491+
_children.keySet().removeAll(propertyNames);
492492
return (T) this;
493493
}
494494

@@ -538,7 +538,7 @@ public JsonNode put(String propertyName, JsonNode value)
538538
* @param value Value to set to property (if and only if it had no value previously);
539539
* if null, will be converted to a {@link NullNode} first.
540540
*
541-
* @return Old value of the field, if any (in which case value was not changed);
541+
* @return Old value of the property, if any (in which case value was not changed);
542542
* null if there was no old value (in which case value is now set)
543543
*
544544
* @since 2.13
@@ -556,28 +556,28 @@ public JsonNode putIfAbsent(String propertyName, JsonNode value)
556556
* Will return previous value of the property, if such property existed;
557557
* null if not.
558558
*
559-
* @return Value of specified field, if it existed; null if not
559+
* @return Value of specified property, if it existed; null if not
560560
*/
561-
public JsonNode remove(String fieldName) {
562-
return _children.remove(fieldName);
561+
public JsonNode remove(String propertyName) {
562+
return _children.remove(propertyName);
563563
}
564564

565565
/**
566566
* Method for removing specified field properties out of
567567
* this ObjectNode.
568568
*
569-
* @param fieldNames Names of fields to remove
569+
* @param propertyNames Names of fields to remove
570570
*
571571
* @return This node after removing entries
572572
*/
573-
public ObjectNode remove(Collection<String> fieldNames)
573+
public ObjectNode remove(Collection<String> propertyNames)
574574
{
575-
_children.keySet().removeAll(fieldNames);
575+
_children.keySet().removeAll(propertyNames);
576576
return this;
577577
}
578578

579579
/**
580-
* Method for removing all field properties, such that this
580+
* Method for removing all properties, such that this
581581
* ObjectNode will contain no properties after call.
582582
*
583583
* @return This node after removing all entries
@@ -620,31 +620,31 @@ public JsonNode putAll(ObjectNode other) {
620620
}
621621

622622
/**
623-
* Method for removing all field properties out of this ObjectNode
623+
* Method for removing all properties out of this ObjectNode
624624
* <b>except</b> for ones specified in argument.
625625
*
626-
* @param fieldNames Fields to <b>retain</b> in this ObjectNode
626+
* @param propertyNames Fields to <b>retain</b> in this ObjectNode
627627
*
628628
* @return This node (to allow call chaining)
629629
*/
630-
public ObjectNode retain(Collection<String> fieldNames)
630+
public ObjectNode retain(Collection<String> propertyNames)
631631
{
632-
_children.keySet().retainAll(fieldNames);
632+
_children.keySet().retainAll(propertyNames);
633633
return this;
634634
}
635635

636636
/**
637-
* Method for removing all field properties out of this ObjectNode
637+
* Method for removing all properties out of this ObjectNode
638638
* <b>except</b> for ones specified in argument.
639639
*
640-
* @param fieldNames Fields to <b>retain</b> in this ObjectNode
640+
* @param propertyNames Fields to <b>retain</b> in this ObjectNode
641641
*
642642
* @return This node (to allow call chaining)
643643
*/
644-
public ObjectNode retain(String... fieldNames) {
645-
return retain(Arrays.asList(fieldNames));
644+
public ObjectNode retain(String... propertyNames) {
645+
return retain(Arrays.asList(propertyNames));
646646
}
647-
647+
648648
/*
649649
/**********************************************************
650650
/* Extended ObjectNode API, mutators, typed
@@ -717,21 +717,25 @@ public ObjectNode putRawValue(String propertyName, RawValue raw) {
717717
}
718718

719719
/**
720+
* Method for setting value of a property to explicit {@code null} value.
721+
*
722+
* @param propertyName Name of property to set.
723+
*
720724
* @return This {@code ObjectNode} (to allow chaining)
721725
*/
722-
public ObjectNode putNull(String fieldName)
726+
public ObjectNode putNull(String propertyName)
723727
{
724-
_children.put(fieldName, nullNode());
728+
_children.put(propertyName, nullNode());
725729
return this;
726730
}
727731

728732
/**
729-
* Method for setting value of a field to specified numeric value.
733+
* Method for setting value of a property to specified numeric value.
730734
*
731735
* @return This node (to allow chaining)
732736
*/
733-
public ObjectNode put(String fieldName, short v) {
734-
return _put(fieldName, numberNode(v));
737+
public ObjectNode put(String propertyName, short v) {
738+
return _put(propertyName, numberNode(v));
735739
}
736740

737741
/**

0 commit comments

Comments
 (0)