Uploaded image for project: 'Sling'
  1. Sling
  2. SLING-8706

Injections for java.util.Optional<> should be automatic optional

    XMLWordPrintableJSON

Details

    Description

      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

      @Inject @Optional
      String fieldname;
      

      it should also be possible to use this

      @Inject
      Optional<String> fieldname;
      

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

      Attachments

        Activity

          People

            joerghoh Joerg Hoh
            joerghoh Joerg Hoh
            Votes:
            5 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 5.5h
                5.5h