How to check if a list contains an item?

asked 2020-10-26 06:39:52 -0600

mss gravatar image

updated 2020-10-26 11:37:47 -0600

I have a record with (among others) two fields: COLS which is a map and KEYS which is a list. I want to keep only items in COLS for which the key can be found in KEYS. To me the obvious stage choice for this was a Field Remover and some simple EL which checks for the presence of an element within a list. But that's where it got hairy since I couldn't find any function to achieve this; I probably missed something obvious.

My current approach does work but is very clunky:

/COLS/*[${not str:contains(str:concat('%', str:concat(list:join(record:value('/KEYS'), '%'), '%')), str:concat('%', str:concat(f:name(), '%')))}]

In the source code I found a CollectionEL class which looks like it should do what I want to achieve with a simpler call like this:

/COLS/*[${not collection:contains(record:value('/KEYS'), f:name())}]

Unfortunately it seems like this class isn't registered for general consumption but used in Antenna Doctor only.

Is there a better approach to what I am trying to achieve here?

edit retag flag offensive close merge delete