You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jena.apache.org by "Jan Martin Keil (Jira)" <ji...@apache.org> on 2020/08/28 09:20:00 UTC
[jira] [Updated] (JENA-1955) Make use of Optional or
NoSuchElementException
[ https://issues.apache.org/jira/browse/JENA-1955?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jan Martin Keil updated JENA-1955:
----------------------------------
Description:
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()}}
was:
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()}}
> 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)