@@ -87,8 +87,7 @@ public ObjectNode with(String exprOrProperty) {
87
87
.getClass ().getName () + "`)" );
88
88
}
89
89
ObjectNode result = objectNode ();
90
- _children .put (exprOrProperty , result );
91
- return result ;
90
+ return _put (exprOrProperty , result );
92
91
}
93
92
94
93
@ Override
@@ -132,7 +131,7 @@ public ArrayNode withArray(String exprOrProperty)
132
131
.getClass ().getName () + "`)" );
133
132
}
134
133
ArrayNode result = arrayNode ();
135
- _children . put (exprOrProperty , result );
134
+ _put (exprOrProperty , result );
136
135
return result ;
137
136
}
138
137
@@ -625,6 +624,9 @@ public <T extends JsonNode> T set(String propertyName, JsonNode value)
625
624
* Method for adding given properties to this object node, overriding
626
625
* any existing values for those properties.
627
626
*<p>
627
+ * NOTE: {@code null} keys are not allowed; ({@code null} values get
628
+ * converted to a {@link NullNode}).
629
+ *<p>
628
630
* NOTE: co-variant return type since 2.10
629
631
*
630
632
* @param properties Properties to add
@@ -641,7 +643,7 @@ public <T extends JsonNode> T setAll(Map<String,? extends JsonNode> properties)
641
643
if (n == null ) {
642
644
n = nullNode ();
643
645
}
644
- _children . put (en .getKey (), n );
646
+ _put (en .getKey (), n );
645
647
}
646
648
return (T ) this ;
647
649
}
@@ -669,7 +671,7 @@ public <T extends JsonNode> T setAll(ObjectNode other)
669
671
* Method for replacing value of specific property with passed
670
672
* value, and returning value (or null if none).
671
673
*
672
- * @param propertyName Property of which value to replace
674
+ * @param propertyName Property of which value to replace: must not be {@code null}
673
675
* @param value Value to set property to, replacing old value if any
674
676
*
675
677
* @return Old value of the property; null if there was no such property
@@ -682,7 +684,7 @@ public JsonNode replace(String propertyName, JsonNode value)
682
684
if (value == null ) { // let's not store 'raw' nulls but nodes
683
685
value = nullNode ();
684
686
}
685
- return _children .put (propertyName , value );
687
+ return _children .put (Objects . requireNonNull ( propertyName ) , value );
686
688
}
687
689
688
690
/**
@@ -730,7 +732,7 @@ public <T extends JsonNode> T without(Collection<String> propertyNames)
730
732
/**
731
733
* Method that will set specified property, replacing old value, if any.
732
734
*
733
- * @param propertyName Name of property to set
735
+ * @param propertyName Name of property to set (must not be {@code null})
734
736
* @param value Value to set to property; if null, will be converted
735
737
* to a {@link NullNode} first (to remove a property, call
736
738
* {@link #remove} instead).
@@ -746,7 +748,7 @@ public JsonNode put(String propertyName, JsonNode value)
746
748
if (value == null ) { // let's not store 'raw' nulls but nodes
747
749
value = nullNode ();
748
750
}
749
- return _children .put (propertyName , value );
751
+ return _children .put (Objects . requireNonNull ( propertyName ) , value );
750
752
}
751
753
752
754
/**
@@ -763,7 +765,7 @@ public JsonNode put(String propertyName, JsonNode value)
763
765
* }
764
766
*</code>
765
767
*
766
- * @param propertyName Name of property to set
768
+ * @param propertyName Name of property to set (must not be {@code null})
767
769
* @param value Value to set to property (if and only if it had no value previously);
768
770
* if null, will be converted to a {@link NullNode} first.
769
771
*
@@ -777,7 +779,7 @@ public JsonNode putIfAbsent(String propertyName, JsonNode value)
777
779
if (value == null ) { // let's not store 'raw' nulls but nodes
778
780
value = nullNode ();
779
781
}
780
- return _children .putIfAbsent (propertyName , value );
782
+ return _children .putIfAbsent (Objects . requireNonNull ( propertyName ) , value );
781
783
}
782
784
783
785
/**
@@ -1176,9 +1178,10 @@ public int hashCode()
1176
1178
/**********************************************************
1177
1179
*/
1178
1180
1181
+ // @since 2.19
1179
1182
protected ObjectNode _put (String propertyName , JsonNode value )
1180
1183
{
1181
- _children .put (propertyName , value );
1184
+ _children .put (Objects . requireNonNull ( propertyName ) , value );
1182
1185
return this ;
1183
1186
}
1184
1187
}
0 commit comments