Package com.google.auto.value.processor
Class AutoValueProcessor
java.lang.Object
javax.annotation.processing.AbstractProcessor
com.google.auto.value.processor.AutoValueOrOneOfProcessor
com.google.auto.value.processor.AutoValueProcessor
- All Implemented Interfaces:
Processor
@AutoService(javax.annotation.processing.Processor.class)
@SupportedAnnotationTypes("com.google.auto.value.AutoValue")
@SupportedOptions("com.google.auto.value.OmitIdentifiers")
public class AutoValueProcessor
extends AutoValueOrOneOfProcessor
Javac annotation processor (compiler plugin) for value types; user code never references this
class.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.google.auto.value.processor.AutoValueOrOneOfProcessor
AutoValueOrOneOfProcessor.ObjectMethod, AutoValueOrOneOfProcessor.Property -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate com.google.common.collect.ImmutableList<AutoValueExtension> private final ClassLoaderFields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv -
Constructor Summary
ConstructorsConstructorDescriptionAutoValueProcessor(ClassLoader loaderForExtensions) AutoValueProcessor(Iterable<? extends AutoValueExtension> extensions) -
Method Summary
Modifier and TypeMethodDescriptionprivate booleanprivate com.google.common.collect.ImmutableList<AutoValueExtension> applicableExtensions(TypeElement type, ExtensionContext context) private voiddefineVarsForType(TypeElement type, AutoValueTemplateVars vars, com.google.common.collect.ImmutableSet<ExecutableElement> toBuilderMethods, com.google.common.collect.ImmutableSet<ExecutableElement> propertyMethods, Optional<BuilderSpec.Builder> builder) private StringextensionName(AutoValueExtension extension) private static StringgeneratedSubclassName(TypeElement type, int depth) private TypeMirrorgetTypeMirror(Class<?> c) private static <E> com.google.common.collect.ImmutableSet<E> immutableSetDifference(com.google.common.collect.ImmutableSet<E> a, com.google.common.collect.ImmutableSet<E> b) private booleanvoidinit(ProcessingEnvironment processingEnv) private static booleanisNullable(AnnotationMirror annotation) private com.google.common.collect.ImmutableSet<ExecutableElement> methodsConsumedByExtensions(TypeElement type, com.google.common.collect.ImmutableList<AutoValueExtension> applicableExtensions, ExtensionContext context, com.google.common.collect.ImmutableSet<ExecutableElement> abstractMethods, com.google.common.collect.ImmutableBiMap<String, ExecutableElement> properties) nullableAnnotationFor(Element element, TypeMirror elementType) Returns an appropriate annotation spelling to indicate the nullability of an element.nullableAnnotationForMethod(ExecutableElement propertyMethod) Returns the appropriate@Nullableannotation to put on the implementation of the given property method, and indicates whether the property is in fact nullable.private static OptionalIntnullableAnnotationIndex(List<? extends AnnotationMirror> annotations) (package private) static com.google.common.collect.ImmutableSet<ExecutableElement> prefixedGettersIn(Iterable<ExecutableElement> methods) (package private) voidprocessType(TypeElement type) Analyzes a single@AutoValueor@AutoOneOfclass, and outputs the corresponding implementation class or classes.private voidvalidateMethods(TypeElement type, com.google.common.collect.ImmutableSet<ExecutableElement> abstractMethods, com.google.common.collect.ImmutableSet<ExecutableElement> toBuilderMethods, com.google.common.collect.ImmutableSet<ExecutableElement> propertyMethods, boolean extensionsPresent) private intwriteExtensions(TypeElement type, ExtensionContext context, com.google.common.collect.ImmutableList<AutoValueExtension> applicableExtensions) Methods inherited from class com.google.auto.value.processor.AutoValueOrOneOfProcessor
abstractMethodsIn, annotationsToCopy, annotationStrings, checkModifiersIfNested, checkReturnType, defineSharedVarsForType, elementUtils, equalsParameterType, errorReporter, fixReservedIdentifiers, generatedClassName, getAnnotationMirror, getSerialVersionUID, getSupportedSourceVersion, hasAnnotationMirror, objectMethodToOverride, process, propertyMethodAnnotationMap, propertyMethodsIn, propertyNameToMethodMap, propertySet, typeUtils, writeSourceFileMethods inherited from class javax.annotation.processing.AbstractProcessor
getCompletions, getSupportedAnnotationTypes, getSupportedOptions, isInitialized
-
Field Details
-
extensions
-
loaderForExtensions
-
-
Constructor Details
-
AutoValueProcessor
public AutoValueProcessor() -
AutoValueProcessor
AutoValueProcessor(ClassLoader loaderForExtensions) -
AutoValueProcessor
-
-
Method Details
-
init
- Specified by:
initin interfaceProcessor- Overrides:
initin classAutoValueOrOneOfProcessor
-
generatedSubclassName
-
processType
Description copied from class:AutoValueOrOneOfProcessorAnalyzes a single@AutoValueor@AutoOneOfclass, and outputs the corresponding implementation class or classes.- Specified by:
processTypein classAutoValueOrOneOfProcessor- Parameters:
type- the class with the@AutoValueor@AutoOneOfannotation.
-
writeExtensions
private int writeExtensions(TypeElement type, ExtensionContext context, com.google.common.collect.ImmutableList<AutoValueExtension> applicableExtensions) -
applicableExtensions
private com.google.common.collect.ImmutableList<AutoValueExtension> applicableExtensions(TypeElement type, ExtensionContext context) -
methodsConsumedByExtensions
private com.google.common.collect.ImmutableSet<ExecutableElement> methodsConsumedByExtensions(TypeElement type, com.google.common.collect.ImmutableList<AutoValueExtension> applicableExtensions, ExtensionContext context, com.google.common.collect.ImmutableSet<ExecutableElement> abstractMethods, com.google.common.collect.ImmutableBiMap<String, ExecutableElement> properties) -
validateMethods
private void validateMethods(TypeElement type, com.google.common.collect.ImmutableSet<ExecutableElement> abstractMethods, com.google.common.collect.ImmutableSet<ExecutableElement> toBuilderMethods, com.google.common.collect.ImmutableSet<ExecutableElement> propertyMethods, boolean extensionsPresent) -
extensionName
-
defineVarsForType
private void defineVarsForType(TypeElement type, AutoValueTemplateVars vars, com.google.common.collect.ImmutableSet<ExecutableElement> toBuilderMethods, com.google.common.collect.ImmutableSet<ExecutableElement> propertyMethods, Optional<BuilderSpec.Builder> builder) -
nullableAnnotationForMethod
Description copied from class:AutoValueOrOneOfProcessorReturns the appropriate@Nullableannotation to put on the implementation of the given property method, and indicates whether the property is in fact nullable. The annotation in question is on the method, not its return type. If instead the return type is@Nullable, this method returnsOptional.of(""), to indicate that the property is nullable but the method isn't. The@Nullableannotation will instead appear when the return type of the method is spelled out in the implementation.- Specified by:
nullableAnnotationForMethodin classAutoValueOrOneOfProcessor
-
nullableAnnotationFor
Returns an appropriate annotation spelling to indicate the nullability of an element. If the return value is a non-empty Optional, that indicates that the element is nullable, and the string should be used to annotate it. If the return value is an empty Optional, the element is not nullable. The return value can beOptional.of(""), which indicates that the element is nullable but that the nullability comes from a type annotation. In this case, the annotation will appear when the type is written, and must not be specified again. If the Optional contains a present non-empty string then that string will end with a space.- Parameters:
element- the element that might be@Nullable, either a method or a parameter.elementType- the relevant type of the element: the return type for a method, or the parameter type for a parameter.
-
nullableAnnotationIndex
-
isNullable
-
prefixedGettersIn
static com.google.common.collect.ImmutableSet<ExecutableElement> prefixedGettersIn(Iterable<ExecutableElement> methods) -
ancestorIsAutoValue
-
implementsAnnotation
-
getTypeMirror
-
immutableSetDifference
private static <E> com.google.common.collect.ImmutableSet<E> immutableSetDifference(com.google.common.collect.ImmutableSet<E> a, com.google.common.collect.ImmutableSet<E> b)
-