Regex Point Lambdafication Patch
Paul Sandoz
paul.sandoz at oracle.com
Wed Mar 13 03:51:34 PDT 2013
Hi Ben,
On Mar 12, 2013, at 10:33 PM, Ben Evans <benjamin.john.evans at gmail.com> wrote:
> Thanks Brian.
>
> Does this webrev address the current comments?
>
> http://www.java7developer.com/webrev-kittylyst.002/
>
Can you include Spliterator.NONNULL in the characteristics since I presume input.subSequence will never return a non-null value?
A useful pattern when writing iterators is to do:
T next() {
if (!hasNext()) throw NoSuchElementException();
...
}
so hasNext() when returning true sets up the correct state for next() to obtain the next element e.g.:
CharSequence next() {
if (!hasNext()) throw NoSuchElementException();
return input.subsequence(start, end);
}
Once that works once can decide if it is worth optimizing the implementation.
--
Testing wise my preference is to add a test ng test extending OpTestCase, add a data provider with the pattern and executed result then use the OpTestCase.exerciseOps or the builder.
That will ensure the stream is tested under many different scenarios with reporting for each item of data.
I can help you with that if you like.
Paul.
More information about the lambda-dev
mailing list