Folks,
When using collect on List of items with some filter (criteria), I need to have result in the same order as it was received:
F.e. I have a list of suppliers :
List() : Supplier(“FIRST”, Status.ACTIVE), Supplier(“SECOND”, Status.INACTIVE), Supplier(“THIRD”, Status.INACTIVE)
And I need to find first INACTIVE supplier, so it must be SECOND supplier.
So doing the following :
When
$l : List() // list of suppliers
$inactive_supp : ArrayList() from collect Supplier(status == Status.INACTIVE) from $l
Then
System.out.println($l); // prints FIRST, SECOND, THIRD
System.out.println($inactive_supp); // prints THIRD, SECOND …. Instead of SECOND , THIRD
So I am getting THIRD supplier instead of SECOND as the result..
Please advise if it is a bug .., or there is another way of doing that…
Thanks,
-Sergey