Class MemoizeExtension
- java.lang.Object
-
- com.google.auto.value.extension.AutoValueExtension
-
- com.google.auto.value.extension.memoized.processor.MemoizeExtension
-
@AutoService(AutoValueExtension.class) public final class MemoizeExtension extends AutoValueExtension
An extension that implements theMemoized
contract.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
MemoizeExtension.Generator
-
Nested classes/interfaces inherited from class com.google.auto.value.extension.AutoValueExtension
AutoValueExtension.Context
-
-
Field Summary
Fields Modifier and Type Field Description private static com.google.common.collect.ImmutableSet<java.lang.String>
DO_NOT_PULL_DOWN_ANNOTATIONS
private static com.squareup.javapoet.ClassName
LAZY_INIT
private static com.squareup.javapoet.AnnotationSpec
SUPPRESS_WARNINGS
-
Constructor Summary
Constructors Constructor Description MemoizeExtension()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method 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 namedclassName
to extendclassToExtend
, ornull
if this extension does not generate a class in the hierarchy.private static java.util.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)
-
Methods inherited from class com.google.auto.value.extension.AutoValueExtension
consumeMethods, consumeProperties, mustBeFinal
-
-
-
-
Field Detail
-
DO_NOT_PULL_DOWN_ANNOTATIONS
private static final com.google.common.collect.ImmutableSet<java.lang.String> DO_NOT_PULL_DOWN_ANNOTATIONS
-
LAZY_INIT
private static final com.squareup.javapoet.ClassName LAZY_INIT
-
SUPPRESS_WARNINGS
private static final com.squareup.javapoet.AnnotationSpec SUPPRESS_WARNINGS
-
-
Method Detail
-
applicable
public boolean applicable(AutoValueExtension.Context context)
Description copied from class:AutoValueExtension
Determines whether this Extension applies to the given context.- Overrides:
applicable
in classAutoValueExtension
- Parameters:
context
- The Context of the code generation for this class.- Returns:
- true if this Extension should be applied in the given context. If an Extension returns false for a given class, it will not be called again during the processing of that class.
-
generateClass
public java.lang.String generateClass(AutoValueExtension.Context context, java.lang.String className, java.lang.String classToExtend, boolean isFinal)
Description copied from class:AutoValueExtension
Returns the generated source code of the class namedclassName
to extendclassToExtend
, ornull
if this extension does not generate a class in the hierarchy. If there is a generated class, it should be final ifisFinal
is true; otherwise it should be abstract. The returned string should be a complete Java class definition of the classclassName
in the packagecontext.packageName()
.The returned string will typically look like this:
package <package>; ... <finalOrAbstract> class <className> extends <classToExtend> {...}
Here,
<package>
isAutoValueExtension.Context.packageName()
;<finalOrAbstract>
is the keywordfinal
ifisFinal
is true orabstract
otherwise; and<className>
and<classToExtend>
are the values of this method's parameters of the same name.- Specified by:
generateClass
in classAutoValueExtension
- Parameters:
context
- TheAutoValueExtension.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.- Returns:
- The source code of the generated class, or
null
if this extension does not generate a class in the hierarchy.
-
memoizedMethods
private static com.google.common.collect.ImmutableSet<javax.lang.model.element.ExecutableElement> memoizedMethods(AutoValueExtension.Context context)
-
getLazyInitAnnotation
private static java.util.Optional<com.squareup.javapoet.AnnotationSpec> getLazyInitAnnotation(javax.lang.model.util.Elements elements)
Returns the errorprone@LazyInit
annotation if it is found on the classpath.
-
-