Class AutoAnnotationProcessor
java.lang.Object
javax.annotation.processing.AbstractProcessor
com.google.auto.value.processor.AutoAnnotationProcessor
- All Implemented Interfaces:
Processor
@AutoService(Processor.class)
@SupportedAnnotationTypes("com.google.auto.value.AutoAnnotation")
public class AutoAnnotationProcessor
extends AbstractProcessor
Javac annotation processor (compiler plugin) to generate annotation implementations. User code
never references this class.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic class -
Field Summary
FieldsFields inherited from class AbstractProcessor
processingEnv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate AbortProcessingExceptionabortWithError(String msg, Element e) Issue a compilation error and return an exception that, when thrown, will cause the processing of this class to be abandoned.private booleancompatibleTypes(TypeMirror parameterType, TypeMirror memberType) Returns true ifparameterTypecan be used to provide the value of an annotation member of typememberType.private static StringfullyQualifiedName(String pkg, String cls) private StringgeneratedClassName(ExecutableElement method) private TypeElementprivate com.google.common.collect.ImmutableMap<String, AnnotationValue> getDefaultValues(TypeElement annotationElement) private Stringprivate com.google.common.collect.ImmutableMap<String, ExecutableElement> getMemberMethods(TypeElement annotationElement) private com.google.common.collect.ImmutableMap<String, AutoAnnotationProcessor.Member> getMembers(Element context, com.google.common.collect.ImmutableMap<String, ExecutableElement> memberMethods) private com.google.common.collect.ImmutableMap<String, AutoAnnotationProcessor.Parameter> getParameters(TypeElement annotationElement, ExecutableElement method, Map<String, AutoAnnotationProcessor.Member> members) private TypeMirrorgetTypeMirror(Class<?> c) invariableHash(List<? extends AnnotationValue> annotationValues) invariableHash(AnnotationValue annotationValue) Returns the hashCode of the given AnnotationValue, if that hashCode is guaranteed to be always the same.invariableHashes(com.google.common.collect.ImmutableMap<String, AutoAnnotationProcessor.Member> members, com.google.common.collect.ImmutableSet<String> parameters) Returns a map from the names of members with invariable hashCodes to the values of those hashCodes.private static booleanisGwtCompatible(TypeElement annotationElement) private booleanmethodsAreOverloaded(List<ExecutableElement> methods) booleanprocess(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) private voidprocess(RoundEnvironment roundEnv) private voidprocessMethod(ExecutableElement method) private voidreportError(Element e, String msg, Object... msgParams) Issue a compilation error.private voidvalidateParameters(TypeElement annotationElement, ExecutableElement method, com.google.common.collect.ImmutableMap<String, AutoAnnotationProcessor.Member> members, com.google.common.collect.ImmutableMap<String, AutoAnnotationProcessor.Parameter> parameters, com.google.common.collect.ImmutableMap<String, AnnotationValue> defaultValues) Returns the wrapper types (Integer.classetc) that are used in collection parameters likeList<Integer>.private voidwriteSourceFile(String className, String text, TypeElement originatingType) Methods inherited from class AbstractProcessor
getCompletions, getSupportedAnnotationTypes, getSupportedOptions, init, isInitialized
-
Field Details
-
elementUtils
-
typeUtils
-
-
Constructor Details
-
AutoAnnotationProcessor
public AutoAnnotationProcessor()
-
-
Method Details
-
getSupportedSourceVersion
- Specified by:
getSupportedSourceVersionin interfaceProcessor- Overrides:
getSupportedSourceVersionin classAbstractProcessor
-
reportError
-
abortWithError
Issue a compilation error and return an exception that, when thrown, will cause the processing of this class to be abandoned. This does not prevent the processing of other classes. -
process
- Specified by:
processin interfaceProcessor- Specified by:
processin classAbstractProcessor
-
process
-
processMethod
-
getGeneratedTypeName
-
invariableHash
Returns the hashCode of the given AnnotationValue, if that hashCode is guaranteed to be always the same. The hashCode of a String or primitive type never changes. The hashCode of a Class or an enum constant does potentially change in different runs of the same program. The hashCode of an array doesn't change if the hashCodes of its elements don't. Although we could have a similar rule for nested annotation values, we currently don't. -
invariableHash
-
invariableHashes
private static com.google.common.collect.ImmutableMap<String,Integer> invariableHashes(com.google.common.collect.ImmutableMap<String, AutoAnnotationProcessor.Member> members, com.google.common.collect.ImmutableSet<String> parameters) Returns a map from the names of members with invariable hashCodes to the values of those hashCodes. -
methodsAreOverloaded
-
generatedClassName
-
getAnnotationReturnType
-
getMemberMethods
private com.google.common.collect.ImmutableMap<String, ExecutableElement> getMemberMethods(TypeElement annotationElement) -
getMembers
private com.google.common.collect.ImmutableMap<String, AutoAnnotationProcessor.Member> getMembers(Element context, com.google.common.collect.ImmutableMap<String, ExecutableElement> memberMethods) -
getDefaultValues
private com.google.common.collect.ImmutableMap<String, AnnotationValue> getDefaultValues(TypeElement annotationElement) -
getParameters
private com.google.common.collect.ImmutableMap<String, AutoAnnotationProcessor.Parameter> getParameters(TypeElement annotationElement, ExecutableElement method, Map<String, AutoAnnotationProcessor.Member> members) -
validateParameters
private void validateParameters(TypeElement annotationElement, ExecutableElement method, com.google.common.collect.ImmutableMap<String, AutoAnnotationProcessor.Member> members, com.google.common.collect.ImmutableMap<String, AutoAnnotationProcessor.Parameter> parameters, com.google.common.collect.ImmutableMap<String, AnnotationValue> defaultValues) -
compatibleTypes
Returns true ifparameterTypecan be used to provide the value of an annotation member of typememberType. They must either be the same type, or the member type must be an array and the parameter type must be a collection of a compatible type. -
wrapperTypesUsedInCollections
Returns the wrapper types (Integer.classetc) that are used in collection parameters likeList<Integer>. This is needed because we will emit a helper method for each such type, for example to convertCollection<Integer>intoint[]. -
getTypeMirror
-
isGwtCompatible
-
fullyQualifiedName
-
writeSourceFile
-