Package com.google.auto.value.processor
Class TemplateVars
- java.lang.Object
-
- com.google.auto.value.processor.TemplateVars
-
- Direct Known Subclasses:
AutoAnnotationTemplateVars,AutoValueOrOneOfTemplateVars,GwtSerialization.GwtTemplateVars
abstract class TemplateVars extends java.lang.ObjectA template and a set of variables to be substituted into that template. A concrete subclass of this class defines a set of fields that are template variables, and an implementation of theparsedTemplate()method which is the template to substitute them into. Once the values of the fields have been assigned, thetoText()method returns the result of substituting them into the template.The subclass may be a direct subclass of this class or a more distant descendant. Every field in the starting class and its ancestors up to this class will be included. Fields cannot be static unless they are also final. They cannot be private, though they can be package-private if the class is in the same package as this class. They cannot be primitive or null, so that there is a clear indication when a field has not been set.
-
-
Field Summary
Fields Modifier and Type Field Description private com.google.common.collect.ImmutableList<java.lang.reflect.Field>fields
-
Constructor Summary
Constructors Constructor Description TemplateVars()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description private static voidaddFields(com.google.common.collect.ImmutableList.Builder<java.lang.reflect.Field> fieldsBuilder, java.lang.reflect.Field[] declaredFields)private static java.lang.ObjectfieldValue(java.lang.reflect.Field field, java.lang.Object container)private static com.google.common.collect.ImmutableList<java.lang.reflect.Field>getFields(java.lang.Class<?> c)private static java.io.InputStreaminputStreamFromFile(java.net.URL resourceUrl)private static java.io.InputStreaminputStreamFromJar(java.net.URL resourceUrl)private static booleanisStaticFinal(java.lang.reflect.Field field)(package private) abstract TemplateparsedTemplate()(package private) static TemplateparsedTemplateForResource(java.lang.String resourceName)private static java.io.ReaderreaderFromResource(java.lang.String resourceName)private static java.io.ReaderreaderFromUrl(java.lang.String resourceName)private static TemplateretryParseAfterException(java.lang.String resourceName, java.lang.Exception exception)(package private) java.lang.StringtoText()Returns the result of substituting the variables defined by the fields of this class (a concrete subclass of TemplateVars) into the template returned byparsedTemplate().private java.util.Map<java.lang.String,java.lang.Object>toVars()
-
-
-
Method Detail
-
parsedTemplate
abstract Template parsedTemplate()
-
getFields
private static com.google.common.collect.ImmutableList<java.lang.reflect.Field> getFields(java.lang.Class<?> c)
-
addFields
private static void addFields(com.google.common.collect.ImmutableList.Builder<java.lang.reflect.Field> fieldsBuilder, java.lang.reflect.Field[] declaredFields)
-
toText
java.lang.String toText()
Returns the result of substituting the variables defined by the fields of this class (a concrete subclass of TemplateVars) into the template returned byparsedTemplate().
-
toVars
private java.util.Map<java.lang.String,java.lang.Object> toVars()
-
parsedTemplateForResource
static Template parsedTemplateForResource(java.lang.String resourceName)
-
retryParseAfterException
private static Template retryParseAfterException(java.lang.String resourceName, java.lang.Exception exception)
-
readerFromResource
private static java.io.Reader readerFromResource(java.lang.String resourceName)
-
readerFromUrl
private static java.io.Reader readerFromUrl(java.lang.String resourceName) throws java.io.IOException- Throws:
java.io.IOException
-
inputStreamFromJar
private static java.io.InputStream inputStreamFromJar(java.net.URL resourceUrl) throws java.net.URISyntaxException, java.io.IOException- Throws:
java.net.URISyntaxExceptionjava.io.IOException
-
inputStreamFromFile
private static java.io.InputStream inputStreamFromFile(java.net.URL resourceUrl) throws java.io.IOException, java.net.URISyntaxException- Throws:
java.io.IOExceptionjava.net.URISyntaxException
-
fieldValue
private static java.lang.Object fieldValue(java.lang.reflect.Field field, java.lang.Object container)
-
isStaticFinal
private static boolean isStaticFinal(java.lang.reflect.Field field)
-
-