File tree 4 files changed +24
-6
lines changed
src/main/java/com/fasterxml/jackson/databind
4 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,7 @@ Project: jackson-databind
40
40
`forEachEntry()`
41
41
#4867 : Add `Optional<JsonNode> JsonNode.asOptional()` convenience method
42
42
(fix by Joo-Hyuk K)
43
+ #4869 : Add `JsonNode.values()` to replace `elements()`
43
44
44
45
2.18.3 (not yet released)
45
46
Original file line number Diff line number Diff line change @@ -1066,16 +1066,23 @@ public boolean hasNonNull(int index) {
1066
1066
@ Override
1067
1067
public final Iterator <JsonNode > iterator () { return elements (); }
1068
1068
1069
+ /**
1070
+ * Alias for {@link #values()}.
1071
+ */
1072
+ public Iterator <JsonNode > elements () {
1073
+ return ClassUtil .emptyIterator ();
1074
+ }
1075
+
1069
1076
/**
1070
1077
* Method for accessing all value nodes of this Node, iff
1071
1078
* this node is a JSON Array or Object node. In case of Object node,
1072
1079
* field names (keys) are not included, only values.
1073
1080
* For other types of nodes, returns empty iterator.
1074
- * <p>
1075
- * Note: In Jackson 3, this method will be renamed to {@code values()}.
1081
+ *
1082
+ * @since 2.19
1076
1083
*/
1077
- public Iterator <JsonNode > elements () {
1078
- return ClassUtil . emptyIterator ();
1084
+ public Iterator <JsonNode > values () {
1085
+ return elements ();
1079
1086
}
1080
1087
1081
1088
/**
Original file line number Diff line number Diff line change @@ -246,15 +246,20 @@ public int size() {
246
246
@ Override // since 2.10
247
247
public boolean isEmpty () { return _children .isEmpty (); }
248
248
249
+ @ Override
250
+ public Iterator <JsonNode > elements () {
251
+ return _children .listIterator ();
252
+ }
253
+
249
254
/**
250
255
* {@inheritDoc}
251
256
*<p>
252
257
* NOTE: actual underlying implementation returns {@link java.util.ListIterator}
253
258
* from {@link java.util.List#listIterator()} that contains elements, since Jackson 2.18
254
259
* (before was only generic {@link java.util.Iterator}).
255
260
*/
256
- @ Override
257
- public Iterator <JsonNode > elements () {
261
+ @ Override // @since 2.19
262
+ public Iterator <JsonNode > values () {
258
263
return _children .listIterator ();
259
264
}
260
265
Original file line number Diff line number Diff line change @@ -275,6 +275,11 @@ public Iterator<JsonNode> elements() {
275
275
return _children .values ().iterator ();
276
276
}
277
277
278
+ @ Override // @since 2.19
279
+ public Iterator <JsonNode > values () {
280
+ return _children .values ().iterator ();
281
+ }
282
+
278
283
@ Override
279
284
public JsonNode get (int index ) { return null ; }
280
285
You can’t perform that action at this time.
0 commit comments