el-spec icon indicating copy to clipboard operation
el-spec copied to clipboard

Property support for Optional<T>

Open glassfishrobot opened this issue 11 years ago • 4 comments

Expression language in Java EE 8 should bring special treatment for java.util.Optional, similar like it does for maps and lists:

When a base expression evaluates to instance of java.util.Optional, and the property name is not equal present, the result of the evaluation shall be equivalent to calling method map or flatMap on the optional:

  • if the base {{Optional]} has value:
    1. evaluate the property against the value of the property,
    2. if the result of an evaluation is instance of an Optional
      • return the value; otherwise
      • return the value wrapped in an Optional
  • if base optional, doesn't have value, return Optional.empty()

The property present is evaluated by invoking the method isPresent() of the base object.

An example of implementation of this behaviour can be found in this ELResolver implementation.

glassfishrobot avatar Dec 06 '14 13:12 glassfishrobot

Reported by pdudits

glassfishrobot avatar Dec 06 '14 13:12 glassfishrobot

kchung said: EL 3.0 was targeted for JDK 7, and as such knows nothing about Optional. However, Optional should be supported in the next release of EL, which is presumable targeted for JDK 8. It is also likely that the next release of EL, EL 3.1 will be a MR.

glassfishrobot avatar Dec 11 '14 17:12 glassfishrobot

Was assigned to kchung

glassfishrobot avatar Dec 06 '14 13:12 glassfishrobot

This issue was imported from java.net JIRA EL_SPEC-21

glassfishrobot avatar Apr 24 '17 07:04 glassfishrobot