You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "Shurmer, Jordan" <js...@scrippsnetworks.com> on 2016/12/08 16:03:16 UTC

Thoughts on adaptTo returning Optional instead of null

Hello Sling Devs,

Currently the SlingAdaptable api specifies that null will be returned if the resource cannot be adapted. What are everyone's thoughts some future version of the API returning an Optional<AdapterType> instead?
For reference: http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html

Thanks,
Jordan Shurmer


Re: Thoughts on adaptTo returning Optional instead of null

Posted by Konrad Windszus <ko...@gmx.de>.
We already had a lengthy discussion about adaptTo() in http://apache-sling.73963.n3.nabble.com/adaptTo-and-results-tt4035466.html.
In case there is ever a refactoring on the adaptTo method the exception handling must for sure be clarified.
Konrad
> On 8 Dec 2016, at 17:03, Shurmer, Jordan <js...@scrippsnetworks.com> wrote:
> 
> Hello Sling Devs,
> 
> Currently the SlingAdaptable api specifies that null will be returned if the resource cannot be adapted. What are everyone's thoughts some future version of the API returning an Optional<AdapterType> instead?
> For reference: http://www.oracle.com/technetwork/articles/java/java8-optional-2175753.html
> 
> Thanks,
> Jordan Shurmer
>