Class AutoValueSupport
java.lang.Object
org.checkerframework.checker.calledmethods.builder.AutoValueSupport
- All Implemented Interfaces:
BuilderFrameworkSupport
AutoValue support for the Called Methods Checker. This class adds
@
CalledMethods
annotations to the code generated by AutoValue.-
Constructor Summary
ConstructorDescriptionAutoValueSupport
(CalledMethodsAnnotatedTypeFactory atypeFactory) Create a new AutoValueSupport. -
Method Summary
Modifier and TypeMethodDescriptiongetAllAbstractMethods
(TypeElement classElement) Get all the abstract methods for a class.void
handleBuilderBuildMethod
(AnnotatedTypeMirror.AnnotatedExecutableType builderBuildType) Hook for adding annotations to a build() method (i.e.void
handleConstructor
(NewClassTree tree, AnnotatedTypeMirror type) This method modifies the type of a copy constructor generated by AutoValue to match the type of the AutoValue toBuilder method, and has no effect iftree
is a call to any other constructor.void
handleToBuilderMethod
(AnnotatedTypeMirror.AnnotatedExecutableType toBuilderType) Hook for supporting a builder framework'stoBuilder
routine.boolean
isBuilderBuildMethod
(ExecutableElement candidateBuildElement) Determines if a method is abuild
method on aBuilder
type for the builder framework.boolean
isToBuilderMethod
(ExecutableElement candidateToBuilderElement) Determines if a method is atoBuilder
method on a type generated by the builder framework.
-
Constructor Details
-
AutoValueSupport
Create a new AutoValueSupport.- Parameters:
atypeFactory
- the typechecker's type factory
-
-
Method Details
-
handleConstructor
This method modifies the type of a copy constructor generated by AutoValue to match the type of the AutoValue toBuilder method, and has no effect iftree
is a call to any other constructor.- Specified by:
handleConstructor
in interfaceBuilderFrameworkSupport
- Parameters:
tree
- AST for a constructor calltype
- type of the call expression
-
isBuilderBuildMethod
Description copied from interface:BuilderFrameworkSupport
Determines 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
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
Description copied from interface:BuilderFrameworkSupport
Determines 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
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
-
getAllAbstractMethods
Get all the abstract methods for a class. This includes inherited abstract methods that are not overridden by the class or a superclass. There is no guarantee that this method will work as intended on code that implements an interface (which AutoValue classes are not supposed to do: https://github.com/google/auto/blob/master/value/userguide/howto.md#inherit).- Parameters:
classElement
- the class- Returns:
- list of all abstract methods
-