-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjcg-transformers.xml
209 lines (187 loc) · 9.94 KB
/
jcg-transformers.xml
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2010 by Guido Steinacker
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd">
<bean id="transformerProvider" class="de.steinacker.jcg.transform.type.TypeTransformerProvider">
<property name="transformers">
<list>
<ref bean="typeMapper" />
<ref bean="typeTranslator"/>
<ref bean="removeSingleEmptyDefaultConstructor"/>
<ref bean="publicFinalClass" />
<ref bean="privatizeFields" />
<ref bean="addConstructors" />
<ref bean="addConstructorsForMutableTypes" />
<ref bean="addGetters" />
<ref bean="addGeneratedAnnotation" />
<ref bean="removeJcgAnnotations" />
<ref bean="addSetters" />
<ref bean="addSettersForMutableTypes" />
<ref bean="finalizeFields" />
<ref bean="extractInterface" />
<ref bean="mutable" />
<ref bean="immutable" />
</list>
</property>
</bean>
<bean id="glossaryFactory" class="de.steinacker.jcg.transform.translation.JaxbGlossaryFactory"/>
<bean id="glossary" factory-bean="glossaryFactory" factory-method="glossary"/>
<!-- Maps types to different types and/or moves types to different packages.
-->
<bean id="typeMapper" class="de.steinacker.jcg.transform.type.TypeMapper">
<property name="name" value="TypeMapper" />
<property name="mappingPatterns">
<util:properties location="jcg-typemapper.properties" />
</property>
</bean>
<bean id="typeTranslator" class="de.steinacker.jcg.transform.translation.TypeTranslator">
<property name="name" value="TypeTranslator" />
<property name="glossary" ref="glossary"/>
</bean>
<bean id="removeSingleEmptyDefaultConstructor" class="de.steinacker.jcg.transform.type.RemoveSingleEmptyDefaultConstructor"/>
<bean id="publicFinalClass" class="de.steinacker.jcg.transform.type.PublicFinalClass"/>
<bean id="privatizeFields" class="de.steinacker.jcg.transform.type.PrivatizeFields"/>
<!-- Adds a constructor with parameters for every attribute of the type. If
some of the attributes are final and some are not, a second constructor
is generated, with parameters for only the final attributes.
If there are no final attributes, an empty default constructor is
generated.
-->
<bean id="addConstructors"
class="de.steinacker.jcg.transform.type.AddConstructors">
<property name="name" value="AddConstructors"/>
<property name="onlyFinalFields" value="false"/>
<property name="finalAndNonFinalFields" value="true"/>
<property name="generateDefaultConstructor" value="true"/>
<property name="templateName" value="/templates/field/setFieldInMethod.vm" />
<property name="templateProcessor" ref="velocityTemplateProcessor" />
</bean>
<!-- Adds a constructor with parameters for every attribute of the type. If
some of the attributes are final and some are not, a second constructor
is generated, with parameters for only the final attributes.
If there are no final attributes, an empty default constructor is
generated.
-->
<bean id="addConstructorsForMutableTypes"
class="de.steinacker.jcg.transform.type.AddConstructors">
<property name="name" value="AddConstructorsForMutableTypes"/>
<property name="onlyFinalFields" value="false"/>
<property name="finalAndNonFinalFields" value="true"/>
<property name="generateDefaultConstructor" value="true"/>
<property name="templateName" value="/templates/field/setMutableFieldInMethod.vm" />
<property name="templateProcessor" ref="velocityTemplateProcessor" />
</bean>
<bean id="addGetters" class="de.steinacker.jcg.transform.type.AddGetters">
<property name="name" value="AddGetters"/>
<property name="templateName" value="/templates/field/getFieldInMethod.vm" />
<property name="templateProcessor" ref="velocityTemplateProcessor" />
</bean>
<bean id="addGeneratedAnnotation" class="de.steinacker.jcg.transform.type.AddGeneratedAnnotation">
<property name="name" value="AddGeneratedAnnotation" />
<property name="comments" value="" />
</bean>
<bean id="removeJcgAnnotations" class="de.steinacker.jcg.transform.type.RemoveAnnotations">
<property name="name" value="RemoveJcgAnnotations" />
<property name="classNames">
<list>
<value>javax.annotation.Generated</value>
</list>
</property>
<property name="packageNames">
<list>
<value>de.steinacker.jcg.annotation</value>
</list>
</property>
</bean>
<bean id="addSetters" class="de.steinacker.jcg.transform.type.AddSetters">
<property name="name" value="AddSetters"/>
<property name="templateName" value="/templates/field/setFieldInMethod.vm" />
<property name="templateProcessor" ref="velocityTemplateProcessor" />
</bean>
<bean id="addSettersForMutableTypes" class="de.steinacker.jcg.transform.type.AddSetters">
<property name="name" value="AddSettersForMutableTypes"/>
<property name="templateName" value="/templates/field/setMutableFieldInMethod.vm" />
<property name="templateProcessor" ref="velocityTemplateProcessor" />
</bean>
<bean id="finalizeFields" class="de.steinacker.jcg.transform.type.FinalizeFields"/>
<bean id="extractInterface" class="de.steinacker.jcg.transform.type.ExtractInterface">
<property name="classAbsolutePackage" value="" />
<property name="interfaceAbsolutePackage" value="" />
<property name="classPrefix" value="" />
<property name="classSuffix" value="Impl" />
<property name="interfacePrefix" value="" />
<property name="classRelativePackage" value="" />
<property name="interfaceRelativePackage" value="" />
<property name="addOverrideAnnotation" value="true" />
</bean>
<bean id="mutable" class="de.steinacker.jcg.transform.type.TypeTransformerChain">
<property name="name" value="Mutable"/>
<property name="transformerChain">
<list>
<ref bean="removeSingleEmptyDefaultConstructor" />
<ref bean="typeMapper" />
<ref bean="typeTranslator" />
<ref bean="publicFinalClass" />
<ref bean="privatizeFields" />
<ref bean="addConstructors" />
<ref bean="addGetters" />
<ref bean="addGeneratedAnnotation" />
<ref bean="removeJcgAnnotations" />
<ref bean="addSetters" />
<ref bean="extractInterface" />
</list>
</property>
</bean>
<bean id="immutable" class="de.steinacker.jcg.transform.type.TypeTransformerChain">
<property name="name" value="Immutable"/>
<property name="transformerChain">
<list>
<ref bean="removeSingleEmptyDefaultConstructor" />
<ref bean="typeMapper" />
<ref bean="typeTranslator" />
<ref bean="publicFinalClass" />
<ref bean="privatizeFields" />
<ref bean="finalizeFields" />
<ref bean="addConstructors" />
<ref bean="addGetters" />
<ref bean="addGeneratedAnnotation" />
<ref bean="removeJcgAnnotations" />
<ref bean="extractInterface" />
</list>
</property>
</bean>
<bean id="modelTransformer" class="de.steinacker.jcg.transform.model.ModelSequencer">
<property name="typeTransformer">
<bean id="transformations" class="de.steinacker.jcg.transform.type.TypeTransformerRouter">
<property name="selector">
<bean class="de.steinacker.jcg.transform.rule.TransformerSelectors">
<property name="rules">
<list>
<bean class="de.steinacker.jcg.transform.rule.AnnotationSelector">
<property name="annotationNames">
<list>
<value>de.steinacker.jcg.annotation.Mutable</value>
<value>de.steinacker.jcg.annotation.Immutable</value>
<value>de.steinacker.jcg.annotation.TransformWith</value>
</list>
</property>
</bean>
<bean class="de.steinacker.jcg.transform.rule.ContextParamSelector">
<property name="ctxParam" value="ctx-selector-param"/>
</bean>
</list>
</property>
</bean>
</property>
<property name="name" value="TypeTransformerRouter"/>
<property name="transformerProvider" ref="transformerProvider"/>
</bean>
</property>
</bean>
<bean id="velocityTemplateProcessor" class="de.steinacker.jcg.codegen.VelocityTemplateProcessor" />
</beans>