I'm working on a project (Java 17) where I have a list of object with two properties, actionId (String) and right (boolean). I'm trying to get the actionId for object with right = true and store the result as List of String.
This is my code:
List<String> usserValidActionsArray = userActionGatewayDTO.stream().filter(UserActionGatewayDTO::getRight)
.map(UserActionGatewayDTO::getActionId).toList();
My code works fine, but Sonar is blocking me by saying:
Refactor the code so this stream pipeline is used
Can anyone suggest to me how I can improve my code to be compliant?