Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 348490 - Support simpler EL check of a value against a set of expected values
Summary: Support simpler EL check of a value against a set of expected values
Status: CLOSED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Sapphire (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Konstantin Komissarchik CLA
QA Contact:
URL:
Whiteboard:
Keywords: plan
Depends on:
Blocks:
 
Reported: 2011-06-06 22:23 EDT by Konstantin Komissarchik CLA
Modified: 2021-11-19 09:21 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Konstantin Komissarchik CLA 2011-06-06 22:23:58 EDT
Consider the case where a property holds an enum and you need to check to see if the property holds one of three enum values.

You can write an expression like this one:

${ ShapeType == 'TRIANGLE' || ShapeType == 'RECTANGLE' || ShapeType == 'SQUARE' }

But that's quite verbose, especially as the number of items to check goes higher. There can also be a problem if LHS of the comparison is an expression rather than a simple property access. Using this pattern would re-evaluate the expression multiple times.

We need something equivalent to SQL IN operator. We should be able to write the above expression like so:

${ ShapeType IN List( 'TRIANGLE', 'RECTANGLE', 'SQUARE' ) }

To do this we need two things: (a) List function that can turn an arbitrary number of operands into a list and (b) IN operator.
Comment 1 Konstantin Komissarchik CLA 2011-06-06 22:27:54 EDT
Enhancement implemented. Updated the EL documentation and the what's new doc for 0.3 release. Unit tests in TestExpr0005 and TestExpr0006. Example of usage in IIfThenElseGallery class of the gallery sample.
Comment 2 Ling Hao CLA 2011-06-10 13:36:21 EDT
Verified in gallery sample, unit test and coherence test case.