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 ClassLoader
Fields inherited from class javax.annotation.processing.AbstractProcessor
processingEnv
-
Constructor Summary
ConstructorsConstructorDescriptionAutoValueProcessor
(ClassLoader loaderForExtensions) AutoValueProcessor
(Iterable<? extends AutoValueExtension> extensions) -
Method Summary
Modifier and TypeMethodDescriptionprivate boolean
private com.google.common.collect.ImmutableList<AutoValueExtension>
applicableExtensions
(TypeElement type, ExtensionContext context) 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) private String
extensionName
(AutoValueExtension extension) private static String
generatedSubclassName
(TypeElement type, int depth) private TypeMirror
getTypeMirror
(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 boolean
void
init
(ProcessingEnvironment processingEnv) private static boolean
isNullable
(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@Nullable
annotation to put on the implementation of the given property method, and indicates whether the property is in fact nullable.private static OptionalInt
nullableAnnotationIndex
(List<? extends AnnotationMirror> annotations) (package private) static com.google.common.collect.ImmutableSet<ExecutableElement>
prefixedGettersIn
(Iterable<ExecutableElement> methods) (package private) void
processType
(TypeElement type) Analyzes a single@AutoValue
or@AutoOneOf
class, and outputs the corresponding implementation class or classes.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) private int
writeExtensions
(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, writeSourceFile
Methods 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:
init
in interfaceProcessor
- Overrides:
init
in classAutoValueOrOneOfProcessor
-
generatedSubclassName
-
processType
Description copied from class:AutoValueOrOneOfProcessor
Analyzes a single@AutoValue
or@AutoOneOf
class, and outputs the corresponding implementation class or classes.- Specified by:
processType
in classAutoValueOrOneOfProcessor
- Parameters:
type
- the class with the@AutoValue
or@AutoOneOf
annotation.
-
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:AutoValueOrOneOfProcessor
Returns the appropriate@Nullable
annotation 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@Nullable
annotation will instead appear when the return type of the method is spelled out in the implementation.- Specified by:
nullableAnnotationForMethod
in 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)
-