Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [el-dev] Question about the new OptionalELResolver

Hi,

I've been following this discussion here, and recognize the importance of the current concerns.

We do have to remember that we have really little time remaining to resolve this. _expression_ Language is up for review at the end of this month:

See https://www.eclipse.org/lists/jakartaee-platform-dev/msg04409.html

Kind regards,
Arjan Tijms


On Tue, 20 Feb 2024 at 12:43, Mark Thomas via el-dev <el-dev@xxxxxxxxxxx> wrote:
On 13/02/2024 15:31, Paul Nicolucci wrote:
> Hey Mark,
>
> Your proposal seems reasonable to me!

I've started to look at implementing this in Tomcat and have found a
complication. Consider the following _expression_:

${beanA.beanBOpt.map(b -> b.name)}

Should this call Optional.map() which is likely what was intended or
should it call Optional.get().map() which will probably throw a
MethodNotFoundException

I think the answer is that the user has to choose.

Choice A: Don't use OptionalELResolver

Instances of Optional are treated like any other object. The _expression_
above will trigger a call to Optional.map() and return a (possibly
non-empty) Optional.


Choice B: Use OptionalELResolver

Instances of Optional are treated as Optional.get() if present and null
if empty (and any property or method on the Optional is ignored). The
_expression_ above will return null if the Optional is empty. If the
Optional is present then the _expression_ will return the result of
calling Optional.get().map() which may return a value or may throw a
MethodNotFoundException


I'm going to continue my work in Tomcat on this basis and see where
things end up.

Mark
_______________________________________________
el-dev mailing list
el-dev@xxxxxxxxxxx
To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/el-dev

Back to the top