Replace this lambda with a method reference. (sonar.java.source is not installed. Suppose 8 or more.)

List<UUID> insrVrfyIds = insrVrfyObjsNew.stream().map(insrVrfy -> insrVrfy.getCustomerInsrVrfyId()).collect(Collectors.toList());

For the following code, I get a warning, as I mentioned in the title. Can someone explain to me how to do this.

here, in the code above, I have a list of objects from which I want to extract all primary keys using a lambda expression. But I get a violation like " Replace this lambda with a method reference (sonar .java.source not installed. Suppose 8 or more.) "

+4
source share
2 answers

Well, that probably means you could write it the same way:

List<UUID> insrVrfyIds = insrVrfyObjsNew.stream().map(InsrVrfy::getCustomerInsrVrfyId).collect(Collectors.toList());

, insrVrfy InsrVrfy, , , , .

.

+6
List<UUID> insrVrfyIds =
                    insrVrfyObjsNew.stream().map(CustomerInsrVrfy::getCustomerInsrVrfyId).collect(Collectors.toList());

.. , , (insrVrfy) (CustomerInsrVrfy).

0

Source: https://habr.com/ru/post/1685608/


All Articles