expression-language icon indicating copy to clipboard operation
expression-language copied to clipboard

Add Elvis Operator to Simplfy Null Handling

Open hantsy opened this issue 1 year ago • 2 comments

eg. if email is null, returns Not Found instead, else returns email property.

customer.email?:'Not Found'

hantsy avatar Jul 22 '24 03:07 hantsy

I have an implementation of this in the current Tomcat 12 development branch. You can download SNAPSHOT build a standard distribution from: https://repository.apache.org/content/groups/snapshots/org/apache/tomcat/tomcat/12.0.0-M1-SNAPSHOT/

Embedded and individual JARs are also available.

If you could try that and and confirm whether or not it works for you that would be great. I can then work on the changes required to the specification document and some TCK tests.

markt-asf avatar Aug 16 '24 08:08 markt-asf

It has been over a month without feedback. The operator works as expected for me so I am going to proceed with the spec updates and TCK tests for 6.1.

markt-asf avatar Sep 20 '24 10:09 markt-asf

The functionality that has been requested here is the Null coalescing operator (??) not the Elvis operator (?:).

Given the similarities, I am going to implement both.

markt-asf avatar Apr 24 '25 11:04 markt-asf