# Remove Lambda Expression Braces
# Description
If the body of the lambda statement contains only a single expression, the braces are optional. It can be reduced to a lambda expression.
This is comparable to if-statements or loops with a single expression inside their body, where braces are also optional.
# Benefits
This rule provides an easier-to read alternative to filter items in a list.
# Tags
# Code Changes
Pre
public Function<Function, Function> f = (Function function) -> {
return function.compose(function);
};
Post
public Function<Function, Function> f = (Function function) -> function.compose(function);
Use a Java Refactoring Tool
No license required
You can review this refactoring on your code without a license by installing jSparrow to your Eclipse IDE. Install the plug-in from Eclipse IDE: Eclipse Marketplace.
System-wide Refactoring
Do you want to automate this refactoring (and many more) to your system-wide code? The automatic application of this system-wide refactoring can be unlocked by acquiring your jSparrow license.
# Properties
Property | Value |
---|---|
Rule ID | StatementLambdaToExpression |
First seen in jSparrow version | 2.0.0 |
Minimum Java version | 8 |
Remediation cost | 5 min |