Top Description Inners Constructors Methods
com.google.auto.value.processor

pack-priv final Class AnnotationOutput

extends Object
Class Inheritance
Imports
com.google.auto.common.MoreTypes, com.google.auto.value.processor.MissingTypes.MissingTypeException, com.google.common.collect.ImmutableMap, .Iterables, java.util.List, .Map, .Optional, javax.annotation.processing.ProcessingEnvironment, javax.lang.model.element.AnnotationMirror, javax.lang.model.element.AnnotationValue, javax.lang.model.element.Element, javax.lang.model.element.ElementKind, javax.lang.model.element.ExecutableElement, javax.lang.model.element.VariableElement, javax.lang.model.type.TypeKind, javax.lang.model.type.TypeMirror, javax.lang.model.util.SimpleAnnotationValueVisitor8, javax.tools.Diagnostic

Handling of default values for annotation members.
Author
[email protected] (Éamonn McManus)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private abstract static class
AnnotationOutput.SourceFormVisitor

Visitor that produces a string representation of an annotation value, suitable for inclusion in a Java source file as an annotation member or as the initializer of a variable of the appropriate type.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static void
private static StringBuilder
private static StringBuilder
private static boolean
isJavaLangClass(javax.lang.model.type.TypeMirror type)

pack-priv static String
sourceFormForAnnotation(javax.lang.model.element.AnnotationMirror annotationMirror)

Returns a string representation of the given annotation mirror, suitable for inclusion in a Java source file to reproduce the annotation in source form.

pack-priv static String
sourceFormForInitializer(javax.lang.model.element.AnnotationValue annotationValue, javax.annotation.processing.ProcessingEnvironment processingEnv, String memberName, javax.lang.model.element.Element errorContext)

Returns a string representation of the given annotation value, suitable for inclusion in a Java source file as the initializer of a variable of the appropriate type.

private static void
validateClassValues(javax.lang.model.element.AnnotationMirror annotationMirror)

Throws an exception if this annotation contains a value for a Class element that is not actually a type.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

AnnotationOutputback to summary
private AnnotationOutput()

Method Detail

appendEscapedback to summary
private static void appendEscaped(StringBuilder sb, char c)
appendQuotedback to summary
private static StringBuilder appendQuoted(StringBuilder sb, String s)
appendQuotedback to summary
private static StringBuilder appendQuoted(StringBuilder sb, char c)
isJavaLangClassback to summary
private static boolean isJavaLangClass(javax.lang.model.type.TypeMirror type)
sourceFormForAnnotationback to summary
pack-priv static String sourceFormForAnnotation(javax.lang.model.element.AnnotationMirror annotationMirror)

Returns a string representation of the given annotation mirror, suitable for inclusion in a Java source file to reproduce the annotation in source form.

sourceFormForInitializerback to summary
pack-priv static String sourceFormForInitializer(javax.lang.model.element.AnnotationValue annotationValue, javax.annotation.processing.ProcessingEnvironment processingEnv, String memberName, javax.lang.model.element.Element errorContext)

Returns a string representation of the given annotation value, suitable for inclusion in a Java source file as the initializer of a variable of the appropriate type.

validateClassValuesback to summary
private static void validateClassValues(javax.lang.model.element.AnnotationMirror annotationMirror)

Throws an exception if this annotation contains a value for a Class element that is not actually a type. The assumption is that the value is the string "<error>" which javac presents when a Class value is an undefined type.

com.google.auto.value.processor back to summary

private Class AnnotationOutput.AnnotationSourceFormVisitor

extends SourceFormVisitor
Class Inheritance

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private static Optional<javax.lang.model.element.AnnotationValue>
shortForm(Map<javax.lang.model.element.ExecutableElement, javax.lang.model.element.AnnotationValue> values)

public Void
visitAnnotation(javax.lang.model.element.AnnotationMirror a, StringBuilder sb)

public Void
visitArray(List<? extends javax.lang.model.element.AnnotationValue> values, StringBuilder sb)

Overrides com.google.auto.value.processor.AnnotationOutput.SourceFormVisitor.visitArray.

Inherited from com.google.auto.value.processor.AnnotationOutput.SourceFormVisitor:
defaultActionvisitCharvisitDoublevisitEnumConstantvisitFloatvisitLongvisitStringvisitType

Constructor Detail

AnnotationSourceFormVisitorback to summary
private AnnotationSourceFormVisitor()

Method Detail

