• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2014 Google LLC
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package com.google.auto.value.processor;
17 
18 import com.google.escapevelocity.Template;
19 import java.util.Map;
20 import java.util.Set;
21 
22 /**
23  * The variables to substitute into the autoannotation.vm template.
24  *
25  * @author emcmanus@google.com (Éamonn McManus)
26  */
27 @SuppressWarnings("unused") // the fields in this class are only read via reflection
28 class AutoAnnotationTemplateVars extends TemplateVars {
29   /** The members of the annotation being implemented. */
30   Map<String, AutoAnnotationProcessor.Member> members;
31 
32   /**
33    * The parameters in the {@code @AutoAnnotation} method, which are also the constructor parameters
34    * in the generated class.
35    */
36   Map<String, AutoAnnotationProcessor.Parameter> params;
37 
38   /**
39    * A string representing the parameter type declaration of the equals(Object) method, including
40    * any annotations.
41    */
42   String equalsParameterType;
43 
44   /** The encoded form of the {@code Generated} class, or empty if it is not available. */
45   String generated;
46 
47   /**
48    * The package of the class containing the {@code @AutoAnnotation} annotation, which is also the
49    * package where the annotation implementation will be generated.
50    */
51   String pkg;
52 
53   /** The simple name of the generated class, like {@code AutoAnnotation_Foo_bar}. */
54   String className;
55 
56   /** The name of the annotation interface as it can be referenced in the generated code. */
57   String annotationName;
58 
59   /** The fully-qualified name of the annotation interface. */
60   String annotationFullName;
61 
62   /**
63    * The wrapper types (like {@code Integer.class}) that are referenced in collection parameters
64    * (like {@code List<Integer>}).
65    */
66   Set<Class<?>> wrapperTypesUsedInCollections;
67 
68   /**
69    * True if this annotation is marked {@code @GwtCompatible}. That means that we can't use {@code
70    * clone()} to make a copy of an array.
71    */
72   Boolean gwtCompatible;
73 
74   /**
75    * The names of members that are defaulted (not mentioned) in this {@code @AutoAnnotation}, and
76    * whose hash codes are invariable.
77    */
78   Set<String> invariableHashes;
79 
80   /** The sum of the hash code contributions from the members in {@link #invariableHashes}. */
81   Integer invariableHashSum;
82 
83   /**
84    * A computed {@code serialVersionUID} based on the names and types of the {@code @AutoAnnotation}
85    * method parameters.
86    */
87   Long serialVersionUID;
88 
89   private static final Template TEMPLATE = parsedTemplateForResource("autoannotation.vm");
90 
91   @Override
parsedTemplate()92   Template parsedTemplate() {
93     return TEMPLATE;
94   }
95 }
96