1
2
3
4
5 package org.andromda.metafacades.uml14;
6
7 import java.util.Collection;
8 import java.util.List;
9 import org.andromda.core.common.Introspector;
10 import org.andromda.core.metafacade.MetafacadeBase;
11 import org.andromda.core.metafacade.ModelValidationMessage;
12 import org.andromda.metafacades.uml.ClassifierFacade;
13 import org.andromda.metafacades.uml.ModelElementFacade;
14 import org.andromda.metafacades.uml.TemplateParameterFacade;
15 import org.andromda.translation.ocl.validation.OCLCollections;
16 import org.andromda.translation.ocl.validation.OCLIntrospector;
17 import org.andromda.translation.ocl.validation.OCLResultEnsurer;
18 import org.apache.log4j.Logger;
19 import org.omg.uml.foundation.core.TemplateParameter;
20
21
22
23
24
25
26
27
28
29
30 public abstract class TemplateParameterFacadeLogic
31 extends MetafacadeBase
32 implements TemplateParameterFacade
33 {
34
35
36
37
38 protected TemplateParameter metaObject;
39
40
41
42
43
44 protected TemplateParameterFacadeLogic(TemplateParameter metaObjectIn, String context)
45 {
46 super(metaObjectIn, getContext(context));
47 this.metaObject = metaObjectIn;
48 }
49
50
51
52
53 private static final Logger logger = Logger.getLogger(TemplateParameterFacadeLogic.class);
54
55
56
57
58
59
60 private static String getContext(String context)
61 {
62 if (context == null)
63 {
64 context = "org.andromda.metafacades.uml.TemplateParameterFacade";
65 }
66 return context;
67 }
68
69
70
71
72 @Override
73 public void resetMetafacadeContext(String context)
74 {
75 if (!this.contextRoot)
76 {
77 context = getContext(context);
78 setMetafacadeContext (context);
79 }
80 }
81
82
83
84
85
86 public boolean isTemplateParameterFacadeMetaType()
87 {
88 return true;
89 }
90
91
92
93
94
95
96
97 protected abstract ClassifierFacade handleGetType();
98
99
100
101
102
103
104 public final ClassifierFacade getType()
105 {
106 ClassifierFacade type1a = null;
107
108 type1a = handleGetType();
109
110 return type1a;
111 }
112
113
114
115
116
117 protected abstract String handleGetName();
118
119
120
121
122
123 public final String getName()
124 {
125 String name2a = null;
126
127 name2a = handleGetName();
128
129 return name2a;
130 }
131
132
133
134
135
136 protected abstract String handleGetFullyQualifiedName();
137
138
139
140
141
142 public final String getFullyQualifiedName()
143 {
144 String fullyQualifiedName3a = null;
145
146 fullyQualifiedName3a = handleGetFullyQualifiedName();
147
148 return fullyQualifiedName3a;
149 }
150
151
152
153
154
155 protected abstract String handleGetGetterSetterTypeName();
156
157
158
159
160
161 public final String getGetterSetterTypeName()
162 {
163 String getterSetterTypeName4a = null;
164
165 getterSetterTypeName4a = handleGetGetterSetterTypeName();
166
167 return getterSetterTypeName4a;
168 }
169
170
171
172
173
174 protected abstract String handleGetGetterName();
175
176
177
178
179
180 public final String getGetterName()
181 {
182 String getterName5a = null;
183
184 getterName5a = handleGetGetterName();
185
186 return getterName5a;
187 }
188
189
190
191
192
193 protected abstract String handleGetSetterName();
194
195
196
197
198
199 public final String getSetterName()
200 {
201 String setterName6a = null;
202
203 setterName6a = handleGetSetterName();
204
205 return setterName6a;
206 }
207
208
209
210
211
212 protected abstract ModelElementFacade handleGetOwner();
213
214
215
216
217
218
219 public final ModelElementFacade getOwner()
220 {
221 ModelElementFacade owner7a = null;
222
223 owner7a = handleGetOwner();
224
225 return owner7a;
226 }
227
228
229
230
231
232
233
234
235
236
237
238 protected abstract String handleGetDocumentation(String indent);
239
240
241
242
243
244
245
246
247
248 public String getDocumentation(String indent)
249 {
250
251 String returnValue = handleGetDocumentation(indent);
252
253 return returnValue;
254 }
255
256
257
258
259
260
261
262
263
264
265
266 protected abstract String handleGetDocumentation(String indent, int lineLength);
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281 public String getDocumentation(String indent, int lineLength)
282 {
283
284 String returnValue = handleGetDocumentation(indent, lineLength);
285
286 return returnValue;
287 }
288
289
290
291
292
293
294
295
296
297
298 protected abstract String handleGetDocumentation(String indent, int lineLength, boolean htmlStyle);
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314 public String getDocumentation(String indent, int lineLength, boolean htmlStyle)
315 {
316
317 String returnValue = handleGetDocumentation(indent, lineLength, htmlStyle);
318
319 return returnValue;
320 }
321
322
323
324
325
326
327
328
329
330
331
332 public final ModelElementFacade getDefaultElement()
333 {
334 ModelElementFacade getDefaultElement1r = null;
335
336 Object result = handleGetDefaultElement();
337 MetafacadeBase shieldedResult = this.shieldedElement(result);
338 try
339 {
340 getDefaultElement1r = (ModelElementFacade)shieldedResult;
341 }
342 catch (ClassCastException ex)
343 {
344
345 TemplateParameterFacadeLogic.logger.warn("incorrect metafacade cast for TemplateParameterFacadeLogic.getDefaultElement ModelElementFacade " + result + ": " + shieldedResult);
346 }
347
348 return getDefaultElement1r;
349 }
350
351
352
353
354
355 protected abstract Object handleGetDefaultElement();
356
357
358
359
360
361
362
363
364
365 public final ModelElementFacade getParameter()
366 {
367 ModelElementFacade getParameter2r = null;
368
369 Object result = handleGetParameter();
370 MetafacadeBase shieldedResult = this.shieldedElement(result);
371 try
372 {
373 getParameter2r = (ModelElementFacade)shieldedResult;
374 }
375 catch (ClassCastException ex)
376 {
377
378 TemplateParameterFacadeLogic.logger.warn("incorrect metafacade cast for TemplateParameterFacadeLogic.getParameter ModelElementFacade " + result + ": " + shieldedResult);
379 }
380
381 return getParameter2r;
382 }
383
384
385
386
387
388 protected abstract Object handleGetParameter();
389
390
391
392
393
394
395
396
397
398 public final Collection<ClassifierFacade> getConstrainingClassifiers()
399 {
400 Collection<ClassifierFacade> getConstrainingClassifiers3r = null;
401
402 Collection result = handleGetConstrainingClassifiers();
403 List shieldedResult = this.shieldedElements(result);
404 try
405 {
406 getConstrainingClassifiers3r = (Collection<ClassifierFacade>)shieldedResult;
407 }
408 catch (ClassCastException ex)
409 {
410
411 TemplateParameterFacadeLogic.logger.warn("incorrect metafacade cast for TemplateParameterFacadeLogic.getConstrainingClassifiers Collection<ClassifierFacade> " + result + ": " + shieldedResult);
412 }
413
414 return getConstrainingClassifiers3r;
415 }
416
417
418
419
420
421 protected abstract Collection handleGetConstrainingClassifiers();
422
423
424
425
426
427
428
429
430 @Override
431 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
432 {
433 try
434 {
435 final Object contextElement = this.THIS();
436 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.notEmpty(OCLIntrospector.invoke(contextElement,"type.name")));
437 if (!constraintValid)
438 {
439 validationMessages.add(
440 new ModelValidationMessage(
441 (MetafacadeBase)contextElement ,
442 "org::andromda::metafacades::uml::TemplateParameterFacade::template parameter type must be specified",
443 "Template Parameter type must be specified."));
444 }
445 }
446 catch (Throwable th)
447 {
448 Throwable cause = th.getCause();
449 int depth = 0;
450 while (cause != null && depth < 7)
451 {
452 th = cause;
453 depth++;
454 }
455 logger.error("Error validating constraint 'org::andromda::metafacades::uml::TemplateParameterFacade::template parameter type must be specified' ON "
456 + this.THIS().toString() + ": " + th.getMessage(), th);
457 }
458 }
459
460
461
462
463 private static final String NAME_PROPERTY = "name";
464 private static final String FQNAME_PROPERTY = "fullyQualifiedName";
465
466
467
468
469 @Override
470 public String toString()
471 {
472 final StringBuilder toString = new StringBuilder(this.getClass().getName());
473 toString.append("[");
474 try
475 {
476 toString.append(Introspector.instance().getProperty(this, FQNAME_PROPERTY));
477 }
478 catch (final Throwable tryAgain)
479 {
480 try
481 {
482 toString.append(Introspector.instance().getProperty(this, NAME_PROPERTY));
483 }
484 catch (final Throwable ignore)
485 {
486
487 }
488 }
489 toString.append("]");
490 return toString.toString();
491 }
492 }