List<UUID> insrVrfyIds = insrVrfyObjsNew.stream().map(insrVrfy -> insrVrfy.getCustomerInsrVrfyId()).collect(Collectors.toList());
For the following code i am getting a warning as i mentioned in title. Can anyone please explain me how to convert this.
here in the above code, i have a list of objects from that i want to extract all the primary keys using lambda expression.But i am getting the violation like "Replace this lambda with a method reference. (sonar.java.source not set. Assuming 8 or greater.)"
Well it probably means that you could write it also like this:
List<UUID> insrVrfyIds = insrVrfyObjsNew.stream().map(InsrVrfy::getCustomerInsrVrfyId).collect(Collectors.toList());
I assumed there that your instance insrVrfy is of a class InsrVrfy so if I was mistaken please correct me.
Here you could read more about method reference.
List<UUID> insrVrfyIds =
insrVrfyObjsNew.stream().map(CustomerInsrVrfy::getCustomerInsrVrfyId).collect(Collectors.toList());
This worked for the above.. That's my bad, it's working by replacing the variable (insrVrfy) with it's class name(CustomerInsrVrfy).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With