• 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   /** The encoded form of the {@code Generated} class, or empty if it is not available. */
39   String generated;
40 
41   /**
42    * The package of the class containing the {@code @AutoAnnotation} annotation, which is also the
43    * package where the annotation implementation will be generated.
44    */
45   String pkg;
46 
47   /** The simple name of the generated class, like {@code AutoAnnotation_Foo_bar}. */
48   String className;
49 
50   /** The name of the annotation interface as it can be referenced in the generated code. */
51   String annotationName;
52 
53   /** The fully-qualified name of the annotation interface. */
54   String annotationFullName;
55 
56   /**
57    * The wrapper types (like {@code Integer.class}) that are referenced in collection parameters
58    * (like {@code List<Integer>}).
59    */
60   Set<Class<?>> wrapperTypesUsedInCollections;
61 
62   /**
63    * True if this annotation is marked {@code @GwtCompatible}. That means that we can't use {@code
64    * clone()} to make a copy of an array.
65    */
66   Boolean gwtCompatible;
67 
68   /**
69    * The names of members that are defaulted (not mentioned) in this {@code @AutoAnnotation}, and
70    * whose hash codes are invariable.
71    */
72   Set<String> invariableHashes;
73 
74   /** The sum of the hash code contributions from the members in {@link #invariableHashes}. */
75   Integer invariableHashSum;
76 
77   private static final Template TEMPLATE = parsedTemplateForResource("autoannotation.vm");
78 
79   @Override
parsedTemplate()80   Template parsedTemplate() {
81     return TEMPLATE;
82   }
83 }
84