shortFormback to summary
private static Optional<javax.lang.model.element.AnnotationValue> shortForm(Map<javax.lang.model.element.ExecutableElement, javax.lang.model.element.AnnotationValue> values)
visitAnnotationback to summary
public Void visitAnnotation(javax.lang.model.element.AnnotationMirror a, StringBuilder sb)
Annotations
@Override
visitArrayback to summary
public Void visitArray(List<? extends javax.lang.model.element.AnnotationValue> values, StringBuilder sb)

Overrides com.google.auto.value.processor.AnnotationOutput.SourceFormVisitor.visitArray.

Annotations
@Override
com.google.auto.value.processor back to summary

private Class AnnotationOutput.InitializerSourceFormVisitor

extends SourceFormVisitor
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final javax.lang.model.element.Element
private final String
private final javax.annotation.processing.ProcessingEnvironment

Constructor Summary

AccessConstructor and Description
pack-priv
InitializerSourceFormVisitor(javax.annotation.processing.ProcessingEnvironment processingEnv, String memberName, javax.lang.model.element.Element errorContext)

Method Summary

Modifier and TypeMethod and Description
public Void
visitAnnotation(javax.lang.model.element.AnnotationMirror a, StringBuilder sb)

Inherited from com.google.auto.value.processor.AnnotationOutput.SourceFormVisitor:
defaultActionvisitArrayvisitCharvisitDoublevisitEnumConstantvisitFloatvisitLongvisitStringvisitType

Field Detail

errorContextback to summary
private final javax.lang.model.element.Element errorContext
memberNameback to summary
private final String memberName
processingEnvback to summary
private final javax.annotation.processing.ProcessingEnvironment processingEnv

Constructor Detail

InitializerSourceFormVisitorback to summary
pack-priv InitializerSourceFormVisitor(javax.annotation.processing.ProcessingEnvironment processingEnv, String memberName, javax.lang.model.element.Element errorContext)

Method Detail

visitAnnotationback to summary
public Void visitAnnotation(javax.lang.model.element.AnnotationMirror a, StringBuilder sb)
Annotations
@Override
com.google.auto.value.processor back to summary

private abstract Class AnnotationOutput.SourceFormVisitor

extends javax.lang.model.util.SimpleAnnotationValueVisitor8
Class Inheritance
  • java.lang.Object
  • ⋱
  • javax.lang.model.util.SimpleAnnotationValueVisitor8
  • com.google.auto.value.processor.AnnotationOutput.SourceFormVisitor
Known Direct Subclasses
com.google.auto.value.processor.AnnotationOutput.InitializerSourceFormVisitor, com.google.auto.value.processor.AnnotationOutput.AnnotationSourceFormVisitor

Visitor that produces a string representation of an annotation value, suitable for inclusion in a Java source file as an annotation member or as the initializer of a variable of the appropriate type. The syntax for the two is the same except for annotation members that are themselves annotations. Within an annotation, an annotation member can be written as @NestedAnnotation(...), while in an initializer it must be written as an object, for example the construction of an @AutoAnnotation class. That's why we have this abstract class and two concrete subclasses.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
protected Void
public Void
visitArray(List<? extends javax.lang.model.element.AnnotationValue> values, StringBuilder sb)

public Void
public Void
visitDouble(double d, StringBuilder sb)

public Void
visitEnumConstant(javax.lang.model.element.VariableElement c, StringBuilder sb)

public Void
public Void
public Void
public Void
visitType(javax.lang.model.type.TypeMirror classConstant, StringBuilder sb)

Constructor Detail

SourceFormVisitorback to summary
private SourceFormVisitor()

Method Detail

defaultActionback to summary
protected Void defaultAction(Object value, StringBuilder sb)
Annotations
@Override
visitArrayback to summary
public Void visitArray(List<? extends javax.lang.model.element.AnnotationValue> values, StringBuilder sb)
Annotations
@Override
visitCharback to summary
public Void visitChar(char c, StringBuilder sb)
Annotations
@Override
visitDoubleback to summary
public Void visitDouble(double d, StringBuilder sb)
Annotations
@Override
visitEnumConstantback to summary
public Void visitEnumConstant(javax.lang.model.element.VariableElement c, StringBuilder sb)
Annotations
@Override
visitFloatback to summary
public Void visitFloat(float f, StringBuilder sb)
Annotations
@Override
visitLongback to summary
public Void visitLong(long i, StringBuilder sb)
Annotations
@Override
visitStringback to summary
public Void visitString(String s, StringBuilder sb)
Annotations
@Override
visitTypeback to summary
public Void visitType(javax.lang.model.type.TypeMirror classConstant, StringBuilder sb)
Annotations
@Override