Jörg Hoh created SLING-8706:
-------------------------------

             Summary: Injections for java.util.Optional<> should be automatic 
optional 
                 Key: SLING-8706
                 URL: https://issues.apache.org/jira/browse/SLING-8706
             Project: Sling
          Issue Type: Improvement
          Components: Sling Models
            Reporter: Jörg Hoh


The current approach to support optional injections requires to annotate the 
field with {{@Optional}} plus proper handling within the javacode (null checks 
etc), which can be forgotten.

So instead of

{code}
@Inject @Optional
String fieldname;
{code}

it should also be possible to use this
{code}
@Inject
Optional<String> fieldname;
{code}

with the very same semantic. But the developer is forced to deal with the case 
that the value is not present.



--
This message was sent by Atlassian Jira
(v8.3.2#803003)

Reply via email to