I am getting this warning on SonarQube: "Replace this lambda with a method reference."
The code is :
childrenNames = StreamSupport.stream(favouritesFolder.getChildren().spliterator(), false)
.map(node -> node.getName())
.limit(NUMBER_OF_FILES_TO_DISPLAY)
.collect(Collectors.toList());
How can I replace the lambda with a method reference in my case?
CodePudding user response:
I was able to solve the issue by assigning the type of the node which is in my case CmisObject
as following:
childrenNames = StreamSupport.stream(favouritesFolder.getChildren().spliterator(), false)
.map(CmisObject::getName)
.limit(NUMBER_OF_FILES_TO_DISPLAY)
.collect(Collectors.toList());
CodePudding user response:
node -> node.getName()
=>Node::getName