[ https://issues.apache.org/jira/browse/JENA-1427?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16273073#comment-16273073 ]
ASF GitHub Bot commented on JENA-1427: -------------------------------------- Github user afs commented on the issue: https://github.com/apache/jena/pull/323 This does not make sense to me - how can one tell from `nextOptional().orElseThrow()` when at the end without having to drop out of fluent? (or functional `first` is fluent in a functional sense). That's why I banned nulls from iterators when using `nextOptional`; I don't know of a case where `ExtendedIterator` can return nulls when used in the model API. If `nextOptional` can have two different uses, we would be better off with `nextOr*` which do differentiate the two cases. > 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)