[JSON_PROCESSING_SPEC-17] JsonParser shouldn't extend Iterable Created: 24/Oct/12  Updated: 03/Dec/12  Resolved: 24/Oct/12

Status: Resolved
Project: json-processing-spec
Component/s: None
Affects Version/s: None
Fix Version/s: 1.0-pr

Type: Improvement Priority: Major
Reporter: jitu Assignee: jitu
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified



Comment by jitu [ 24/Oct/12 ]

Checked with SE team regarding Iterable. Here is a comment

"While the specifications do not require that an Iterable can be iterated repeatedly/consistently, many users expect this and are likely to be confused if they cannot.

If you do not intend iterator() to return a fresh "rewound" view every time, then you should probably follow the convention set by Socket.getInputStream(), which returns the same stream on every call.

You definitely don't want to implement Iterator; a parser is-not-a Iterator. One option would be to have an iterator() method but not implement Iterable, where the iterator() method was spec'ed to behave as above – just return the same Iterator object every time. All you lose there is the foreach loop support – no big deal.

Overall I think you sow more confusion than benefit by implementing Iterable.

When you get to EE 8 you can implement Streamable too!"

Based on this, added iterator() method.

Generated at Wed Oct 07 06:37:28 UTC 2015 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.