Class LambdaFunctionalInterface
- java.lang.Object
-
- com.google.errorprone.bugpatterns.BugChecker
-
- com.google.errorprone.bugpatterns.LambdaFunctionalInterface
-
- All Implemented Interfaces:
BugChecker.MethodTreeMatcher
,Suppressible
,Serializable
public class LambdaFunctionalInterface extends BugChecker implements BugChecker.MethodTreeMatcher
- Author:
- [email protected] (Ali Mesbah)
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.errorprone.bugpatterns.BugChecker
BugChecker.AnnotatedTypeTreeMatcher, BugChecker.AnnotationTreeMatcher, BugChecker.ArrayAccessTreeMatcher, BugChecker.ArrayTypeTreeMatcher, BugChecker.AssertTreeMatcher, BugChecker.AssignmentTreeMatcher, BugChecker.BinaryTreeMatcher, BugChecker.BlockTreeMatcher, BugChecker.BreakTreeMatcher, BugChecker.CaseTreeMatcher, BugChecker.CatchTreeMatcher, BugChecker.ClassTreeMatcher, BugChecker.CompilationUnitTreeMatcher, BugChecker.CompoundAssignmentTreeMatcher, BugChecker.ConditionalExpressionTreeMatcher, BugChecker.ContinueTreeMatcher, BugChecker.DoWhileLoopTreeMatcher, BugChecker.EmptyStatementTreeMatcher, BugChecker.EnhancedForLoopTreeMatcher, BugChecker.ExpressionStatementTreeMatcher, BugChecker.ForLoopTreeMatcher, BugChecker.IdentifierTreeMatcher, BugChecker.IfTreeMatcher, BugChecker.ImportTreeMatcher, BugChecker.InstanceOfTreeMatcher, BugChecker.IntersectionTypeTreeMatcher, BugChecker.LabeledStatementTreeMatcher, BugChecker.LambdaExpressionTreeMatcher, BugChecker.LiteralTreeMatcher, BugChecker.MemberReferenceTreeMatcher, BugChecker.MemberSelectTreeMatcher, BugChecker.MethodInvocationTreeMatcher, BugChecker.MethodTreeMatcher, BugChecker.ModifiersTreeMatcher, BugChecker.NewArrayTreeMatcher, BugChecker.NewClassTreeMatcher, BugChecker.ParameterizedTypeTreeMatcher, BugChecker.ParenthesizedTreeMatcher, BugChecker.PrimitiveTypeTreeMatcher, BugChecker.ReturnTreeMatcher, BugChecker.SuppressibleTreePathScanner<A extends Object,B extends Object>, BugChecker.SwitchTreeMatcher, BugChecker.SynchronizedTreeMatcher, BugChecker.ThrowTreeMatcher, BugChecker.TryTreeMatcher, BugChecker.TypeCastTreeMatcher, BugChecker.TypeParameterTreeMatcher, BugChecker.UnaryTreeMatcher, BugChecker.UnionTypeTreeMatcher, BugChecker.VariableTreeMatcher, BugChecker.WhileLoopTreeMatcher, BugChecker.WildcardTreeMatcher
-
-
Constructor Summary
Constructors Constructor Description LambdaFunctionalInterface()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Description
matchMethod(com.sun.source.tree.MethodTree tree, VisitorState state)
Identifies methods with parameters that have a generic argument with Int, Long, or Double.-
Methods inherited from class com.google.errorprone.bugpatterns.BugChecker
allNames, buildDescription, buildDescription, buildDescription, canonicalName, customSuppressionAnnotations, defaultSeverity, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, describeMatch, disableable, equals, hashCode, isSuppressed, isSuppressed, isSuppressed, isSuppressed, linkUrl, message, supportsSuppressWarnings, suppressedByAnyOf, suppressedRegions
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.google.errorprone.matchers.Suppressible
allNames, canonicalName, customSuppressionAnnotations, supportsSuppressWarnings, suppressedByAnyOf
-
-
-
-
Method Detail
-
matchMethod
public Description matchMethod(com.sun.source.tree.MethodTree tree, VisitorState state)
Identifies methods with parameters that have a generic argument with Int, Long, or Double. If pre-conditions are met, it refactors them to the primitive specializations.PreConditions: (1): The method declaration has to be private (to do a safe refactoring) (2): Its parameters have to meet the following conditions: 2.1 Contain type java.util.function.Function 2.2 At least one argument type of the Function must be subtype of Number (3): All its invocations in the top-level enclosing class have to meet the following conditions as well: 3.1: lambda argument of Kind.LAMBDA_EXPRESSION 3.2: same as 2.1 3.3: same as 2.2
Refactoring Changes for matched methods: (1) Add the imports (2) Change the method signature to use utility function instead of Function (3) Find and change the 'apply' calls to the corresponding applyAsT
- Specified by:
matchMethod
in interfaceBugChecker.MethodTreeMatcher
-
-