Class 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:
  • Field Details

    • extensions

      private com.google.common.collect.ImmutableList<AutoValueExtension> extensions
    • loaderForExtensions

      private final ClassLoader loaderForExtensions
  • Constructor Details

    • AutoValueProcessor

      public AutoValueProcessor()
    • AutoValueProcessor

      AutoValueProcessor(ClassLoader loaderForExtensions)
    • AutoValueProcessor

      public AutoValueProcessor(Iterable<? extends AutoValueExtension> extensions)
  • Method Details

    • init

      public void init(ProcessingEnvironment processingEnv)
      Specified by:
      init in interface Processor
      Overrides:
      init in class AutoValueOrOneOfProcessor
    • generatedSubclassName

      private static String generatedSubclassName(TypeElement type, int depth)
    • processType

      void processType(TypeElement type)
      Description copied from class: AutoValueOrOneOfProcessor
      Analyzes a single @AutoValue or @AutoOneOf class, and outputs the corresponding implementation class or classes.
      Specified by:
      processType in class AutoValueOrOneOfProcessor
      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

      private String extensionName(AutoValueExtension extension)
    • 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

      Optional<String> nullableAnnotationForMethod(ExecutableElement propertyMethod)
      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 returns Optional.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 class AutoValueOrOneOfProcessor
    • nullableAnnotationFor

      static Optional<String> nullableAnnotationFor(Element element, TypeMirror elementType)
      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 be Optional.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

      private static OptionalInt nullableAnnotationIndex(List<? extends AnnotationMirror> annotations)
    • isNullable

      private static boolean isNullable(AnnotationMirror annotation)
    • prefixedGettersIn

      static com.google.common.collect.ImmutableSet<ExecutableElement> prefixedGettersIn(Iterable<ExecutableElement> methods)
    • ancestorIsAutoValue

      private boolean ancestorIsAutoValue(TypeElement type)
    • implementsAnnotation

      private boolean implementsAnnotation(TypeElement type)
    • getTypeMirror

      private TypeMirror getTypeMirror(Class<?> c)
    • 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)