[
https://issues.apache.org/jira/browse/JENA-1427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16264622#comment-16264622
]
A. Soroka edited comment on JENA-1427 at 11/23/17 5:14 PM:
-----------------------------------------------------------
I'd be very much inclined to just {{nextOptional}}. It's simple and it reuses a
standard type which is already familiar to users. It provides all the
functionality in that type, so or-else and more. Lastly, it allows callers to
understand whether the iterator is done.
was (Author: ajs6f):
I'd be very much inclined to just {{nextOptional}}. It's simple and it reuses a
standard type which is already familiar to users. It provides all the
functionality in that type, so or-else and more.
> 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)