Top Fields Constructors Methods
com.google.auto.value.processor

pack-priv Class BuilderMethodClassifierForAutoBuilder

extends com.google.auto.value.processor.BuilderMethodClassifier<javax.lang.model.element.VariableElement>
Class Inheritance
Static Imports
com.google.auto.common.MoreStreams.toImmutableBiMap, .MoreStreams.toImmutableMap

Field Summary

Modifier and TypeField and Description
private final Executable
private final ImmutableBiMap<javax.lang.model.element.VariableElement, String>

Constructor Summary

AccessConstructor and Description
private
BuilderMethodClassifierForAutoBuilder(ErrorReporter errorReporter, javax.annotation.processing.ProcessingEnvironment processingEnv, Executable executable, javax.lang.model.type.TypeMirror builtType, javax.lang.model.element.TypeElement builderType, ImmutableBiMap<javax.lang.model.element.VariableElement, String> paramToPropertyName, ImmutableMap<String, javax.lang.model.type.TypeMirror> rewrittenPropertyTypes, ImmutableSet<String> propertiesWithDefaults, Nullables nullables)

Method Summary

Modifier and TypeMethod and Description
pack-priv String
autoWhat()

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.autoWhat.

A string describing what sort of Auto this is, "AutoValue" or "AutoBuilder".

pack-priv void
checkForFailedJavaBean(javax.lang.model.element.ExecutableElement rejectedSetter)

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.checkForFailedJavaBean.

Checks for failed JavaBean usage when a method that looks like a setter doesn't actually match anything, and emits a compiler Note if detected.

pack-priv static Optional<BuilderMethodClassifier<javax.lang.model.element.VariableElement>>

Returns:

an Optional that contains the results of the classification if it was successful or nothing if it was not.
classify
(Iterable<javax.lang.model.element.ExecutableElement>
the abstract methods in builderType and its ancestors.
methods
,
ErrorReporter
where to report errors.
errorReporter
,
javax.annotation.processing.ProcessingEnvironment
the ProcessingEnvironment for annotation processing.
processingEnv
,
Executable
the constructor or static method that AutoBuilder will call.
executable
,
javax.lang.model.type.TypeMirror
the type to be built.
builtType
,
javax.lang.model.element.TypeElement
the builder class or interface within ofClass.
builderType
,
ImmutableSet<String>
properties that have a default value, so it is not an error for them not to have a setter.
propertiesWithDefaults
,
Nullables nullables)

Classifies the given methods from a builder type and its ancestors.

pack-priv String
fooBuilderMustMatch()

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.fooBuilderMustMatch.

A string describing what a property builder for property foo must match, foo() or getFoo() for AutoValue, foo for AutoBuilder.

pack-priv String
getterMustMatch()

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.getterMustMatch.

A string describing what a builder getter must match: a property method for AutoValue, a parameter for AutoBuilder.

pack-priv javax.lang.model.type.TypeMirror
originalPropertyType(javax.lang.model.element.VariableElement propertyElement)

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.originalPropertyType.

Returns the property type as it appears on the original source program element.

pack-priv ImmutableBiMap<String, javax.lang.model.element.VariableElement>
propertyElements()

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.propertyElements.

Returns a map from property names to the corresponding source program elements.

pack-priv Optional<String>
propertyForBuilderGetter(javax.lang.model.element.ExecutableElement method)

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.propertyForBuilderGetter.

Returns the name of the property that the given no-arg builder method queries, if any.

pack-priv String
propertyString(javax.lang.model.element.VariableElement propertyElement)

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.propertyString.

A string identifying the given property element, which is a method for AutoValue or a parameter for AutoBuilder.

private static ImmutableMap<String, javax.lang.model.type.TypeMirror>
rewriteParameterTypes(Executable executable, javax.lang.model.element.TypeElement builderType, ErrorReporter errorReporter, javax.lang.model.util.Types typeUtils)

Inherited from com.google.auto.value.processor.BuilderMethodClassifier:
builderGettersbuilderMethodReturnTypebuildMethodsclassifyMethodspropertyNameToPropertyBuilderpropertyNameToSetters

Field Detail

executableback to summary
private final Executable executable
paramToPropertyNameback to summary
private final ImmutableBiMap<javax.lang.model.element.VariableElement, String> paramToPropertyName

Constructor Detail

BuilderMethodClassifierForAutoBuilderback to summary
private BuilderMethodClassifierForAutoBuilder(ErrorReporter errorReporter, javax.annotation.processing.ProcessingEnvironment processingEnv, Executable executable, javax.lang.model.type.TypeMirror builtType, javax.lang.model.element.TypeElement builderType, ImmutableBiMap<javax.lang.model.element.VariableElement, String> paramToPropertyName, ImmutableMap<String, javax.lang.model.type.TypeMirror> rewrittenPropertyTypes, ImmutableSet<String> propertiesWithDefaults, Nullables nullables)

Method Detail

autoWhatback to summary
pack-priv String autoWhat()

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.autoWhat.

Doc from com.google.auto.value.processor.BuilderMethodClassifier.autoWhat.

