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 method
enableFramework in CalledMethodsAnnotatedTypeFactory.
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
Modifier and TypeMethodDescriptionvoidhandleBuilderBuildMethod(AnnotatedTypeMirror.AnnotatedExecutableType builderBuildType) Hook for adding annotations to a build() method (i.e.voidhandleConstructor(NewClassTree tree, AnnotatedTypeMirror type) Hook for adding annotations (e.g.,@CalledMethods) to a constructor call.voidhandleToBuilderMethod(AnnotatedTypeMirror.AnnotatedExecutableType toBuilderType) Hook for supporting a builder framework'stoBuilderroutine.booleanisBuilderBuildMethod(ExecutableElement candidateBuildElement) Returns true if a method is abuildmethod on aBuildertype for the builder framework.booleanisToBuilderMethod(ExecutableElement candidateToBuilderElement) Returns true if a method is atoBuildermethod on a type generated by the builder framework.
-
Method Details
-
isToBuilderMethod
Returns true if a method is atoBuildermethod on a type generated by the builder framework.- Parameters:
candidateToBuilderElement- a method- Returns:
trueifcandidateToBuilderElementis atoBuildermethod on a type generated by the builder framework
-
handleToBuilderMethod
Hook for supporting a builder framework'stoBuilderroutine. Typically, the returned Builder has had all of its required setters invoked. So, implementations of this method should add aCalledMethodsannotation capturing this fact.- Parameters:
toBuilderType- the type of a method that is thetoBuildermethod (as determined byisToBuilderMethod(ExecutableElement)) for a type that has an associated builder
-
isBuilderBuildMethod
Returns true if a method is abuildmethod on aBuildertype for the builder framework.- Parameters:
candidateBuildElement- a method- Returns:
trueifcandidateBuildElementis abuildmethod on aBuildertype for the builder framework
-
handleBuilderBuildMethod
Hook for adding annotations to a build() method (i.e. a finalizer) generated by a builder framework.For
buildmethods onBuildertypes, implementations of this method should determine the required properties and add a correspondingCalledMethodsannotation to the type of the receiver parameter.- Parameters:
builderBuildType- the type of a method that is thebuildmethod (as determined byisBuilderBuildMethod(ExecutableElement)) for a builder
-
handleConstructor
Hook for adding annotations (e.g.,@CalledMethods) to a constructor call.- Parameters:
tree- a constructor calltype- type of the call expression
-