1
2
3
4
5 package org.andromda.metafacades.uml14;
6
7 import java.util.Collection;
8 import org.andromda.core.metafacade.MetafacadeBase;
9 import org.andromda.core.metafacade.ModelValidationMessage;
10 import org.andromda.metafacades.uml.AssociationEndFacade;
11 import org.andromda.metafacades.uml.AssociationFacade;
12 import org.andromda.metafacades.uml.ClassifierFacade;
13 import org.andromda.translation.ocl.validation.OCLCollections;
14 import org.andromda.translation.ocl.validation.OCLIntrospector;
15 import org.andromda.translation.ocl.validation.OCLResultEnsurer;
16 import org.apache.log4j.Logger;
17 import org.omg.uml.foundation.core.AssociationEnd;
18
19
20
21
22
23
24
25
26
27
28
29 public abstract class AssociationEndFacadeLogic
30 extends ModelElementFacadeLogicImpl
31 implements AssociationEndFacade
32 {
33
34
35
36
37 protected AssociationEnd metaObject;
38
39
40
41
42
43 protected AssociationEndFacadeLogic(AssociationEnd metaObjectIn, String context)
44 {
45 super(metaObjectIn, getContext(context));
46 this.metaObject = metaObjectIn;
47 }
48
49
50
51
52 private static final Logger logger = Logger.getLogger(AssociationEndFacadeLogic.class);
53
54
55
56
57
58
59 private static String getContext(String context)
60 {
61 if (context == null)
62 {
63 context = "org.andromda.metafacades.uml.AssociationEndFacade";
64 }
65 return context;
66 }
67
68
69
70
71 @Override
72 public void resetMetafacadeContext(String context)
73 {
74 if (!this.contextRoot)
75 {
76 context = getContext(context);
77 setMetafacadeContext (context);
78 }
79 }
80
81
82
83
84
85 public boolean isAssociationEndFacadeMetaType()
86 {
87 return true;
88 }
89
90
91
92
93
94
95
96 protected abstract boolean handleIsOne2One();
97
98 private boolean __one2One1a;
99 private boolean __one2One1aSet = false;
100
101
102
103
104
105 public final boolean isOne2One()
106 {
107 boolean one2One1a = this.__one2One1a;
108 if (!this.__one2One1aSet)
109 {
110
111 one2One1a = handleIsOne2One();
112
113 this.__one2One1a = one2One1a;
114 if (isMetafacadePropertyCachingEnabled())
115 {
116 this.__one2One1aSet = true;
117 }
118 }
119 return one2One1a;
120 }
121
122
123
124
125
126 protected abstract boolean handleIsOne2Many();
127
128 private boolean __one2Many2a;
129 private boolean __one2Many2aSet = false;
130
131
132
133
134
135 public final boolean isOne2Many()
136 {
137 boolean one2Many2a = this.__one2Many2a;
138 if (!this.__one2Many2aSet)
139 {
140
141 one2Many2a = handleIsOne2Many();
142
143 this.__one2Many2a = one2Many2a;
144 if (isMetafacadePropertyCachingEnabled())
145 {
146 this.__one2Many2aSet = true;
147 }
148 }
149 return one2Many2a;
150 }
151
152
153
154
155
156 protected abstract boolean handleIsMany2One();
157
158 private boolean __many2One3a;
159 private boolean __many2One3aSet = false;
160
161
162
163
164
165 public final boolean isMany2One()
166 {
167 boolean many2One3a = this.__many2One3a;
168 if (!this.__many2One3aSet)
169 {
170
171 many2One3a = handleIsMany2One();
172
173 this.__many2One3a = many2One3a;
174 if (isMetafacadePropertyCachingEnabled())
175 {
176 this.__many2One3aSet = true;
177 }
178 }
179 return many2One3a;
180 }
181
182
183
184
185
186 protected abstract boolean handleIsMany2Many();
187
188 private boolean __many2Many4a;
189 private boolean __many2Many4aSet = false;
190
191
192
193
194
195 public final boolean isMany2Many()
196 {
197 boolean many2Many4a = this.__many2Many4a;
198 if (!this.__many2Many4aSet)
199 {
200
201 many2Many4a = handleIsMany2Many();
202
203 this.__many2Many4a = many2Many4a;
204 if (isMetafacadePropertyCachingEnabled())
205 {
206 this.__many2Many4aSet = true;
207 }
208 }
209 return many2Many4a;
210 }
211
212
213
214
215
216 protected abstract boolean handleIsAggregation();
217
218 private boolean __aggregation5a;
219 private boolean __aggregation5aSet = false;
220
221
222
223
224
225 public final boolean isAggregation()
226 {
227 boolean aggregation5a = this.__aggregation5a;
228 if (!this.__aggregation5aSet)
229 {
230
231 aggregation5a = handleIsAggregation();
232
233 this.__aggregation5a = aggregation5a;
234 if (isMetafacadePropertyCachingEnabled())
235 {
236 this.__aggregation5aSet = true;
237 }
238 }
239 return aggregation5a;
240 }
241
242
243
244
245
246 protected abstract boolean handleIsComposition();
247
248 private boolean __composition6a;
249 private boolean __composition6aSet = false;
250
251
252
253
254
255 public final boolean isComposition()
256 {
257 boolean composition6a = this.__composition6a;
258 if (!this.__composition6aSet)
259 {
260
261 composition6a = handleIsComposition();
262
263 this.__composition6a = composition6a;
264 if (isMetafacadePropertyCachingEnabled())
265 {
266 this.__composition6aSet = true;
267 }
268 }
269 return composition6a;
270 }
271
272
273
274
275
276 protected abstract boolean handleIsOrdered();
277
278 private boolean __ordered7a;
279 private boolean __ordered7aSet = false;
280
281
282
283
284
285
286 public final boolean isOrdered()
287 {
288 boolean ordered7a = this.__ordered7a;
289 if (!this.__ordered7aSet)
290 {
291
292 ordered7a = handleIsOrdered();
293
294 this.__ordered7a = ordered7a;
295 if (isMetafacadePropertyCachingEnabled())
296 {
297 this.__ordered7aSet = true;
298 }
299 }
300 return ordered7a;
301 }
302
303
304
305
306
307 protected abstract boolean handleIsReadOnly();
308
309 private boolean __readOnly8a;
310 private boolean __readOnly8aSet = false;
311
312
313
314
315
316 public final boolean isReadOnly()
317 {
318 boolean readOnly8a = this.__readOnly8a;
319 if (!this.__readOnly8aSet)
320 {
321
322 readOnly8a = handleIsReadOnly();
323
324 this.__readOnly8a = readOnly8a;
325 if (isMetafacadePropertyCachingEnabled())
326 {
327 this.__readOnly8aSet = true;
328 }
329 }
330 return readOnly8a;
331 }
332
333
334
335
336
337 protected abstract boolean handleIsNavigable();
338
339 private boolean __navigable9a;
340 private boolean __navigable9aSet = false;
341
342
343
344
345
346 public final boolean isNavigable()
347 {
348 boolean navigable9a = this.__navigable9a;
349 if (!this.__navigable9aSet)
350 {
351
352 navigable9a = handleIsNavigable();
353
354 this.__navigable9a = navigable9a;
355 if (isMetafacadePropertyCachingEnabled())
356 {
357 this.__navigable9aSet = true;
358 }
359 }
360 return navigable9a;
361 }
362
363
364
365
366
367 protected abstract String handleGetGetterName();
368
369 private String __getterName10a;
370 private boolean __getterName10aSet = false;
371
372
373
374
375
376 public final String getGetterName()
377 {
378 String getterName10a = this.__getterName10a;
379 if (!this.__getterName10aSet)
380 {
381
382 getterName10a = handleGetGetterName();
383
384 this.__getterName10a = getterName10a;
385 if (isMetafacadePropertyCachingEnabled())
386 {
387 this.__getterName10aSet = true;
388 }
389 }
390 return getterName10a;
391 }
392
393
394
395
396
397 protected abstract String handleGetSetterName();
398
399 private String __setterName11a;
400 private boolean __setterName11aSet = false;
401
402
403
404
405
406 public final String getSetterName()
407 {
408 String setterName11a = this.__setterName11a;
409 if (!this.__setterName11aSet)
410 {
411
412 setterName11a = handleGetSetterName();
413
414 this.__setterName11a = setterName11a;
415 if (isMetafacadePropertyCachingEnabled())
416 {
417 this.__setterName11aSet = true;
418 }
419 }
420 return setterName11a;
421 }
422
423
424
425
426
427 protected abstract String handleGetGetterSetterTypeName();
428
429 private String __getterSetterTypeName12a;
430 private boolean __getterSetterTypeName12aSet = false;
431
432
433
434
435
436
437 public final String getGetterSetterTypeName()
438 {
439 String getterSetterTypeName12a = this.__getterSetterTypeName12a;
440 if (!this.__getterSetterTypeName12aSet)
441 {
442
443 getterSetterTypeName12a = handleGetGetterSetterTypeName();
444
445 this.__getterSetterTypeName12a = getterSetterTypeName12a;
446 if (isMetafacadePropertyCachingEnabled())
447 {
448 this.__getterSetterTypeName12aSet = true;
449 }
450 }
451 return getterSetterTypeName12a;
452 }
453
454
455
456
457
458 protected abstract boolean handleIsMany();
459
460 private boolean __many13a;
461 private boolean __many13aSet = false;
462
463
464
465
466
467 public final boolean isMany()
468 {
469 boolean many13a = this.__many13a;
470 if (!this.__many13aSet)
471 {
472
473 many13a = handleIsMany();
474
475 this.__many13a = many13a;
476 if (isMetafacadePropertyCachingEnabled())
477 {
478 this.__many13aSet = true;
479 }
480 }
481 return many13a;
482 }
483
484
485
486
487
488 protected abstract boolean handleIsRequired();
489
490 private boolean __required14a;
491 private boolean __required14aSet = false;
492
493
494
495
496
497 public final boolean isRequired()
498 {
499 boolean required14a = this.__required14a;
500 if (!this.__required14aSet)
501 {
502
503 required14a = handleIsRequired();
504
505 this.__required14a = required14a;
506 if (isMetafacadePropertyCachingEnabled())
507 {
508 this.__required14aSet = true;
509 }
510 }
511 return required14a;
512 }
513
514
515
516
517
518 protected abstract boolean handleIsChild();
519
520 private boolean __child15a;
521 private boolean __child15aSet = false;
522
523
524
525
526
527
528 public final boolean isChild()
529 {
530 boolean child15a = this.__child15a;
531 if (!this.__child15aSet)
532 {
533
534 child15a = handleIsChild();
535
536 this.__child15a = child15a;
537 if (isMetafacadePropertyCachingEnabled())
538 {
539 this.__child15aSet = true;
540 }
541 }
542 return child15a;
543 }
544
545
546
547
548
549 protected abstract int handleGetUpper();
550
551 private int __upper16a;
552 private boolean __upper16aSet = false;
553
554
555
556
557
558
559 public final int getUpper()
560 {
561 int upper16a = this.__upper16a;
562 if (!this.__upper16aSet)
563 {
564
565 upper16a = handleGetUpper();
566
567 this.__upper16a = upper16a;
568 if (isMetafacadePropertyCachingEnabled())
569 {
570 this.__upper16aSet = true;
571 }
572 }
573 return upper16a;
574 }
575
576
577
578
579
580 protected abstract int handleGetLower();
581
582 private int __lower17a;
583 private boolean __lower17aSet = false;
584
585
586
587
588
589
590 public final int getLower()
591 {
592 int lower17a = this.__lower17a;
593 if (!this.__lower17aSet)
594 {
595
596 lower17a = handleGetLower();
597
598 this.__lower17a = lower17a;
599 if (isMetafacadePropertyCachingEnabled())
600 {
601 this.__lower17aSet = true;
602 }
603 }
604 return lower17a;
605 }
606
607
608
609
610
611 protected abstract String handleGetDefault();
612
613 private String __default18a;
614 private boolean __default18aSet = false;
615
616
617
618
619
620
621
622
623 public final String getDefault()
624 {
625 String default18a = this.__default18a;
626 if (!this.__default18aSet)
627 {
628
629 default18a = handleGetDefault();
630
631 this.__default18a = default18a;
632 if (isMetafacadePropertyCachingEnabled())
633 {
634 this.__default18aSet = true;
635 }
636 }
637 return default18a;
638 }
639
640
641
642
643
644 protected abstract String handleGetAggregationKind();
645
646 private String __aggregationKind19a;
647 private boolean __aggregationKind19aSet = false;
648
649
650
651
652
653
654
655 public final String getAggregationKind()
656 {
657 String aggregationKind19a = this.__aggregationKind19a;
658 if (!this.__aggregationKind19aSet)
659 {
660
661 aggregationKind19a = handleGetAggregationKind();
662
663 this.__aggregationKind19a = aggregationKind19a;
664 if (isMetafacadePropertyCachingEnabled())
665 {
666 this.__aggregationKind19aSet = true;
667 }
668 }
669 return aggregationKind19a;
670 }
671
672
673
674
675
676 protected abstract boolean handleIsLeaf();
677
678 private boolean __leaf20a;
679 private boolean __leaf20aSet = false;
680
681
682
683
684
685
686 public final boolean isLeaf()
687 {
688 boolean leaf20a = this.__leaf20a;
689 if (!this.__leaf20aSet)
690 {
691
692 leaf20a = handleIsLeaf();
693
694 this.__leaf20a = leaf20a;
695 if (isMetafacadePropertyCachingEnabled())
696 {
697 this.__leaf20aSet = true;
698 }
699 }
700 return leaf20a;
701 }
702
703
704
705
706
707 protected abstract boolean handleIsUnique();
708
709 private boolean __unique21a;
710 private boolean __unique21aSet = false;
711
712
713
714
715
716
717 public final boolean isUnique()
718 {
719 boolean unique21a = this.__unique21a;
720 if (!this.__unique21aSet)
721 {
722
723 unique21a = handleIsUnique();
724
725 this.__unique21a = unique21a;
726 if (isMetafacadePropertyCachingEnabled())
727 {
728 this.__unique21aSet = true;
729 }
730 }
731 return unique21a;
732 }
733
734
735
736
737
738 protected abstract String handleGetRemoverName();
739
740 private String __removerName22a;
741 private boolean __removerName22aSet = false;
742
743
744
745
746
747 public final String getRemoverName()
748 {
749 String removerName22a = this.__removerName22a;
750 if (!this.__removerName22aSet)
751 {
752
753 removerName22a = handleGetRemoverName();
754
755 this.__removerName22a = removerName22a;
756 if (isMetafacadePropertyCachingEnabled())
757 {
758 this.__removerName22aSet = true;
759 }
760 }
761 return removerName22a;
762 }
763
764
765
766
767
768 protected abstract String handleGetAdderName();
769
770 private String __adderName23a;
771 private boolean __adderName23aSet = false;
772
773
774
775
776
777 public final String getAdderName()
778 {
779 String adderName23a = this.__adderName23a;
780 if (!this.__adderName23aSet)
781 {
782
783 adderName23a = handleGetAdderName();
784
785 this.__adderName23a = adderName23a;
786 if (isMetafacadePropertyCachingEnabled())
787 {
788 this.__adderName23aSet = true;
789 }
790 }
791 return adderName23a;
792 }
793
794
795
796
797
798 protected abstract boolean handleIsBidirectional();
799
800 private boolean __bidirectional24a;
801 private boolean __bidirectional24aSet = false;
802
803
804
805
806
807
808 public final boolean isBidirectional()
809 {
810 boolean bidirectional24a = this.__bidirectional24a;
811 if (!this.__bidirectional24aSet)
812 {
813
814 bidirectional24a = handleIsBidirectional();
815
816 this.__bidirectional24a = bidirectional24a;
817 if (isMetafacadePropertyCachingEnabled())
818 {
819 this.__bidirectional24aSet = true;
820 }
821 }
822 return bidirectional24a;
823 }
824
825
826
827
828
829 protected abstract boolean handleIsDerived();
830
831 private boolean __derived25a;
832 private boolean __derived25aSet = false;
833
834
835
836
837
838
839 public final boolean isDerived()
840 {
841 boolean derived25a = this.__derived25a;
842 if (!this.__derived25aSet)
843 {
844
845 derived25a = handleIsDerived();
846
847 this.__derived25a = derived25a;
848 if (isMetafacadePropertyCachingEnabled())
849 {
850 this.__derived25aSet = true;
851 }
852 }
853 return derived25a;
854 }
855
856
857
858
859
860 protected abstract boolean handleIsStatic();
861
862 private boolean __static26a;
863 private boolean __static26aSet = false;
864
865
866
867
868
869 public final boolean isStatic()
870 {
871 boolean static26a = this.__static26a;
872 if (!this.__static26aSet)
873 {
874
875 static26a = handleIsStatic();
876
877 this.__static26a = static26a;
878 if (isMetafacadePropertyCachingEnabled())
879 {
880 this.__static26aSet = true;
881 }
882 }
883 return static26a;
884 }
885
886
887
888
889
890
891
892 public final AssociationFacade getAssociation()
893 {
894 AssociationFacade getAssociation1r = null;
895
896 Object result = handleGetAssociation();
897 MetafacadeBase shieldedResult = this.shieldedElement(result);
898 try
899 {
900 getAssociation1r = (AssociationFacade)shieldedResult;
901 }
902 catch (ClassCastException ex)
903 {
904
905 AssociationEndFacadeLogic.logger.warn("incorrect metafacade cast for AssociationEndFacadeLogic.getAssociation AssociationFacade " + result + ": " + shieldedResult);
906 }
907
908 return getAssociation1r;
909 }
910
911
912
913
914
915 protected abstract Object handleGetAssociation();
916
917
918
919
920
921
922
923
924
925
926
927
928
929 public final ClassifierFacade getType()
930 {
931 ClassifierFacade getType2r = null;
932
933 Object result = handleGetType();
934 MetafacadeBase shieldedResult = this.shieldedElement(result);
935 try
936 {
937 getType2r = (ClassifierFacade)shieldedResult;
938 }
939 catch (ClassCastException ex)
940 {
941
942 AssociationEndFacadeLogic.logger.warn("incorrect metafacade cast for AssociationEndFacadeLogic.getType ClassifierFacade " + result + ": " + shieldedResult);
943 }
944
945 return getType2r;
946 }
947
948
949
950
951
952 protected abstract Object handleGetType();
953
954
955
956
957
958
959
960
961
962
963
964
965
966 public final AssociationEndFacade getOtherEnd()
967 {
968 AssociationEndFacade getOtherEnd3r = null;
969
970 Object result = handleGetOtherEnd();
971 MetafacadeBase shieldedResult = this.shieldedElement(result);
972 try
973 {
974 getOtherEnd3r = (AssociationEndFacade)shieldedResult;
975 }
976 catch (ClassCastException ex)
977 {
978
979 AssociationEndFacadeLogic.logger.warn("incorrect metafacade cast for AssociationEndFacadeLogic.getOtherEnd AssociationEndFacade " + result + ": " + shieldedResult);
980 }
981
982 return getOtherEnd3r;
983 }
984
985
986
987
988
989 protected abstract Object handleGetOtherEnd();
990
991
992
993
994
995
996
997
998
999 @Override
1000 public void validateInvariants(Collection<ModelValidationMessage> validationMessages)
1001 {
1002 super.validateInvariants(validationMessages);
1003 try
1004 {
1005 final Object contextElement = this.THIS();
1006 boolean constraintValid = OCLResultEnsurer.ensure(OCLCollections.notEmpty(OCLIntrospector.invoke(contextElement,"type.name")));
1007 if (!constraintValid)
1008 {
1009 validationMessages.add(
1010 new ModelValidationMessage(
1011 (MetafacadeBase)contextElement ,
1012 "org::andromda::metafacades::uml::AssociationEndFacade::association end needs a type",
1013 "Each association end needs a type, you cannot leave the type unspecified."));
1014 }
1015 }
1016 catch (Throwable th)
1017 {
1018 Throwable cause = th.getCause();
1019 int depth = 0;
1020 while (cause != null && depth < 7)
1021 {
1022 th = cause;
1023 depth++;
1024 }
1025 logger.error("Error validating constraint 'org::andromda::metafacades::uml::AssociationEndFacade::association end needs a type' ON "
1026 + this.THIS().toString() + ": " + th.getMessage(), th);
1027 }
1028 }
1029 }