Skip to content

Commit 25f39ae

Browse files
authored
no need for spliterator methods when collections are public (#4882)
1 parent 1e0aa7c commit 25f39ae

File tree

5 files changed

+3
-47
lines changed

5 files changed

+3
-47
lines changed

release-notes/VERSION

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ Versions: 3.x (for earlier see VERSION-2.x)
8484
#4820: Change JDK baseline for Jackson 3.0 from Java 8 to Java 17
8585
#4835: Remove dynamic work-arounds wrt accessing `Record` definition
8686
#4840: Increase minimum Android SDK required to 34 for Jackson 3.0
87-
#4865: Add spliterator support in `JsonNode`
88-
(contributed by @pjfanning)
8987
#4875: Remove `JsonNode.fields()` from 3.0
9088
#4879: Rename `TextNode` as `StringNode`; `JsonNode.xxxTextYyy()` (mostly) as
9189
`JsonNode.xxxStringYyy()` [JSTEP-3]

src/main/java/tools/jackson/databind/JsonNode.java

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,18 +1050,14 @@ public boolean hasNonNull(int index) {
10501050
*/
10511051

10521052
/**
1053-
* Same as calling {@link #values()}; implemented so that
1054-
* convenience "for-each" loop can be used for looping over elements
1053+
* Implemented so that convenience "for-each" loop can be used for looping over elements
10551054
* of JSON Array constructs.
10561055
*/
10571056
@Override
10581057
public final Iterator<JsonNode> iterator() { return values().iterator(); }
10591058

1060-
/**
1061-
* Same as calling {@link #valueSpliterator()}.
1062-
*/
10631059
@Override
1064-
public final Spliterator<JsonNode> spliterator() { return valueSpliterator(); }
1060+
public final Spliterator<JsonNode> spliterator() { return values().spliterator(); }
10651061

10661062
/**
10671063
* Method for accessing all value nodes of this Node, iff
@@ -1073,18 +1069,6 @@ public Collection<JsonNode> values() {
10731069
return Collections.emptyList();
10741070
}
10751071

1076-
/**
1077-
* Method for accessing all value nodes of this Node, iff
1078-
* this node is a JSON Array or Object node. In case of Object node,
1079-
* field names (keys) are not included, only values.
1080-
* For other types of nodes, returns empty <code>Spliterator</code>.
1081-
*
1082-
* @since 3.0
1083-
*/
1084-
public Spliterator<JsonNode> valueSpliterator() {
1085-
return values().spliterator();
1086-
}
1087-
10881072
/**
10891073
* Accessor that will return properties of {@code ObjectNode}
10901074
* similar to how {@link Map#entrySet()} works;
@@ -1098,15 +1082,6 @@ public Set<Map.Entry<String, JsonNode>> properties() {
10981082
return Collections.emptySet();
10991083
}
11001084

1101-
/**
1102-
* @return {@code Spliterator} that can be used to traverse all key/value pairs
1103-
* for object nodes; empty spliterator (no contents) for other types
1104-
* @since 3.0
1105-
*/
1106-
public Spliterator<Map.Entry<String, JsonNode>> propertySpliterator() {
1107-
return properties().spliterator();
1108-
}
1109-
11101085
/**
11111086
* Returns a stream of all value nodes of this Node, iff
11121087
* this node is an {@code ArrayNode} or {@code ObjectNode}.

src/main/java/tools/jackson/databind/node/ArrayNode.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -256,18 +256,12 @@ public JsonNode required(int index) {
256256
/**
257257
* {@inheritDoc}
258258
*<p>
259-
* NOTE: actual underlying implementation returns {@link java.util.ListIterator}
260-
* from {@link java.util.List#listIterator()} that contains elements.
259+
* NOTE: this returns the live <code>List</code> and not a copy.
261260
*/
262261
@Override
263262
public Collection<JsonNode> values() {
264263
return _children;
265264
}
266-
267-
@Override
268-
public Spliterator<JsonNode> valueSpliterator() {
269-
return _children.spliterator();
270-
}
271265

272266
@Override
273267
public Stream<JsonNode> valueStream() {

src/main/java/tools/jackson/databind/node/ObjectNode.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,6 @@ public Collection<JsonNode> values() {
278278
return _children.values();
279279
}
280280

281-
@Override
282-
public Spliterator<JsonNode> valueSpliterator() {
283-
return _children.values().spliterator();
284-
}
285-
286281
@Override // @since 2.19
287282
public Stream<JsonNode> valueStream() {
288283
return _children.values().stream();
@@ -302,11 +297,6 @@ public Set<Map.Entry<String, JsonNode>> properties() {
302297
return _children.entrySet();
303298
}
304299

305-
@Override
306-
public Spliterator<Map.Entry<String, JsonNode>> propertySpliterator() {
307-
return _children.entrySet().spliterator();
308-
}
309-
310300
@Override // @since 2.19
311301
public Stream<Map.Entry<String, JsonNode>> propertyStream() {
312302
return _children.entrySet().stream();

src/test/java/tools/jackson/databind/node/ArrayNodeTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public void testDirectCreation() throws Exception
3636

3737
assertStandardEquals(n);
3838
assertFalse(n.values().iterator().hasNext());
39-
assertEquals(0, n.valueSpliterator().estimateSize());
4039
assertTrue(n.propertyNames().isEmpty());
4140
assertTrue(n.isEmpty());
4241
StringNode text = StringNode.valueOf("x");

0 commit comments

Comments
 (0)