[
https://issues.apache.org/jira/browse/JENA-1427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16273327#comment-16273327
]
ASF GitHub Bot commented on JENA-1427:
--------------------------------------
Github user ajs6f commented on the issue:
https://github.com/apache/jena/pull/323
That's my point-- I don't think you can do a good fluent API for this
without narrowing the `Iterator` contract to exclude `null`s, because you can't
distinguish. We can do that (narrow the contact)-- we own `ExtendedIterator`
and as you say, we aren't pushing `null`s through it for the `Model` API.
So my vote is that we do what you have here, but _also_ add a note to
`ExtendedIterator` guaranteeing that `next()` must not return `null`.
> Add nextOrElse() method in ExtendedIterator
> -------------------------------------------
>
> Key: JENA-1427
> URL: https://issues.apache.org/jira/browse/JENA-1427
> Project: Apache Jena
> Issue Type: Improvement
> Components: Core
> Affects Versions: Jena 3.5.0
> Reporter: Adam Jacobs
> Priority: Trivial
> Labels: easytask
>
> Allow a functional approach for returning a default value or throwing a
> custom exception from a Jena iterator.
> The following method may be added to the ExtendedIterator interface.
> {noformat}
> /**
> Answer the next object, if it exists, otherwise invoke the
> _supplier_.
> */
> public default T nextOrElse( Supplier<T> supplier ) {
> return hasNext() ? next() : supplier.get();
> }
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)