A string describing what sort of Auto this is, "AutoValue" or "AutoBuilder".

Annotations
@Override
checkForFailedJavaBeanback to summary
pack-priv void checkForFailedJavaBean(javax.lang.model.element.ExecutableElement rejectedSetter)

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.checkForFailedJavaBean.

Doc from com.google.auto.value.processor.BuilderMethodClassifier.checkForFailedJavaBean.

Checks for failed JavaBean usage when a method that looks like a setter doesn't actually match anything, and emits a compiler Note if detected. A frequent source of problems is where the JavaBeans conventions have been followed for most but not all getters. Then AutoValue considers that they haven't been followed at all, so you might have a property called getFoo where you thought it was called just foo, and you might not understand why your setter called setFoo is rejected (it would have to be called setGetFoo).

This is not relevant for AutoBuilder, which uses parameter names rather than getters. The parameter names are unambiguously the same as the property names.

Annotations
@Override
classifyback to summary
pack-priv static Optional<BuilderMethodClassifier<javax.lang.model.element.VariableElement>> classify(Iterable<javax.lang.model.element.ExecutableElement> methods, ErrorReporter errorReporter, javax.annotation.processing.ProcessingEnvironment processingEnv, Executable executable, javax.lang.model.type.TypeMirror builtType, javax.lang.model.element.TypeElement builderType, ImmutableSet<String> propertiesWithDefaults, Nullables nullables)

Classifies the given methods from a builder type and its ancestors.

Parameters
methods:Iterable<javax.lang.model.element.ExecutableElement>

the abstract methods in builderType and its ancestors.

errorReporter:ErrorReporter

where to report errors.

processingEnv:javax.annotation.processing.ProcessingEnvironment

the ProcessingEnvironment for annotation processing.

executable:Executable

the constructor or static method that AutoBuilder will call.

builtType:javax.lang.model.type.TypeMirror

the type to be built.

builderType:javax.lang.model.element.TypeElement

the builder class or interface within ofClass.

propertiesWithDefaults:ImmutableSet<String>

properties that have a default value, so it is not an error for them not to have a setter.

Returns:Optional<BuilderMethodClassifier<javax.lang.model.element.VariableElement>>

an Optional that contains the results of the classification if it was successful or nothing if it was not.

fooBuilderMustMatchback to summary
pack-priv String fooBuilderMustMatch()

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.fooBuilderMustMatch.

Doc from com.google.auto.value.processor.BuilderMethodClassifier.fooBuilderMustMatch.

A string describing what a property builder for property foo must match, foo() or getFoo() for AutoValue, foo for AutoBuilder.

Annotations
@Override
getterMustMatchback to summary
pack-priv String getterMustMatch()

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.getterMustMatch.

Doc from com.google.auto.value.processor.BuilderMethodClassifier.getterMustMatch.

A string describing what a builder getter must match: a property method for AutoValue, a parameter for AutoBuilder.

Annotations
@Override
originalPropertyTypeback to summary
pack-priv javax.lang.model.type.TypeMirror originalPropertyType(javax.lang.model.element.VariableElement propertyElement)

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.originalPropertyType.

Doc from com.google.auto.value.processor.BuilderMethodClassifier.originalPropertyType.

Returns the property type as it appears on the original source program element. This can be different from the type stored in rewrittenPropertyTypes since that one will refer to type variables in the builder rather than in the original class. Also, rewrittenPropertyTypes will not have type annotations even if they were present on the original element, so originalPropertyType is the right thing to use for those.

Annotations
@Override
propertyElementsback to summary
pack-priv ImmutableBiMap<String, javax.lang.model.element.VariableElement> propertyElements()

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.propertyElements.

Doc from com.google.auto.value.processor.BuilderMethodClassifier.propertyElements.

Returns a map from property names to the corresponding source program elements. For AutoValue, these elements are the abstract getter methods in the @AutoValue class. For AutoBuilder, they are the parameters of the constructor or method that the generated builder will call.

Annotations
@Override
propertyForBuilderGetterback to summary
pack-priv Optional<String> propertyForBuilderGetter(javax.lang.model.element.ExecutableElement method)

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.propertyForBuilderGetter.

Doc from com.google.auto.value.processor.BuilderMethodClassifier.propertyForBuilderGetter.

Returns the name of the property that the given no-arg builder method queries, if any. For example, if your @AutoValue class has a method abstract String getBar() then an abstract method in its builder with the same signature will query the bar property.

Annotations
@Override
propertyStringback to summary
pack-priv String propertyString(javax.lang.model.element.VariableElement propertyElement)

Implements abstract com.google.auto.value.processor.BuilderMethodClassifier.propertyString.

Doc from com.google.auto.value.processor.BuilderMethodClassifier.propertyString.

A string identifying the given property element, which is a method for AutoValue or a parameter for AutoBuilder.

Annotations
@Override
rewriteParameterTypesback to summary
private static ImmutableMap<String, javax.lang.model.type.TypeMirror> rewriteParameterTypes(Executable executable, javax.lang.model.element.TypeElement builderType, ErrorReporter errorReporter, javax.lang.model.util.Types typeUtils)