public class LambdaGenerationUtil
extends java.lang.Object
Constructor and Description |
---|
LambdaGenerationUtil() |
Modifier and Type | Method and Description |
---|---|
static boolean |
canBeUncheckedLambda(PsiElement lambdaCandidate)
Tests the element (expression or statement) whether it could be converted to the body
of lambda expression mapped to functional interface which SAM does not declare any
checked exceptions.
|
static boolean |
canBeUncheckedLambda(PsiElement lambdaCandidate,
java.util.function.Predicate<? super PsiVariable> variableAllowedPredicate)
Tests the element (expression or statement) whether it could be converted to the body
of lambda expression mapped to functional interface which SAM does not declare any
checked exceptions.
|
public static boolean canBeUncheckedLambda(PsiElement lambdaCandidate)
1. The expression should not throw checked exceptions
2. The expression should not refer any variables which are not effectively final
3. No control flow instructions inside which may jump out of the supplied lambdaCandidate
lambdaCandidate
- an expression or statement to testpublic static boolean canBeUncheckedLambda(PsiElement lambdaCandidate, java.util.function.Predicate<? super PsiVariable> variableAllowedPredicate)
1. The expression should not throw checked exceptions
2. The expression should not refer any variables which are not effectively final and not allowed by specified predicate
3. No control flow instructions inside which may jump out of the supplied lambdaCandidate
lambdaCandidate
- an expression or statement to testvariableAllowedPredicate
- a predicate which returns true if the variable is allowed to be present inside lambdaCandidate
even if it's not effectively final (e.g. it will be replaced by something else when moved to lambda)