This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathAndroidAnnotationsEnvironment.java
More file actions
177 lines (139 loc) · 5.24 KB
/
Copy pathAndroidAnnotationsEnvironment.java
File metadata and controls
177 lines (139 loc) · 5.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
/**
* Copyright (C) 2010-2015 eBusiness Information, Excilys Group
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed To in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package org.androidannotations;
import java.lang.annotation.Annotation;
import java.util.List;
import java.util.Set;
import javax.annotation.processing.ProcessingEnvironment;
import javax.lang.model.element.Element;
import org.androidannotations.handler.AnnotationHandler;
import org.androidannotations.handler.AnnotationHandlers;
import org.androidannotations.handler.GeneratingAnnotationHandler;
import org.androidannotations.helper.AndroidManifest;
import org.androidannotations.holder.GeneratedClassHolder;
import org.androidannotations.model.AndroidSystemServices;
import org.androidannotations.model.AnnotationElements;
import org.androidannotations.plugin.AndroidAnnotationsPlugin;
import org.androidannotations.process.Option;
import org.androidannotations.process.Options;
import org.androidannotations.process.ProcessHolder;
import org.androidannotations.rclass.IRClass;
import com.sun.codemodel.JClass;
import com.sun.codemodel.JCodeModel;
import com.sun.codemodel.JDefinedClass;
public class AndroidAnnotationsEnvironment {
private final ProcessingEnvironment processingEnvironment;
private final Options options;
private final AnnotationHandlers annotationHandlers;
private List<AndroidAnnotationsPlugin> plugins;
private IRClass rClass;
private AndroidSystemServices androidSystemServices;
private AndroidManifest androidManifest;
private AnnotationElements validatedElements;
private ProcessHolder processHolder;
AndroidAnnotationsEnvironment(ProcessingEnvironment processingEnvironment) {
this.processingEnvironment = processingEnvironment;
options = new Options(processingEnvironment);
annotationHandlers = new AnnotationHandlers();
androidSystemServices = new AndroidSystemServices(this);
}
public void setPlugins(List<AndroidAnnotationsPlugin> plugins) {
this.plugins = plugins;
for (AndroidAnnotationsPlugin plugin : plugins) {
options.addAllSupportedOptions(plugin.getSupportedOptions());
plugin.addHandlers(annotationHandlers, this);
}
}
public void setAndroidEnvironment(IRClass rClass, AndroidManifest androidManifest) {
this.rClass = rClass;
this.androidManifest = androidManifest;
}
public void setValidatedElements(AnnotationElements validatedElements) {
this.validatedElements = validatedElements;
}
public void setProcessHolder(ProcessHolder processHolder) {
this.processHolder = processHolder;
}
public ProcessingEnvironment getProcessingEnvironment() {
return processingEnvironment;
}
public Set<String> getSupportedOptions() {
return options.getSupportedOptions();
}
public String getOptionValue(Option option) {
return options.get(option);
}
public String getOptionValue(String optionKey) {
return options.get(optionKey);
}
public boolean getOptionBooleanValue(Option option) {
return options.getBoolean(option);
}
public boolean getOptionBooleanValue(String optionKey) {
return options.getBoolean(optionKey);
}
public Set<String> getSupportedAnnotationTypes() {
return annotationHandlers.getSupportedAnnotationTypes();
}
public List<AnnotationHandler<? extends GeneratedClassHolder>> getHandlers() {
return annotationHandlers.get();
}
public List<AnnotationHandler<? extends GeneratedClassHolder>> getDecoratingHandlers() {
return annotationHandlers.getDecorating();
}
public List<GeneratingAnnotationHandler<? extends GeneratedClassHolder>> getGeneratingHandlers() {
return annotationHandlers.getGenerating();
}
public IRClass getRClass() {
return rClass;
}
public AndroidSystemServices getAndroidSystemServices() {
return androidSystemServices;
}
public AndroidManifest getAndroidManifest() {
return androidManifest;
}
public AnnotationElements getValidatedElements() {
return validatedElements;
}
public JCodeModel getCodeModel() {
return processHolder.codeModel();
}
public JClass getJClass(String fullyQualifiedName) {
return processHolder.refClass(fullyQualifiedName);
}
public JClass getJClass(Class<?> clazz) {
return processHolder.refClass(clazz);
}
public JDefinedClass getDefinedClass(String fullyQualifiedName) {
return processHolder.definedClass(fullyQualifiedName);
}
public GeneratedClassHolder getGeneratedClassHolder(Element element) {
return processHolder.getGeneratedClassHolder(element);
}
public ProcessHolder.Classes getClasses() {
return processHolder.classes();
}
public List<Class<? extends Annotation>> getGeneratingAnnotations() {
return annotationHandlers.getGeneratingAnnotations();
}
public boolean isAndroidAnnotation(String annotationQualifiedName) {
return getSupportedAnnotationTypes().contains(annotationQualifiedName);
}
public List<AndroidAnnotationsPlugin> getPlugins() {
return plugins;
}
}