public class AutoValueSupport extends Object implements BuilderFrameworkSupport
@
CalledMethods
annotations to the code generated by AutoValue.Constructor and Description |
---|
AutoValueSupport(CalledMethodsAnnotatedTypeFactory atypeFactory)
Create a new AutoValueSupport.
|
Modifier and Type | Method and Description |
---|---|
List<ExecutableElement> |
getAllAbstractMethods(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 if
tree is a call to any other
constructor. |
void |
handleToBuilderMethod(AnnotatedTypeMirror.AnnotatedExecutableType toBuilderType)
Hook for supporting a builder framework's
toBuilder routine. |
boolean |
isBuilderBuildMethod(ExecutableElement candidateBuildElement)
Determines if a method is a
build method on a Builder type for the builder
framework. |
boolean |
isToBuilderMethod(ExecutableElement candidateToBuilderElement)
Determines if a method is a
toBuilder method on a type generated by the builder
framework. |
public AutoValueSupport(CalledMethodsAnnotatedTypeFactory atypeFactory)
atypeFactory
- the typechecker's type factorypublic void handleConstructor(NewClassTree tree, AnnotatedTypeMirror type)
tree
is a call to any other
constructor.handleConstructor
in interface BuilderFrameworkSupport
tree
- AST for a constructor calltype
- type of the call expressionpublic boolean isBuilderBuildMethod(ExecutableElement candidateBuildElement)
BuilderFrameworkSupport
build
method on a Builder
type for the builder
framework.isBuilderBuildMethod
in interface BuilderFrameworkSupport
candidateBuildElement
- a methodtrue
if candidateBuildElement
is a build
method on a Builder
type for the builder frameworkpublic void handleBuilderBuildMethod(AnnotatedTypeMirror.AnnotatedExecutableType builderBuildType)
BuilderFrameworkSupport
For build
methods on Builder
types, implementations of this method should
determine the required properties and add a corresponding CalledMethods
annotation to the type of the
receiver parameter.
handleBuilderBuildMethod
in interface BuilderFrameworkSupport
builderBuildType
- the type of a method that is the build
method (as determined by
BuilderFrameworkSupport.isBuilderBuildMethod(ExecutableElement)
) for a builderpublic boolean isToBuilderMethod(ExecutableElement candidateToBuilderElement)
BuilderFrameworkSupport
toBuilder
method on a type generated by the builder
framework.isToBuilderMethod
in interface BuilderFrameworkSupport
candidateToBuilderElement
- a methodtrue
if candidateToBuilderElement
is a toBuilder
method on a
type generated by the builder frameworkpublic void handleToBuilderMethod(AnnotatedTypeMirror.AnnotatedExecutableType toBuilderType)
BuilderFrameworkSupport
toBuilder
routine. Typically, the returned
Builder has had all of its required setters invoked. So, implementations of this method should
add a CalledMethods
annotation
capturing this fact.handleToBuilderMethod
in interface BuilderFrameworkSupport
toBuilderType
- the type of a method that is the toBuilder
method (as determined
by BuilderFrameworkSupport.isToBuilderMethod(ExecutableElement)
) for a type that has an associated builderpublic List<ExecutableElement> getAllAbstractMethods(TypeElement classElement)
classElement
- the class