Interface AutoValueExtension.Context
-
- Enclosing class:
- AutoValueExtension
public static interface AutoValueExtension.ContextThe context of the generation cycle.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description Set<ExecutableElement>abstractMethods()Returns the complete set of abstract methods defined in or inherited by the@AutoValueclass.TypeElementautoValueClass()Returns the annotated class that this generation cycle is based on.default Optional<AutoValueExtension.BuilderContext>builder()Returns a representation of theBuilderassociated with the@AutoValueclass, if there is one.Set<ExecutableElement>builderAbstractMethods()Returns the complete set of abstract methods defined in or inherited by the@Builderclass.default List<AnnotationMirror>classAnnotationsToCopy(TypeElement classToCopyFrom)Returns the complete list of annotations defined on theclassToCopyFromthat should be added to any generated subclass.default StringfinalAutoValueClassName()The fully-qualified name of the last class in theAutoValuehierarchy.default List<AnnotationMirror>methodAnnotationsToCopy(ExecutableElement method)Returns the complete list of annotations defined on themethodthat should be applied to any override of that method.StringpackageName()Returns the package name of the classes to be generated.ProcessingEnvironmentprocessingEnvironment()Returns the processing environment of this generation cycle.Map<String,ExecutableElement>properties()Returns the ordered collection of properties to be generated by AutoValue.default Map<String,TypeMirror>propertyTypes()Returns the properties to be generated by AutoValue, with their types.
-
-
-
Method Detail
-
processingEnvironment
ProcessingEnvironment processingEnvironment()
Returns the processing environment of this generation cycle. This can be used, among other things, to produce compilation warnings or errors, usingProcessingEnvironment.getMessager().
-
packageName
String packageName()
Returns the package name of the classes to be generated.
-
autoValueClass
TypeElement autoValueClass()
Returns the annotated class that this generation cycle is based on.Given
@AutoValue public class Foo {...}, this will beFoo.
-
finalAutoValueClassName
default String finalAutoValueClassName()
The fully-qualified name of the last class in theAutoValuehierarchy. For an@AutoValueclassfoo.bar.Baz, this will befoo.bar.AutoValue_Baz. The class may be generated by an extension, which will be the current extension if theisFinalparameter toAutoValueExtension.generateClass(com.google.auto.value.extension.AutoValueExtension.Context, java.lang.String, java.lang.String, boolean)is true and the returned string is notnull.For compatibility reasons, this method has a default implementation that throws an exception. The AutoValue processor supplies an implementation that behaves as documented.
-
properties
Map<String,ExecutableElement> 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 propertybaris defined byabstract String getBar()then this map will have an entry mapping"bar"to theExecutableElementforgetBar().To determine the type of a property, it is best to use
propertyTypes()rather than looking at the return type of theExecutableElementin this map. The reason is that the final type of the property might be different because of type variables. For example, if you have...
...then the type of theinterface Parent<T>{ T bar(); }@AutoValue abstract class Foo implements Parent<String> {...}barproperty inFoois actuallyString, but theExecutableElementwill be the the method inParent, whose return type isT.
-
propertyTypes
default Map<String,TypeMirror> 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@AutoValueproperties.For example, if property
baris defined byabstract String getBar()then this map will have an entry mapping"bar"to theTypeMirrorforString.For compatibility reasons, this method has a default implementation that throws an exception. The AutoValue processor supplies an implementation that behaves as documented.
-
abstractMethods
Set<ExecutableElement> abstractMethods()
Returns the complete set of abstract methods defined in or inherited by the@AutoValueclass. This includes all methods that define properties (likeabstract String getBar()), any abstracttoBuilder()method, and any other abstract method even if it has been consumed by this or another Extension.
-
builderAbstractMethods
Set<ExecutableElement> builderAbstractMethods()
Returns the complete set of abstract methods defined in or inherited by the@Builderclass. This includes methods that have been consumed by this or another Extension.If there is no builder class, then this set is empty.
-
classAnnotationsToCopy
default List<AnnotationMirror> classAnnotationsToCopy(TypeElement classToCopyFrom)
Returns the complete list of annotations defined on theclassToCopyFromthat should be added to any generated subclass. Only annotations visible to the@AutoValuewill be present. SeeAutoValue.CopyAnnotationsfor more information.The default implementation of this method returns an empty list for compatibility with extensions which may have implemented this interface themselves.
-
methodAnnotationsToCopy
default List<AnnotationMirror> methodAnnotationsToCopy(ExecutableElement method)
Returns the complete list of annotations defined on themethodthat should be applied to any override of that method. Only annotations visible to the@AutoValuewill be present. SeeAutoValue.CopyAnnotationsfor more information.The default implementation of this method returns an empty list for compatibility with extensions which may have implemented this interface themselves.
-
builder
default Optional<AutoValueExtension.BuilderContext> builder()
Returns a representation of theBuilderassociated with the@AutoValueclass, if there is one.This method returns
Optional.empty()if called from within theAutoValueExtension.applicable(com.google.auto.value.extension.AutoValueExtension.Context)method. If an Extension needsBuilderinformation to decide whether it is applicable, it should returntruefrom theAutoValueExtension.applicable(com.google.auto.value.extension.AutoValueExtension.Context)method and then returnnullfrom theAutoValueExtension.generateClass(com.google.auto.value.extension.AutoValueExtension.Context, java.lang.String, java.lang.String, boolean)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.
-
-