That’s an unusual construction.
The Group filter will return a list object.
The if() will try to evaluate the list as true or false; if the list is empty (null) I expect that will be false, not sure if any non-zero list would be true?
In either case, the list is then thrown away before executing the next line.
This might help if you really want to test list/no-list
This never happens and can be removed,
I would imagine you want to forEach through your filtered list
@rossko57 is absolutely right, the filter returns a List so you need to do a forEach on that filtered list assuming you want to do something with each member of the filtered list.
What happens if you leave out the “GenericItem” part? It’s not usually needed and it’s often better to not type things unless you really really have to. This isn’t a case where you usually have to.
However, if the warning is still there without the “GenericItem”, then I’m skeptical that this is the actual source of the warning.
It’s complaining that it can’t infer the type of the closure’s arguments. In this case GenericItem sis the argument to the closure. And by providing GenericItem as the type, you are typing the argument. In this context, for the filter, GenericItem is probably the right type to use. You don’t need to be more specific than that. But, as I said it’s not really needed because the .members returns a List<Item> so it already knows the type.
One note on the filter though. s.state will *never be null so that test is redundant. And it’s off to compare the state to NULL but then the string "UNDEF". Why not compare to UNDEF the same as you compare to NULL?
Or you can use if(s.state instanceof UnDefType) which covers both NULL and UNDEF.