Interface BuilderFrameworkSupport
-
- All Known Implementing Classes:
AutoValueSupport
,LombokSupport
public interface BuilderFrameworkSupport
Provides hooks to add CalledMethods annotations to code generated by a builder framework like Lombok or AutoValue. If you are adding support to the Called Methods Checker for a new builder framework, you should create a subclass of this class and modify the private methodenableFramework
inCalledMethodsAnnotatedTypeFactory
.Every method in this class is permitted to do nothing (or always return false). The work that each method must do is particular to the builder framework being supported.
-
-
Method Summary
All Methods Instance Methods Abstract 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.
-
-
-
Method Detail
-
isToBuilderMethod
boolean isToBuilderMethod(javax.lang.model.element.ExecutableElement candidateToBuilderElement)
Returns true if a method is atoBuilder
method on a type generated by the builder framework.- Parameters:
candidateToBuilderElement
- a method- Returns:
true
ifcandidateToBuilderElement
is atoBuilder
method on a type generated by the builder framework
-
handleToBuilderMethod
void handleToBuilderMethod(AnnotatedTypeMirror.AnnotatedExecutableType toBuilderType)
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.- Parameters:
toBuilderType
- the type of a method that is thetoBuilder
method (as determined byisToBuilderMethod(ExecutableElement)
) for a type that has an associated builder
-
isBuilderBuildMethod
boolean isBuilderBuildMethod(javax.lang.model.element.ExecutableElement candidateBuildElement)
Returns true if a method is abuild
method on aBuilder
type for the builder framework.- Parameters:
candidateBuildElement
- a method- Returns:
true
ifcandidateBuildElement
is abuild
method on aBuilder
type for the builder framework
-
handleBuilderBuildMethod
void handleBuilderBuildMethod(AnnotatedTypeMirror.AnnotatedExecutableType builderBuildType)
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.- Parameters:
builderBuildType
- the type of a method that is thebuild
method (as determined byisBuilderBuildMethod(ExecutableElement)
) for a builder
-
handleConstructor
void handleConstructor(com.sun.source.tree.NewClassTree tree, AnnotatedTypeMirror type)
Hook for adding annotations (e.g.,@
CalledMethods
) to a constructor call.- Parameters:
tree
- a constructor calltype
- type of the call expression
-
-