[
https://issues.apache.org/jira/browse/JENA-1955?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17186504#comment-17186504
]
Andy Seaborne commented on JENA-1955:
-------------------------------------
I do not think it is simple as portrayed.
This would impact a lot of existing code. To date, the user community has been
more in favour of stability.
These are not in streams; the change is replace "if ( x != null )" with "if (
x.isPresent() )".
Library code can provide a different style:
{noformat}
getResource(QuerySolution, String, x->{...});
{noformat}
I believe that a new APIs to sit along side existing ones is the way to evolve.
This is both a way to consider the whole functionality and also respect the
significant legacy code issue.
> Make use of Optional or NoSuchElementException
> ----------------------------------------------
>
> Key: JENA-1955
> URL: https://issues.apache.org/jira/browse/JENA-1955
> Project: Apache Jena
> Issue Type: Improvement
> Reporter: Jan Martin Keil
> Priority: Major
>
> Many methods currently return {{null}} or an empty String, if something was
> not present. It would significantly ease writing stable and fault-tolerant
> code, if this methods would be replaced be methods returning an
> {{java.util.Optional}} (preferred) or throwing an {{NoSuchElementException}}
> instead.
> Best way to do that would probably be to deprecate the current methods for
> the time being and add new methods using {{java.util.Optional}} or
> {{NoSuchElementException}}.
> An (probably incomplete) example list of affected methods:
> * {{QuerySolution#get(String)}}
> * {{QuerySolution#getResource(String)}}
> * {{QuerySolution#getLiteral(String)}}
> * {{Literal#getLanguage()}}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)