public static interface AutoValueExtension.Context
Modifier and Type | Method and Description |
---|---|
java.util.Set<javax.lang.model.element.ExecutableElement> |
abstractMethods()
Returns the complete set of abstract methods defined in or inherited by the
@AutoValue class. |
javax.lang.model.element.TypeElement |
autoValueClass()
Returns the annotated class that this generation cycle is based on.
|
default java.util.Optional<AutoValueExtension.BuilderContext> |
builder()
Returns a representation of the
Builder associated with the @AutoValue class,
if there is one. |
default java.lang.String |
finalAutoValueClassName()
The fully-qualified name of the last class in the
AutoValue hierarchy. |
java.lang.String |
packageName()
Returns the package name of the classes to be generated.
|
javax.annotation.processing.ProcessingEnvironment |
processingEnvironment()
Returns the processing environment of this generation cycle.
|
java.util.Map<java.lang.String,javax.lang.model.element.ExecutableElement> |
properties()
Returns the ordered collection of properties to be generated by AutoValue.
|
default java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror> |
propertyTypes()
Returns the properties to be generated by AutoValue, with their types.
|
javax.annotation.processing.ProcessingEnvironment processingEnvironment()
ProcessingEnvironment.getMessager()
.java.lang.String packageName()
javax.lang.model.element.TypeElement autoValueClass()
Given @AutoValue public class Foo {...}
, this will be Foo
.
default java.lang.String finalAutoValueClassName()
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(com.google.auto.value.extension.AutoValueExtension.Context, java.lang.String, java.lang.String, boolean)
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.
java.util.Map<java.lang.String,javax.lang.model.element.ExecutableElement> properties()
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...
...then the type of theinterface Parent<T>
{ T bar(); }@AutoValue abstract class Foo implements Parent<String> {...}
bar
property in Foo
is actually String
, but
the ExecutableElement
will be the the method in Parent
, whose return type is
T
.default java.util.Map<java.lang.String,javax.lang.model.type.TypeMirror> propertyTypes()
@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.
java.util.Set<javax.lang.model.element.ExecutableElement> abstractMethods()
@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.default java.util.Optional<AutoValueExtension.BuilderContext> builder()
Builder
associated with the @AutoValue
class,
if there is one.
This method returns Optional.empty()
if called from within the AutoValueExtension.applicable(com.google.auto.value.extension.AutoValueExtension.Context)
method. If an Extension needs Builder
information to decide whether it is applicable,
it should return true
from the AutoValueExtension.applicable(com.google.auto.value.extension.AutoValueExtension.Context)
method and then return null
from the AutoValueExtension.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.
Copyright © 2021 Google LLC. All Rights Reserved.