@AutoService(value=AutoValueExtension.class) public final class MemoizeExtension extends AutoValueExtension
Memoized
contract.Modifier and Type | Class and Description |
---|---|
(package private) static class |
MemoizeExtension.Generator |
AutoValueExtension.Context
Modifier and Type | Field and Description |
---|---|
private static com.google.common.collect.ImmutableSet<java.lang.String> |
DO_NOT_PULL_DOWN_ANNOTATIONS |
private static com.squareup.javapoet.AnnotationSpec |
GENERATED |
private static com.squareup.javapoet.ClassName |
LAZY_INIT |
Constructor and Description |
---|
MemoizeExtension() |
Modifier and Type | Method and Description |
---|---|
boolean |
applicable(AutoValueExtension.Context context)
Determines whether this Extension applies to the given context.
|
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. |
private static com.google.common.base.Optional<com.squareup.javapoet.AnnotationSpec> |
getLazyInitAnnotation(javax.lang.model.util.Elements elements)
Returns the errorprone
@LazyInit annotation if it is found on the classpath. |
private static com.google.common.collect.ImmutableSet<javax.lang.model.element.ExecutableElement> |
memoizedMethods(AutoValueExtension.Context context) |
consumeMethods, consumeProperties, mustBeFinal
private static final com.google.common.collect.ImmutableSet<java.lang.String> DO_NOT_PULL_DOWN_ANNOTATIONS
private static final com.squareup.javapoet.AnnotationSpec GENERATED
private static final com.squareup.javapoet.ClassName LAZY_INIT
public boolean applicable(AutoValueExtension.Context context)
AutoValueExtension
applicable
in class AutoValueExtension
context
- The Context of the code generation for this class.public java.lang.String generateClass(AutoValueExtension.Context context, java.lang.String className, java.lang.String classToExtend, boolean isFinal)
AutoValueExtension
className
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> {...}
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.
generateClass
in class AutoValueExtension
context
- 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.private static com.google.common.collect.ImmutableSet<javax.lang.model.element.ExecutableElement> memoizedMethods(AutoValueExtension.Context context)
private static com.google.common.base.Optional<com.squareup.javapoet.AnnotationSpec> getLazyInitAnnotation(javax.lang.model.util.Elements elements)
@LazyInit
annotation if it is found on the classpath.