Extract lambda parameter
The Extract Lambda Parameter refactoring helps you extract an expression or statement into a new parameter with a lambda expression passed as a corresponding argument. For example, this could be a comparator passed to a sorting function.
Extract a lambda parameter
Select a code fragment you want to extract into a lambda parameter.
Call Lambda Parameter from the Refactor This (Ctrl+Alt+Shift+T) popup:from the main menu or choose
In the dialog that opens, specify the name, return type, and declaration placement for the new lambda parameter:
Review the changes in the Signature Preview field and click Extract. The refactoring with be applied right away: