Issue
When in IntelliJ you enter some code like this :
Runnable cronTask = new Runnable() {
@Override
public void run() {
// do something
}
};
IntelliJ will automatically suggest that this will be better when using a lambda expression. And you have the option to do an automatic conversion to
Runnable cronTask = () -> {
// do something
};
Is something like this possible in Eclipse ? Maybe with some kind of plugin ? I want Eclipse to give me warnings of where a lambda expression might be a better solution. And if possible also suggest the correct fix.
Solution
To the best of my knowledge, there is no way to make Eclipse show compiler warnings where lambda expressions are a better alternative. Nevertheless, there is a nice feature that takes care of the automatic conversion you requested.
Right-click on any project or Java file, and select Source -> Clean Up... In the window that appears, select Use custom profile, and click Configure... In the Code Style tab, enable Convert functional interface instances, and make sure Use lambda where possible is selected, as shown in the screenshot below:
Validate and run the clean up. This feature alongside the manual Quick assist suggested by Timothy Truckle in the comments will hopefully cover most of your needs.
Answered By - Pyves

0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.