>From the original request it seems the requirements were:
1. return a default value if the iterator is empty.
2. throw a custom exception if the iterator is empty.


Perhaps we should add a next( T default ) method that will return the
default if hasNext() returns false.  This seem better than polluting the
environment with Optionals that don't really belong.

If we want to provide a method to throw an custom exception we could add
something like next( Class<? extends Exception> e ) to create and throw the
exception.  But I don't like this one for some reason.  Like the Optional
it doesn't pass the smell test for me.

It seems that much of the rest of  the discussion is covered by adding a
method to convert the iterator to a stream (probably just a call to an
existing Java method.

Claude


On Sun, Dec 17, 2017 at 5:50 PM, Andy Seaborne <[email protected]> wrote:

> We seem to have drifted a bit here - the original use case wasn't about
> streaming as I read it. list* get used to write zero/one tests and one/many
> tests dealing with properties etc.
>
> And, of course, we want to avoid the anti-pattern of Optional/if-empty.
>
> Claude - thoughts on the use case? How might we evolve the current API
> without method bloat?
>
>     Andy
>
>
> On 14/12/17 17:46, Claude Warren wrote:
>
>> I was expecting that with the discovery that optional throws a null
>> pointer
>> exception when the retrieved value is null would be enough to remove this
>> functionality.
>>
>> I am concerned that once added it will be difficult to remove and that its
>> operation is not congruent with stream based optional usage.
>>
>> Claude
>>
>> On 14 Dec 2017 10:33, "Andy Seaborne" <[email protected]> wrote:
>>
>> Claude,
>>>
>>> The JIRA ticket ends:
>>>
>>> [[
>>> ASF GitHub Bot added a comment - 04/Dec/17 15:36
>>>
>>> That was already the case in the PR and I've added text to call it out
>>> explicitly into the javadoc.
>>> ----
>>> githubbot ASF GitHub Bot added a comment - 04/Dec/17 15:40
>>>
>>> Github user ajs6f commented on the issue:
>>>
>>> https://github.com/apache/jena/pull/323
>>>
>>> Okay, that works for me!
>>> ----
>>> Andy Seaborne added a comment - 04/Dec/17 15:58
>>>
>>> nextOptional added for release 3.6.0.
>>>
>>> Proposal: close this JIRA for now, see how nextOptional works out and
>>> revisit orElse* based on experience.
>>> ----
>>> ajs6f A. Soroka added a comment - 1 week ago
>>>
>>> +1
>>> ]]
>>>
>>> Adding nextOptional, and no others, is in the RC.
>>>
>>> What were you expecting?
>>>
>>>      Andy
>>>
>>> On 14/12/17 08:44, Claude Warren wrote:
>>>
>>> Perhaps i wasn't paying close enough attention but i didn't think adding
>>>> optional and other streaming methods had been agreed.  In fact i thought
>>>> quite the oposite.
>>>>
>>>> If i am wrong please forgive the noise.  If i am correct shouldn't 1427
>>>> be
>>>> removed from the release candidate?
>>>>
>>>> Claude
>>>>
>>>>
>>>>
>>


-- 
I like: Like Like - The likeliest place on the web
<http://like-like.xenei.com>
LinkedIn: http://www.linkedin.com/in/claudewarren

Reply via email to