Class LombokSupport
- java.lang.Object
-
- org.checkerframework.checker.calledmethods.builder.LombokSupport
-
- All Implemented Interfaces:
BuilderFrameworkSupport
public class LombokSupport extends java.lang.Object implements BuilderFrameworkSupport
Lombok support for the Called Methods Checker. This class adds CalledMethods annotations to the code generated by Lombok.
-
-
Field Summary
Fields Modifier and Type Field Description static java.util.List<java.lang.String>
NONNULL_ANNOTATIONS
The list of annotations that Lombok treats as non-null.
-
Constructor Summary
Constructors Constructor Description LombokSupport(CalledMethodsAnnotatedTypeFactory atypeFactory)
Create a new LombokSupport.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
handleBuilderBuildMethod(AnnotatedTypeMirror.AnnotatedExecutableType builderBuildType)
Hook for adding annotations to a build() method (i.e.void
handleConstructor(com.sun.source.tree.NewClassTree tree, AnnotatedTypeMirror type)
Hook for adding annotations (e.g.,@
CalledMethods
) to a constructor call.void
handleToBuilderMethod(AnnotatedTypeMirror.AnnotatedExecutableType toBuilderType)
Hook for supporting a builder framework'stoBuilder
routine.boolean
isBuilderBuildMethod(javax.lang.model.element.ExecutableElement candidateBuildElement)
Returns true if a method is abuild
method on aBuilder
type for the builder framework.boolean
isToBuilderMethod(javax.lang.model.element.ExecutableElement candidateToBuilderElement)
Returns true if a method is atoBuilder
method on a type generated by the builder framework.
-
-
-
Constructor Detail
-
LombokSupport
public LombokSupport(CalledMethodsAnnotatedTypeFactory atypeFactory)
Create a new LombokSupport.- Parameters:
atypeFactory
- the typechecker's type factory
-
-
Method Detail
-
isBuilderBuildMethod
public boolean isBuilderBuildMethod(javax.lang.model.element.ExecutableElement candidateBuildElement)
Description copied from interface:BuilderFrameworkSupport
Returns true if a method is abuild
method on aBuilder
type for the builder framework.- Specified by:
isBuilderBuildMethod
in interfaceBuilderFrameworkSupport
- Parameters:
candidateBuildElement
- a method- Returns:
true
ifcandidateBuildElement
is abuild
method on aBuilder
type for the builder framework
-
handleBuilderBuildMethod
public void handleBuilderBuildMethod(AnnotatedTypeMirror.AnnotatedExecutableType builderBuildType)
Description copied from interface:BuilderFrameworkSupport
Hook for adding annotations to a build() method (i.e. a finalizer) generated by a builder framework.For
build
methods onBuilder
types, implementations of this method should determine the required properties and add a correspondingCalledMethods
annotation to the type of the receiver parameter.- Specified by:
handleBuilderBuildMethod
in interfaceBuilderFrameworkSupport
- Parameters:
builderBuildType
- the type of a method that is thebuild
method (as determined byBuilderFrameworkSupport.isBuilderBuildMethod(ExecutableElement)
) for a builder
-
isToBuilderMethod
public boolean isToBuilderMethod(javax.lang.model.element.ExecutableElement candidateToBuilderElement)
Description copied from interface:BuilderFrameworkSupport
Returns true if a method is atoBuilder
method on a type generated by the builder framework.- Specified by:
isToBuilderMethod
in interfaceBuilderFrameworkSupport
- Parameters:
candidateToBuilderElement
- a method- Returns:
true
ifcandidateToBuilderElement
is atoBuilder
method on a type generated by the builder framework
-
handleToBuilderMethod
public void handleToBuilderMethod(AnnotatedTypeMirror.AnnotatedExecutableType toBuilderType)
Description copied from interface:BuilderFrameworkSupport
Hook for supporting a builder framework'stoBuilder
routine. Typically, the returned Builder has had all of its required setters invoked. So, implementations of this method should add aCalledMethods
annotation capturing this fact.- Specified by:
handleToBuilderMethod
in interfaceBuilderFrameworkSupport
- Parameters:
toBuilderType
- the type of a method that is thetoBuilder
method (as determined byBuilderFrameworkSupport.isToBuilderMethod(ExecutableElement)
) for a type that has an associated builder
-
handleConstructor
public void handleConstructor(com.sun.source.tree.NewClassTree tree, AnnotatedTypeMirror type)
Description copied from interface:BuilderFrameworkSupport
Hook for adding annotations (e.g.,@
CalledMethods
) to a constructor call.- Specified by:
handleConstructor
in interfaceBuilderFrameworkSupport
- Parameters:
tree
- a constructor calltype
- type of the call expression
-
-