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

pack-priv Class ExtensionContext

extends Object
implements Context
Class Inheritance
All Implemented Interfaces
com.google.auto.value.extension.AutoValueExtension.Context
Static Imports
com.google.auto.value.processor.ClassNames.COPY_ANNOTATIONS_NAME

Field Summary

Modifier and TypeField and Description
private final ImmutableSet<javax.lang.model.element.ExecutableElement>
private final javax.lang.model.element.TypeElement
private Optional<AutoValueExtension.BuilderContext>
private final javax.annotation.processing.ProcessingEnvironment
private final ImmutableMap<String, javax.lang.model.element.ExecutableElement>
private final ImmutableMap<String, javax.lang.model.type.TypeMirror>

Constructor Summary

AccessConstructor and Description
pack-priv
ExtensionContext(javax.annotation.processing.ProcessingEnvironment processingEnvironment, javax.lang.model.element.TypeElement autoValueClass, ImmutableMap<String, javax.lang.model.element.ExecutableElement> properties, ImmutableMap<javax.lang.model.element.ExecutableElement, javax.lang.model.type.TypeMirror> propertyMethodsAndTypes, ImmutableSet<javax.lang.model.element.ExecutableElement> abstractMethods)

Method Summary

Modifier and TypeMethod and Description
public Set<javax.lang.model.element.ExecutableElement>
abstractMethods()

Implements com.google.auto.value.extension.AutoValueExtension.Context.abstractMethods.

Returns the complete set of abstract methods defined in or inherited by the @AutoValue class.

public javax.lang.model.element.TypeElement
autoValueClass()

Implements com.google.auto.value.extension.AutoValueExtension.Context.autoValueClass.

Returns the annotated class that this generation cycle is based on.

public Optional<AutoValueExtension.BuilderContext>
builder()

Overrides default com.google.auto.value.extension.AutoValueExtension.Context.builder.

Returns a representation of the Builder associated with the @AutoValue class, if there is one.

public List<javax.lang.model.element.AnnotationMirror>
classAnnotationsToCopy(javax.lang.model.element.TypeElement classToCopyFrom)

Overrides default com.google.auto.value.extension.AutoValueExtension.Context.classAnnotationsToCopy.

Returns the complete list of annotations defined on the classToCopyFrom that should be added to any generated subclass.

public String
finalAutoValueClassName()

Overrides default com.google.auto.value.extension.AutoValueExtension.Context.finalAutoValueClassName.

The fully-qualified name of the last class in the AutoValue hierarchy.

public List<javax.lang.model.element.AnnotationMirror>
methodAnnotationsToCopy(javax.lang.model.element.ExecutableElement method)

Overrides default com.google.auto.value.extension.AutoValueExtension.Context.methodAnnotationsToCopy.

Returns the complete list of annotations defined on the method that should be applied to any override of that method.

public String
packageName()

Implements com.google.auto.value.extension.AutoValueExtension.Context.packageName.

Returns the package name of the classes to be generated.

public javax.annotation.processing.ProcessingEnvironment
processingEnvironment()

Implements com.google.auto.value.extension.AutoValueExtension.Context.processingEnvironment.

Returns the processing environment of this generation cycle.

public Map<String, javax.lang.model.element.ExecutableElement>
properties()

Implements com.google.auto.value.extension.AutoValueExtension.Context.properties.

Returns the ordered collection of properties to be generated by AutoValue.

public Map<String, javax.lang.model.type.TypeMirror>
propertyTypes()

Overrides default com.google.auto.value.extension.AutoValueExtension.Context.propertyTypes.

Returns the properties to be generated by AutoValue, with their types.

pack-priv void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

abstractMethodsback to summary
private final ImmutableSet<javax.lang.model.element.ExecutableElement> abstractMethods
autoValueClassback to summary
private final javax.lang.model.element.TypeElement autoValueClass
builderContextback to summary
private Optional<AutoValueExtension.BuilderContext> builderContext
processingEnvironmentback to summary
private final javax.annotation.processing.ProcessingEnvironment processingEnvironment
propertiesback to summary
private final ImmutableMap<String, javax.lang.model.element.ExecutableElement> properties
propertyTypesback to summary
private final ImmutableMap<String, javax.lang.model.type.TypeMirror> propertyTypes

Constructor Detail

ExtensionContextback to summary
pack-priv ExtensionContext(javax.annotation.processing.ProcessingEnvironment processingEnvironment, javax.lang.model.element.TypeElement autoValueClass, ImmutableMap<String, javax.lang.model.element.ExecutableElement> properties, ImmutableMap<javax.lang.model.element.ExecutableElement, javax.lang.model.type.TypeMirror> propertyMethodsAndTypes, ImmutableSet<javax.lang.model.element.ExecutableElement> abstractMethods)

Method Detail

abstractMethodsback to summary
public Set<javax.lang.model.element.ExecutableElement> abstractMethods()

Implements com.google.auto.value.extension.AutoValueExtension.Context.abstractMethods.

Doc from com.google.auto.value.extension.AutoValueExtension.Context.abstractMethods.

Returns the complete set of abstract methods defined in or inherited by the @AutoValue class. This includes all methods that define properties (like abstract String getBar()), any abstract toBuilder() method, and any other abstract method even if it has been consumed by this or another Extension.

Annotations
@Override
autoValueClassback to summary
public javax.lang.model.element.TypeElement autoValueClass()

Implements com.google.auto.value.extension.AutoValueExtension.Context.autoValueClass.

