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

pack-priv Class BuilderMethodClassifierForAutoValue

extends com.google.auto.value.processor.BuilderMethodClassifier<javax.lang.model.element.ExecutableElement>
Class Inheritance
Static Imports
com.google.common.collect.Sets.difference

Field Summary

Modifier and TypeField and Description
private final javax.lang.model.type.TypeMirror
private final ErrorReporter
private final ImmutableMap<String, javax.lang.model.element.ExecutableElement>
private final ImmutableBiMap<javax.lang.model.element.ExecutableElement, String>

Constructor Summary

AccessConstructor and Description
private
BuilderMethodClassifierForAutoValue(ErrorReporter errorReporter, javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.type.TypeMirror builtType, javax.lang.model.element.TypeElement builderType, ImmutableBiMap<javax.lang.model.element.ExecutableElement, String> getterToPropertyName, ImmutableMap<String, javax.lang.model.type.TypeMirror> rewrittenPropertyTypes, 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.ExecutableElement>>

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
,
javax.lang.model.element.TypeElement
the AutoValue class containing the builder.
autoValueClass
,
javax.lang.model.element.TypeElement
the builder class or interface within autoValueClass.
builderType
,
ImmutableBiMap<javax.lang.model.element.ExecutableElement, String>
a map from getter methods to the properties they get.
getterToPropertyName
,
ImmutableMap<String, javax.lang.model.type.TypeMirror>
a map from property names to types. The types here use type parameters from the builder class (if any) rather than from the AutoValue class, even though the getter methods are in the latter.
rewrittenPropertyTypes
,
Nullables nullables, boolean
true if the containing @AutoValue class has a toBuilder() method.
autoValueHasToBuilder
)

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.ExecutableElement 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.ExecutableElement>
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.ExecutableElement 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.

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

Field Detail

builtTypeback to summary
private final javax.lang.model.type.TypeMirror builtType

Hides com.google.auto.value.processor.BuilderMethodClassifier.builtType.

errorReporterback to summary
private final ErrorReporter errorReporter

Hides com.google.auto.value.processor.BuilderMethodClassifier.errorReporter.

getterNameToGetterback to summary
private final ImmutableMap<String, javax.lang.model.element.ExecutableElement> getterNameToGetter
getterToPropertyNameback to summary
private final ImmutableBiMap<javax.lang.model.element.ExecutableElement, String> getterToPropertyName

Constructor Detail

BuilderMethodClassifierForAutoValueback to summary
private BuilderMethodClassifierForAutoValue(ErrorReporter errorReporter, javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.type.TypeMirror builtType, javax.lang.model.element.TypeElement builderType, ImmutableBiMap<javax.lang.model.element.ExecutableElement, String> getterToPropertyName, ImmutableMap<String, javax.lang.model.type.TypeMirror> rewrittenPropertyTypes, 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.ExecutableElement>> classify(Iterable<javax.lang.model.element.ExecutableElement> methods, ErrorReporter errorReporter, javax.annotation.processing.ProcessingEnvironment processingEnv, javax.lang.model.element.TypeElement autoValueClass, javax.lang.model.element.TypeElement builderType, ImmutableBiMap<javax.lang.model.element.ExecutableElement, String> getterToPropertyName, ImmutableMap<String, javax.lang.model.type.TypeMirror> rewrittenPropertyTypes, Nullables nullables, boolean autoValueHasToBuilder)

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.

autoValueClass:javax.lang.model.element.TypeElement

the AutoValue class containing the builder.

builderType:javax.lang.model.element.TypeElement

the builder class or interface within autoValueClass.

getterToPropertyName:ImmutableBiMap<javax.lang.model.element.ExecutableElement, String>

a map from getter methods to the properties they get.

rewrittenPropertyTypes:ImmutableMap<String, javax.lang.model.type.TypeMirror>

a map from property names to types. The types here use type parameters from the builder class (if any) rather than from the AutoValue class, even though the getter methods are in the latter.

autoValueHasToBuilder:boolean

true if the containing @AutoValue class has a toBuilder() method.

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

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.ExecutableElement 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.ExecutableElement> 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.ExecutableElement 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