Class ToPrettyStringExtension
- java.lang.Object
-
- com.google.auto.value.extension.AutoValueExtension
-
- com.google.auto.value.extension.toprettystring.processor.ToPrettyStringExtension
-
@AutoService(AutoValueExtension.class) public final class ToPrettyStringExtension extends AutoValueExtension
Generates implementations ofToPrettyStringannotated methods inAutoValuetypes.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.google.auto.value.extension.AutoValueExtension
AutoValueExtension.BuilderContext, AutoValueExtension.Context, AutoValueExtension.IncrementalExtensionType
-
-
Constructor Summary
Constructors Constructor Description ToPrettyStringExtension()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanapplicable(AutoValueExtension.Context context)Determines whether this Extension applies to the given context.com.google.common.collect.ImmutableSet<ExecutableElement>consumeMethods(AutoValueExtension.Context context)Returns a possible empty set of abstract methods that this Extension intends to implement.StringgenerateClass(AutoValueExtension.Context context, String className, String classToExtend, boolean isFinal)Returns the generated source code of the class namedclassNameto extendclassToExtend, ornullif this extension does not generate a class in the hierarchy.AutoValueExtension.IncrementalExtensionTypeincrementalType(ProcessingEnvironment processingEnvironment)Determines the incremental type of this Extension.-
Methods inherited from class com.google.auto.value.extension.AutoValueExtension
consumeProperties, getSupportedOptions, mustBeFinal
-
-
-
-
Method Detail
-
generateClass
public String generateClass(AutoValueExtension.Context context, String className, String classToExtend, boolean isFinal)
Description copied from class:AutoValueExtensionReturns the generated source code of the class namedclassNameto extendclassToExtend, ornullif this extension does not generate a class in the hierarchy. If there is a generated class, it should be final ifisFinalis true; otherwise it should be abstract. The returned string should be a complete Java class definition of the classclassNamein the packagecontext.packageName().The returned string will typically look like this:
package <package>; ... <finalOrAbstract> class <className> extends <classToExtend> { // Constructor <className>(<constructorParameters>) { super(<constructorParameterNames>); ... } ... }Here,
<package>isAutoValueExtension.Context.packageName();<finalOrAbstract>is the keywordfinalifisFinalis true orabstractotherwise; and<className>and<classToExtend>are the values of this method's parameters of the same name. The<constructorParameters>and<constructorParameterNames>are typically derived fromAutoValueExtension.Context.propertyTypes().- Specified by:
generateClassin classAutoValueExtension- Parameters:
context- TheAutoValueExtension.Contextof 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.- Returns:
- The source code of the generated class, or
nullif this extension does not generate a class in the hierarchy.
-
applicable
public boolean applicable(AutoValueExtension.Context context)
Description copied from class:AutoValueExtensionDetermines whether this Extension applies to the given context. If an Extension returnsfalsefor a given class, it will not be called again during the processing of that class. An Extension can returntrueand still choose not to generate any code for the class, by returningnullfromAutoValueExtension.generateClass(com.google.auto.value.extension.AutoValueExtension.Context, java.lang.String, java.lang.String, boolean). That is often a more flexible approach.- Overrides:
applicablein classAutoValueExtension- Parameters:
context- The Context of the code generation for this class.
-
consumeMethods
public com.google.common.collect.ImmutableSet<ExecutableElement> consumeMethods(AutoValueExtension.Context context)
Description copied from class:AutoValueExtensionReturns a possible empty set of abstract methods that this Extension intends to implement. This will prevent AutoValue from generating an implementation, in cases where it would have, and it will also avoid warnings about abstract methods that AutoValue doesn't expect. The default set returned by this method is empty.Each returned method must be one of the abstract methods in
AutoValueExtension.Context.abstractMethods().For example, Android's
Parcelableinterface includes a methodvoid writeToParcel(Parcel, int). Normally AutoValue would not know what to do with that abstract method. But anAutoValueExtensionthat understandsParcelablecan provide a useful implementation and return thewriteToParcelmethod here. That will prevent a warning about the method from AutoValue.- Overrides:
consumeMethodsin classAutoValueExtension- Parameters:
context- the Context of the code generation for this class.
-
incrementalType
public AutoValueExtension.IncrementalExtensionType incrementalType(ProcessingEnvironment processingEnvironment)
Description copied from class:AutoValueExtensionDetermines the incremental type of this Extension.The
ProcessingEnvironmentcan be used, among other things, to obtain the processor options, usingProcessingEnvironment.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.- Overrides:
incrementalTypein classAutoValueExtension
-
-