[JSON_PROCESSING_SPEC-17] JsonParser shouldn't extend Iterable Created: 24/Oct/12 Updated: 03/Dec/12 Resolved: 24/Oct/12
|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.