@AutoService(value=AutoValueExtension.class) public final class ToPrettyStringExtension extends AutoValueExtension
ToPrettyString annotated methods in AutoValue types.AutoValueExtension.BuilderContext, AutoValueExtension.Context, AutoValueExtension.IncrementalExtensionType| Constructor and Description |
|---|
ToPrettyStringExtension() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
applicable(AutoValueExtension.Context context)
Determines whether this Extension applies to the given context.
|
com.google.common.collect.ImmutableSet<javax.lang.model.element.ExecutableElement> |
consumeMethods(AutoValueExtension.Context context)
Returns a possible empty set of abstract methods that this Extension intends to implement.
|
java.lang.String |
generateClass(AutoValueExtension.Context context,
java.lang.String className,
java.lang.String classToExtend,
boolean isFinal)
Returns the generated source code of the class named
className to extend classToExtend, or null if this extension does not generate a class in the hierarchy. |
AutoValueExtension.IncrementalExtensionType |
incrementalType(javax.annotation.processing.ProcessingEnvironment processingEnvironment)
Determines the incremental type of this Extension.
|
consumeProperties, getSupportedOptions, mustBeFinalpublic java.lang.String generateClass(AutoValueExtension.Context context, java.lang.String className, java.lang.String classToExtend, boolean isFinal)
AutoValueExtensionclassName to extend classToExtend, or null if this extension does not generate a class in the hierarchy.
If there is a generated class, it should be final if isFinal is true; otherwise it
should be abstract. The returned string should be a complete Java class definition of the class
className in the package context.packageName().
The returned string will typically look like this:
package <package>;
...
<finalOrAbstract> class <className> extends <classToExtend> {
// Constructor
<className>(<constructorParameters>) {
super(<constructorParameterNames>);
...
}
...
}
Here, <package> is AutoValueExtension.Context.packageName(); <finalOrAbstract> is the
keyword final if isFinal is true or abstract otherwise; and <className> and <classToExtend> are the values of this method's parameters of the same
name. The <constructorParameters> and <constructorParameterNames> are typically
derived from AutoValueExtension.Context.propertyTypes().
generateClass in class AutoValueExtensioncontext - The AutoValueExtension.Context of the code generation for this class.className - The simple name of the resulting class. The returned code will be written to a
file named accordingly.classToExtend - The simple name of the direct parent of the generated class. This could be
the AutoValue generated class, or a class generated as the result of another Extension.isFinal - True if this class is the last class in the chain, meaning it should be marked
as final. Otherwise it should be marked as abstract.null if this extension does not
generate a class in the hierarchy.public boolean applicable(AutoValueExtension.Context context)
AutoValueExtensionfalse for a given class, it will not be called again during the processing of that class. An
Extension can return true and still choose not to generate any code for the class, by
returning null from AutoValueExtension.generateClass(com.google.auto.value.extension.AutoValueExtension.Context, java.lang.String, java.lang.String, boolean). That is often a more flexible approach.applicable in class AutoValueExtensioncontext - The Context of the code generation for this class.public com.google.common.collect.ImmutableSet<javax.lang.model.element.ExecutableElement> consumeMethods(AutoValueExtension.Context context)
AutoValueExtensionEach returned method must be one of the abstract methods in AutoValueExtension.Context.abstractMethods().
For example, Android's Parcelable interface includes a method
void writeToParcel(Parcel, int). Normally AutoValue would not know what to do with that
abstract method. But an AutoValueExtension that understands Parcelable can
provide a useful implementation and return the writeToParcel method here. That will
prevent a warning about the method from AutoValue.
consumeMethods in class AutoValueExtensioncontext - the Context of the code generation for this class.public AutoValueExtension.IncrementalExtensionType incrementalType(javax.annotation.processing.ProcessingEnvironment processingEnvironment)
AutoValueExtensionThe ProcessingEnvironment can be used, among other things, to obtain the processor
options, using ProcessingEnvironment.getOptions().
The actual incremental type of the AutoValue processor as a whole will be the loosest
incremental types of the Extensions present in the annotation processor path. The default
returned value is AutoValueExtension.IncrementalExtensionType.UNKNOWN, which will disable incremental
annotation processing entirely.
incrementalType in class AutoValueExtensionCopyright © 2021 Google LLC. All Rights Reserved.