Doc from com.google.auto.value.extension.AutoValueExtension.Context.autoValueClass.

Returns the annotated class that this generation cycle is based on.

Given @AutoValue public class Foo {...}, this will be Foo.

Annotations
@Override
builderback to summary
public Optional<AutoValueExtension.BuilderContext> builder()

Overrides default com.google.auto.value.extension.AutoValueExtension.Context.builder.

Doc from com.google.auto.value.extension.AutoValueExtension.Context.builder.

Returns a representation of the Builder associated with the @AutoValue class, if there is one.

This method returns Optional#empty() if called from within the applicable method. If an Extension needs Builder information to decide whether it is applicable, it should return true from the applicable method and then return null from the generateClass method if it does not need to generate a class after all.

The default implementation of this method returns Optional#empty() for compatibility with extensions which may have implemented this interface themselves.

Annotations
@Override
classAnnotationsToCopyback to summary
public List<javax.lang.model.element.AnnotationMirror> classAnnotationsToCopy(javax.lang.model.element.TypeElement classToCopyFrom)

Overrides default com.google.auto.value.extension.AutoValueExtension.Context.classAnnotationsToCopy.

Doc from com.google.auto.value.extension.AutoValueExtension.Context.classAnnotationsToCopy.

Returns the complete list of annotations defined on the classToCopyFrom that should be added to any generated subclass. Only annotations visible to the @AutoValue will be present. See AutoValue.CopyAnnotations for more information.

The default implementation of this method returns an empty list for compatibility with extensions which may have implemented this interface themselves.

Annotations
@Override
finalAutoValueClassNameback to summary
public String finalAutoValueClassName()

Overrides default com.google.auto.value.extension.AutoValueExtension.Context.finalAutoValueClassName.

Doc from com.google.auto.value.extension.AutoValueExtension.Context.finalAutoValueClassName.

The fully-qualified name of the last class in the AutoValue hierarchy. For an @AutoValue class foo.bar.Baz, this will be foo.bar.AutoValue_Baz. The class may be generated by an extension, which will be the current extension if the isFinal parameter to AutoValueExtension#generateClass is true and the returned string is not null.

For compatibility reasons, this method has a default implementation that throws an exception. The AutoValue processor supplies an implementation that behaves as documented.

Annotations
@Override
methodAnnotationsToCopyback to summary
public List<javax.lang.model.element.AnnotationMirror> methodAnnotationsToCopy(javax.lang.model.element.ExecutableElement method)

Overrides default com.google.auto.value.extension.AutoValueExtension.Context.methodAnnotationsToCopy.

Doc from com.google.auto.value.extension.AutoValueExtension.Context.methodAnnotationsToCopy.

Returns the complete list of annotations defined on the method that should be applied to any override of that method. Only annotations visible to the @AutoValue will be present. See AutoValue.CopyAnnotations for more information.

The default implementation of this method returns an empty list for compatibility with extensions which may have implemented this interface themselves.

Annotations
@Override
packageNameback to summary
public String packageName()

Implements com.google.auto.value.extension.AutoValueExtension.Context.packageName.

Doc from com.google.auto.value.extension.AutoValueExtension.Context.packageName.

Returns the package name of the classes to be generated.

Annotations
@Override
processingEnvironmentback to summary
public javax.annotation.processing.ProcessingEnvironment processingEnvironment()

Implements com.google.auto.value.extension.AutoValueExtension.Context.processingEnvironment.

Doc from com.google.auto.value.extension.AutoValueExtension.Context.processingEnvironment.

Returns the processing environment of this generation cycle. This can be used, among other things, to produce compilation warnings or errors, using ProcessingEnvironment#getMessager().

Annotations
@Override
propertiesback to summary
public Map<String, javax.lang.model.element.ExecutableElement> properties()

Implements com.google.auto.value.extension.AutoValueExtension.Context.properties.

Doc from com.google.auto.value.extension.AutoValueExtension.Context.properties.

Returns the ordered collection of properties to be generated by AutoValue. Each key is a property name, and the corresponding value is the getter method for that property. For example, if property bar is defined by abstract String getBar() then this map will have an entry mapping "bar" to the ExecutableElement for getBar().

To determine the type of a property, it is best to use propertyTypes() rather than looking at the return type of the ExecutableElement in this map. The reason is that the final type of the property might be different because of type variables. For example, if you have...

  interface Parent<T> {
    T bar();
  }
 @AutoValue abstract class Foo implements Parent<String> {...}
...then the type of the bar property in Foo is actually String, but the ExecutableElement will be the the method in Parent, whose return type is T.
Annotations
@Override
propertyTypesback to summary
public Map<String, javax.lang.model.type.TypeMirror> propertyTypes()

Overrides default com.google.auto.value.extension.AutoValueExtension.Context.propertyTypes.

Doc from com.google.auto.value.extension.AutoValueExtension.Context.propertyTypes.

Returns the properties to be generated by AutoValue, with their types. Each key is a property name, and the corresponding value is the type of that property. The order of the map entries is the same as the order of the @AutoValue properties.

For example, if property bar is defined by abstract String getBar() then this map will have an entry mapping "bar" to the TypeMirror for String.

For compatibility reasons, this method has a default implementation that throws an exception. The AutoValue processor supplies an implementation that behaves as documented.

Annotations
@Override
setBuilderContextback to summary
pack-priv void setBuilderContext(AutoValueExtension.BuilderContext builderContext)