Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 1a92addc90d59c63970f458d0eb488dffa709a47 (plain) (blame)
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
/**
 * Copyright (c) 2011 protos software gmbh (http://www.protos.de).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * CONTRIBUTORS:
 * 		Henrik Rentz-Reichert (initial contribution)
 */
package org.eclipse.etrice.generator.java.gen;

import com.google.common.base.Objects;
import com.google.inject.Inject;
import com.google.inject.Singleton;
import java.util.HashMap;
import java.util.List;
import org.eclipse.emf.common.util.EList;
import org.eclipse.etrice.core.fsm.fSM.ComponentCommunicationType;
import org.eclipse.etrice.core.fsm.fSM.DetailCode;
import org.eclipse.etrice.core.fsm.fSM.ModelComponent;
import org.eclipse.etrice.core.fsm.fSM.StateGraph;
import org.eclipse.etrice.core.genmodel.builder.GenmodelConstants;
import org.eclipse.etrice.core.genmodel.etricegen.ExpandedActorClass;
import org.eclipse.etrice.core.genmodel.etricegen.Root;
import org.eclipse.etrice.core.genmodel.etricegen.Wire;
import org.eclipse.etrice.core.genmodel.etricegen.WiredActorClass;
import org.eclipse.etrice.core.genmodel.etricegen.WiredStructureClass;
import org.eclipse.etrice.core.room.ActorClass;
import org.eclipse.etrice.core.room.ActorRef;
import org.eclipse.etrice.core.room.Attribute;
import org.eclipse.etrice.core.room.ClassStructor;
import org.eclipse.etrice.core.room.DataType;
import org.eclipse.etrice.core.room.EnumerationType;
import org.eclipse.etrice.core.room.InterfaceItem;
import org.eclipse.etrice.core.room.Message;
import org.eclipse.etrice.core.room.Port;
import org.eclipse.etrice.core.room.PrimitiveType;
import org.eclipse.etrice.core.room.ProtocolClass;
import org.eclipse.etrice.core.room.RefableType;
import org.eclipse.etrice.core.room.ReferenceType;
import org.eclipse.etrice.core.room.RoomModel;
import org.eclipse.etrice.core.room.SAP;
import org.eclipse.etrice.core.room.SPP;
import org.eclipse.etrice.core.room.ServiceImplementation;
import org.eclipse.etrice.core.room.StandardOperation;
import org.eclipse.etrice.core.room.VarDecl;
import org.eclipse.etrice.generator.base.AbstractGenerator;
import org.eclipse.etrice.generator.base.IDataConfiguration;
import org.eclipse.etrice.generator.fsm.base.FileSystemHelpers;
import org.eclipse.etrice.generator.fsm.base.IGeneratorFileIo;
import org.eclipse.etrice.generator.generic.GenericActorClassGenerator;
import org.eclipse.etrice.generator.generic.ProcedureHelpers;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.generic.TypeHelpers;
import org.eclipse.etrice.generator.java.Main;
import org.eclipse.etrice.generator.java.gen.ConfigGenAddon;
import org.eclipse.etrice.generator.java.gen.GlobalSettings;
import org.eclipse.etrice.generator.java.gen.Initialization;
import org.eclipse.etrice.generator.java.gen.JavaExtensions;
import org.eclipse.etrice.generator.java.gen.StateMachineGen;
import org.eclipse.xtend2.lib.StringConcatenation;
import org.eclipse.xtext.xbase.lib.Extension;
import org.eclipse.xtext.xbase.lib.Functions.Function1;
import org.eclipse.xtext.xbase.lib.IterableExtensions;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.eclipse.xtext.xbase.lib.StringExtensions;

@Singleton
@SuppressWarnings("all")
public class ActorClassGen extends GenericActorClassGenerator {
  @Inject
  private IGeneratorFileIo fileIO;
  
  @Inject
  @Extension
  private JavaExtensions _javaExtensions;
  
  @Inject
  @Extension
  private RoomExtensions _roomExtensions;
  
  @Inject
  private IDataConfiguration dataConfigExt;
  
  private final ConfigGenAddon configGenAddon;
  
  @Inject
  @Extension
  private ProcedureHelpers _procedureHelpers;
  
  @Inject
  @Extension
  private Initialization _initialization;
  
  @Inject
  @Extension
  private StateMachineGen _stateMachineGen;
  
  @Inject
  @Extension
  private TypeHelpers _typeHelpers;
  
  @Inject
  @Extension
  private FileSystemHelpers _fileSystemHelpers;
  
  @Inject
  public ActorClassGen(final ConfigGenAddon configGenAddon) {
    this.configGenAddon = configGenAddon;
  }
  
  public void doGenerate(final Root root) {
    final HashMap<ActorClass, WiredActorClass> ac2wired = new HashMap<ActorClass, WiredActorClass>();
    EList<WiredStructureClass> _wiredInstances = root.getWiredInstances();
    final Function1<WiredStructureClass, Boolean> _function = new Function1<WiredStructureClass, Boolean>() {
      public Boolean apply(final WiredStructureClass w) {
        return Boolean.valueOf((w instanceof WiredActorClass));
      }
    };
    Iterable<WiredStructureClass> _filter = IterableExtensions.<WiredStructureClass>filter(_wiredInstances, _function);
    final Procedure1<WiredStructureClass> _function_1 = new Procedure1<WiredStructureClass>() {
      public void apply(final WiredStructureClass w) {
        ActorClass _actorClass = ((WiredActorClass) w).getActorClass();
        ac2wired.put(_actorClass, ((WiredActorClass) w));
      }
    };
    IterableExtensions.<WiredStructureClass>forEach(_filter, _function_1);
    EList<ExpandedActorClass> _xpActorClasses = root.getXpActorClasses();
    final Function1<ExpandedActorClass, Boolean> _function_2 = new Function1<ExpandedActorClass, Boolean>() {
      public Boolean apply(final ExpandedActorClass cl) {
        ActorClass _actorClass = cl.getActorClass();
        return Boolean.valueOf(ActorClassGen.this._fileSystemHelpers.isValidGenerationLocation(_actorClass));
      }
    };
    Iterable<ExpandedActorClass> _filter_1 = IterableExtensions.<ExpandedActorClass>filter(_xpActorClasses, _function_2);
    for (final ExpandedActorClass xpac : _filter_1) {
      {
        ActorClass _actorClass = xpac.getActorClass();
        final WiredActorClass wired = ac2wired.get(_actorClass);
        ActorClass _actorClass_1 = xpac.getActorClass();
        final boolean manualBehavior = this._roomHelpers.isBehaviorAnnotationPresent(_actorClass_1, "BehaviorManual");
        ActorClass _actorClass_2 = xpac.getActorClass();
        String _generationTargetPath = this._roomExtensions.getGenerationTargetPath(_actorClass_2);
        ActorClass _actorClass_3 = xpac.getActorClass();
        String _path = this._roomExtensions.getPath(_actorClass_3);
        final String path = (_generationTargetPath + _path);
        ActorClass _actorClass_4 = xpac.getActorClass();
        String _generationInfoPath = this._roomExtensions.getGenerationInfoPath(_actorClass_4);
        ActorClass _actorClass_5 = xpac.getActorClass();
        String _path_1 = this._roomExtensions.getPath(_actorClass_5);
        final String infopath = (_generationInfoPath + _path_1);
        ActorClass _actorClass_6 = xpac.getActorClass();
        String file = this._javaExtensions.getJavaFileName(_actorClass_6);
        if (manualBehavior) {
          file = ("Abstract" + file);
        }
        CharSequence _generate = this.generate(root, xpac, wired, manualBehavior);
        this.fileIO.generateFile("generating ActorClass implementation", path, infopath, file, _generate);
      }
    }
  }
  
  public CharSequence generate(final Root root, final ExpandedActorClass xpac, final WiredActorClass wired, final boolean manualBehavior) {
    CharSequence _xblockexpression = null;
    {
      final ActorClass ac = xpac.getActorClass();
      String _xifexpression = null;
      if (manualBehavior) {
        String _name = ac.getName();
        _xifexpression = ("Abstract" + _name);
      } else {
        _xifexpression = ac.getName();
      }
      final String clsname = _xifexpression;
      EList<ClassStructor> _structors = ac.getStructors();
      final Function1<ClassStructor, Boolean> _function = new Function1<ClassStructor, Boolean>() {
        public Boolean apply(final ClassStructor it) {
          return Boolean.valueOf(it.isConstructor());
        }
      };
      final ClassStructor ctor = IterableExtensions.<ClassStructor>findFirst(_structors, _function);
      EList<ClassStructor> _structors_1 = ac.getStructors();
      final Function1<ClassStructor, Boolean> _function_1 = new Function1<ClassStructor, Boolean>() {
        public Boolean apply(final ClassStructor it) {
          boolean _isConstructor = it.isConstructor();
          return Boolean.valueOf((!_isConstructor));
        }
      };
      final ClassStructor dtor = IterableExtensions.<ClassStructor>findFirst(_structors_1, _function_1);
      final EList<RoomModel> models = root.getReferencedModels(ac);
      String _xifexpression_1 = null;
      GlobalSettings _settings = Main.getSettings();
      boolean _isGeneratePersistenceInterface = _settings.isGeneratePersistenceInterface();
      if (_isGeneratePersistenceInterface) {
        _xifexpression_1 = "implements IPersistable ";
      } else {
        _xifexpression_1 = "";
      }
      final String impPersist = _xifexpression_1;
      String _name_1 = ac.getName();
      final String dataObjClass = (_name_1 + "_DataObject");
      String _xifexpression_2 = null;
      ActorClass _actorBase = ac.getActorBase();
      boolean _notEquals = (!Objects.equal(_actorBase, null));
      if (_notEquals) {
        ActorClass _actorBase_1 = ac.getActorBase();
        _xifexpression_2 = _actorBase_1.getName();
      } else {
        String _xifexpression_3 = null;
        String _attribute = this._roomHelpers.getAttribute(ac, "ActorBaseClass", "class");
        boolean _isEmpty = _attribute.isEmpty();
        boolean _not = (!_isEmpty);
        if (_not) {
          _xifexpression_3 = this._roomHelpers.getAttribute(ac, "ActorBaseClass", "class");
        } else {
          String _xifexpression_4 = null;
          GlobalSettings _settings_1 = Main.getSettings();
          boolean _isGenerateStoreDataObj = _settings_1.isGenerateStoreDataObj();
          if (_isGenerateStoreDataObj) {
            _xifexpression_4 = "ActorClassFinalActionBase";
          } else {
            _xifexpression_4 = "ActorClassBase";
          }
          _xifexpression_3 = _xifexpression_4;
        }
        _xifexpression_2 = _xifexpression_3;
      }
      final String baseClass = _xifexpression_2;
      StringConcatenation _builder = new StringConcatenation();
      _builder.append("package ");
      String _package = this._roomExtensions.getPackage(ac);
      _builder.append(_package, "");
      _builder.append(";");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      {
        List<Attribute> _dynConfigReadAttributes = this.dataConfigExt.getDynConfigReadAttributes(ac);
        boolean _isEmpty_1 = _dynConfigReadAttributes.isEmpty();
        boolean _not_1 = (!_isEmpty_1);
        if (_not_1) {
          _builder.append("import org.eclipse.etrice.runtime.java.config.DynConfigLock;");
          _builder.newLine();
        }
      }
      {
        GlobalSettings _settings_2 = Main.getSettings();
        boolean _isGeneratePersistenceInterface_1 = _settings_2.isGeneratePersistenceInterface();
        if (_isGeneratePersistenceInterface_1) {
          _builder.append("import org.eclipse.etrice.runtime.java.modelbase.IPersistable;");
          _builder.newLine();
          _builder.append("import java.io.IOException;");
          _builder.newLine();
          _builder.append("import java.io.ObjectInput;");
          _builder.newLine();
          _builder.append("import java.io.ObjectOutput;");
          _builder.newLine();
        }
      }
      {
        GlobalSettings _settings_3 = Main.getSettings();
        boolean _isGenerateStoreDataObj_1 = _settings_3.isGenerateStoreDataObj();
        if (_isGenerateStoreDataObj_1) {
          _builder.append("import java.util.Arrays;");
          _builder.newLine();
        }
      }
      _builder.append("import org.eclipse.etrice.runtime.java.messaging.*;");
      _builder.newLine();
      _builder.append("import org.eclipse.etrice.runtime.java.modelbase.*;");
      _builder.newLine();
      _builder.append("import org.eclipse.etrice.runtime.java.debugging.*;");
      _builder.newLine();
      _builder.newLine();
      _builder.append("import static org.eclipse.etrice.runtime.java.etunit.EtUnit.*;");
      _builder.newLine();
      _builder.newLine();
      {
        for(final RoomModel model : models) {
          _builder.append("import ");
          String _name_2 = model.getName();
          _builder.append(_name_2, "");
          _builder.append(".*;");
          _builder.newLineIfNotEmpty();
        }
      }
      {
        EList<ProtocolClass> _referencedProtocolClasses = root.getReferencedProtocolClasses(ac);
        for(final ProtocolClass pc : _referencedProtocolClasses) {
          _builder.append("import ");
          String _package_1 = this._roomExtensions.getPackage(pc);
          _builder.append(_package_1, "");
          _builder.append(".");
          String _name_3 = pc.getName();
          _builder.append(_name_3, "");
          _builder.append(".*;");
          _builder.newLineIfNotEmpty();
        }
      }
      {
        EList<ActorRef> _actorRefs = ac.getActorRefs();
        final Function1<ActorRef, Boolean> _function_2 = new Function1<ActorRef, Boolean>() {
          public Boolean apply(final ActorRef r) {
            ReferenceType _refType = r.getRefType();
            return Boolean.valueOf(Objects.equal(_refType, ReferenceType.OPTIONAL));
          }
        };
        Iterable<ActorRef> _filter = IterableExtensions.<ActorRef>filter(_actorRefs, _function_2);
        for(final ActorRef sub : _filter) {
          _builder.append("import ");
          ActorClass _type = sub.getType();
          String _package_2 = this._roomExtensions.getPackage(_type);
          _builder.append(_package_2, "");
          _builder.append(".");
          ActorClass _type_1 = sub.getType();
          String _name_4 = _type_1.getName();
          _builder.append(_name_4, "");
          _builder.append("Interface;");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.newLine();
      CharSequence _userCode = this._procedureHelpers.userCode(ac, 1, true);
      _builder.append(_userCode, "");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.newLine();
      _builder.append("public ");
      {
        boolean _or = false;
        if (manualBehavior) {
          _or = true;
        } else {
          boolean _isAbstract = ac.isAbstract();
          _or = _isAbstract;
        }
        if (_or) {
          _builder.append("abstract ");
        }
      }
      _builder.append("class ");
      _builder.append(clsname, "");
      _builder.append(" extends ");
      _builder.append(baseClass, "");
      _builder.append(" ");
      _builder.append(impPersist, "");
      _builder.append("{");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("\t");
      CharSequence _userCode_1 = this._procedureHelpers.userCode(ac, 2, false);
      _builder.append(_userCode_1, "\t");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("//--------------------- ports");
      _builder.newLine();
      {
        List<Port> _endPorts = this._roomHelpers.getEndPorts(ac);
        for(final Port ep : _endPorts) {
          _builder.append("\t");
          _builder.append("protected ");
          String _portClassName = this._roomExtensions.getPortClassName(ep);
          _builder.append(_portClassName, "\t");
          _builder.append(" ");
          String _name_5 = ep.getName();
          _builder.append(_name_5, "\t");
          _builder.append(" = null;");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("//--------------------- saps");
      _builder.newLine();
      {
        EList<SAP> _serviceAccessPoints = ac.getServiceAccessPoints();
        for(final SAP sap : _serviceAccessPoints) {
          _builder.append("\t");
          _builder.append("protected ");
          String _portClassName_1 = this._roomExtensions.getPortClassName(sap);
          _builder.append(_portClassName_1, "\t");
          _builder.append(" ");
          String _name_6 = sap.getName();
          _builder.append(_name_6, "\t");
          _builder.append(" = null;");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("//--------------------- services");
      _builder.newLine();
      {
        EList<ServiceImplementation> _serviceImplementations = ac.getServiceImplementations();
        for(final ServiceImplementation svc : _serviceImplementations) {
          _builder.append("\t");
          _builder.append("protected ");
          String _portClassName_2 = this._roomExtensions.getPortClassName(svc);
          _builder.append(_portClassName_2, "\t");
          _builder.append(" ");
          SPP _spp = svc.getSpp();
          String _name_7 = _spp.getName();
          _builder.append(_name_7, "\t");
          _builder.append(" = null;");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("//--------------------- optional actors");
      _builder.newLine();
      {
        EList<ActorRef> _actorRefs_1 = ac.getActorRefs();
        final Function1<ActorRef, Boolean> _function_3 = new Function1<ActorRef, Boolean>() {
          public Boolean apply(final ActorRef r) {
            ReferenceType _refType = r.getRefType();
            return Boolean.valueOf(Objects.equal(_refType, ReferenceType.OPTIONAL));
          }
        };
        Iterable<ActorRef> _filter_1 = IterableExtensions.<ActorRef>filter(_actorRefs_1, _function_3);
        for(final ActorRef sub_1 : _filter_1) {
          _builder.append("\t");
          _builder.append("protected ");
          ActorClass _type_2 = sub_1.getType();
          String _name_8 = _type_2.getName();
          _builder.append(_name_8, "\t");
          {
            int _multiplicity = sub_1.getMultiplicity();
            boolean _notEquals_1 = (_multiplicity != 1);
            if (_notEquals_1) {
              _builder.append("Replicated");
            }
          }
          _builder.append("Interface ");
          String _name_9 = sub_1.getName();
          _builder.append(_name_9, "\t");
          _builder.append(" = null;");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("//--------------------- interface item IDs");
      _builder.newLine();
      _builder.append("\t");
      String _genInterfaceItemConstants = this.genInterfaceItemConstants(xpac);
      _builder.append(_genInterfaceItemConstants, "\t");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      String _genMinMaxConstants = this.configGenAddon.genMinMaxConstants(ac);
      _builder.append(_genMinMaxConstants, "\t");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      EList<Attribute> _attributes = ac.getAttributes();
      CharSequence _attributes_1 = this._procedureHelpers.attributes(_attributes);
      _builder.append(_attributes_1, "\t");
      _builder.newLineIfNotEmpty();
      {
        List<Attribute> _dynConfigReadAttributes_1 = this.dataConfigExt.getDynConfigReadAttributes(ac);
        for(final Attribute a : _dynConfigReadAttributes_1) {
          _builder.append("\t");
          _builder.append("private DynConfigLock lock_");
          String _name_10 = a.getName();
          _builder.append(_name_10, "\t");
          _builder.append(";");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("\t");
      EList<StandardOperation> _operations = ac.getOperations();
      String _name_11 = ac.getName();
      CharSequence _operationsImplementation = this._procedureHelpers.operationsImplementation(_operations, _name_11);
      _builder.append(_operationsImplementation, "\t");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("// user defined destructor");
      _builder.newLine();
      _builder.append("\t");
      String _name_12 = ac.getName();
      CharSequence _destructorSignature = this._procedureHelpers.getDestructorSignature(_name_12);
      _builder.append(_destructorSignature, "\t");
      _builder.append("{");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      {
        ModelComponent _base = ac.getBase();
        boolean _notEquals_2 = (!Objects.equal(_base, null));
        if (_notEquals_2) {
          _builder.append("super.dtor();");
        }
      }
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      {
        boolean _notEquals_3 = (!Objects.equal(dtor, null));
        if (_notEquals_3) {
          AbstractGenerator _instance = AbstractGenerator.getInstance();
          DetailCode _detailCode = dtor.getDetailCode();
          String _translatedCode = _instance.getTranslatedCode(_detailCode);
          _builder.append(_translatedCode, "\t\t");
        }
      }
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      _builder.newLine();
      _builder.append("\t");
      _builder.append("//--------------------- construction");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("public ");
      _builder.append(clsname, "\t");
      _builder.append("(IRTObject parent, String name) {");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.append("super(parent, name);");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("setClassName(\"");
      String _name_13 = ac.getName();
      _builder.append(_name_13, "\t\t");
      _builder.append("\");");
      _builder.newLineIfNotEmpty();
      _builder.append("\t\t");
      _builder.newLine();
      _builder.append("\t\t");
      EList<Attribute> _attributes_2 = ac.getAttributes();
      CharSequence _attributeInitialization = this._initialization.attributeInitialization(_attributes_2, ac, false);
      _builder.append(_attributeInitialization, "\t\t");
      _builder.newLineIfNotEmpty();
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("// own ports");
      _builder.newLine();
      {
        List<Port> _endPorts_1 = this._roomHelpers.getEndPorts(ac);
        for(final Port ep_1 : _endPorts_1) {
          _builder.append("\t\t");
          String _name_14 = ep_1.getName();
          _builder.append(_name_14, "\t\t");
          _builder.append(" = new ");
          String _portClassName_3 = this._roomExtensions.getPortClassName(ep_1);
          _builder.append(_portClassName_3, "\t\t");
          _builder.append("(this, \"");
          String _name_15 = ep_1.getName();
          _builder.append(_name_15, "\t\t");
          _builder.append("\", ");
          String _ifItemId = this.getIfItemId(ep_1);
          _builder.append(_ifItemId, "\t\t");
          _builder.append(");");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("\t\t");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("// own saps");
      _builder.newLine();
      {
        EList<SAP> _serviceAccessPoints_1 = ac.getServiceAccessPoints();
        for(final SAP sap_1 : _serviceAccessPoints_1) {
          _builder.append("\t\t");
          String _name_16 = sap_1.getName();
          _builder.append(_name_16, "\t\t");
          _builder.append(" = new ");
          String _portClassName_4 = this._roomExtensions.getPortClassName(sap_1);
          _builder.append(_portClassName_4, "\t\t");
          _builder.append("(this, \"");
          String _name_17 = sap_1.getName();
          _builder.append(_name_17, "\t\t");
          _builder.append("\", ");
          String _ifItemId_1 = this.getIfItemId(sap_1);
          _builder.append(_ifItemId_1, "\t\t");
          _builder.append(", 0);");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("\t\t");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("// own service implementations");
      _builder.newLine();
      {
        EList<ServiceImplementation> _serviceImplementations_1 = ac.getServiceImplementations();
        for(final ServiceImplementation svc_1 : _serviceImplementations_1) {
          _builder.append("\t\t");
          SPP _spp_1 = svc_1.getSpp();
          String _name_18 = _spp_1.getName();
          _builder.append(_name_18, "\t\t");
          _builder.append(" = new ");
          String _portClassName_5 = this._roomExtensions.getPortClassName(svc_1);
          _builder.append(_portClassName_5, "\t\t");
          _builder.append("(this, \"");
          SPP _spp_2 = svc_1.getSpp();
          String _name_19 = _spp_2.getName();
          _builder.append(_name_19, "\t\t");
          _builder.append("\", ");
          SPP _spp_3 = svc_1.getSpp();
          String _ifItemId_2 = this.getIfItemId(_spp_3);
          _builder.append(_ifItemId_2, "\t\t");
          _builder.append(");");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("\t\t");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("// sub actors");
      _builder.newLine();
      {
        EList<ActorRef> _actorRefs_2 = ac.getActorRefs();
        for(final ActorRef sub_2 : _actorRefs_2) {
          {
            ReferenceType _refType = sub_2.getRefType();
            boolean _equals = Objects.equal(_refType, ReferenceType.OPTIONAL);
            if (_equals) {
              _builder.append("\t\t");
              String _name_20 = sub_2.getName();
              _builder.append(_name_20, "\t\t");
              _builder.append(" = new ");
              ActorClass _type_3 = sub_2.getType();
              String _name_21 = _type_3.getName();
              _builder.append(_name_21, "\t\t");
              {
                int _multiplicity_1 = sub_2.getMultiplicity();
                boolean _notEquals_4 = (_multiplicity_1 != 1);
                if (_notEquals_4) {
                  _builder.append("Replicated");
                }
              }
              _builder.append("Interface(this, \"");
              String _name_22 = sub_2.getName();
              _builder.append(_name_22, "\t\t");
              _builder.append("\");");
              _builder.newLineIfNotEmpty();
            } else {
              int _multiplicity_2 = sub_2.getMultiplicity();
              boolean _greaterThan = (_multiplicity_2 > 1);
              if (_greaterThan) {
                _builder.append("\t\t");
                _builder.append("for (int i=0; i<");
                int _multiplicity_3 = sub_2.getMultiplicity();
                _builder.append(_multiplicity_3, "\t\t");
                _builder.append("; ++i) {");
                _builder.newLineIfNotEmpty();
                {
                  GlobalSettings _settings_4 = Main.getSettings();
                  boolean _generateMSCInstrumentation = _settings_4.generateMSCInstrumentation();
                  if (_generateMSCInstrumentation) {
                    _builder.append("\t\t");
                    _builder.append("\t");
                    _builder.append("DebuggingService.getInstance().addMessageActorCreate(this, \"");
                    String _name_23 = sub_2.getName();
                    _builder.append(_name_23, "\t\t\t");
                    _builder.append(GenmodelConstants.INDEX_SEP, "\t\t\t");
                    _builder.append("\"+i);");
                    _builder.newLineIfNotEmpty();
                  }
                }
                _builder.append("\t\t");
                _builder.append("\t");
                _builder.append("new ");
                ActorClass _type_4 = sub_2.getType();
                String _name_24 = _type_4.getName();
                _builder.append(_name_24, "\t\t\t");
                _builder.append("(this, \"");
                String _name_25 = sub_2.getName();
                _builder.append(_name_25, "\t\t\t");
                _builder.append(GenmodelConstants.INDEX_SEP, "\t\t\t");
                _builder.append("\"+i);");
                _builder.newLineIfNotEmpty();
                _builder.append("\t\t");
                _builder.append("}");
                _builder.newLine();
              } else {
                {
                  GlobalSettings _settings_5 = Main.getSettings();
                  boolean _generateMSCInstrumentation_1 = _settings_5.generateMSCInstrumentation();
                  if (_generateMSCInstrumentation_1) {
                    _builder.append("\t\t");
                    _builder.append("DebuggingService.getInstance().addMessageActorCreate(this, \"");
                    String _name_26 = sub_2.getName();
                    _builder.append(_name_26, "\t\t");
                    _builder.append("\");");
                    _builder.newLineIfNotEmpty();
                  }
                }
                _builder.append("\t\t");
                _builder.append("new ");
                ActorClass _type_5 = sub_2.getType();
                String _name_27 = _type_5.getName();
                _builder.append(_name_27, "\t\t");
                _builder.append("(this, \"");
                String _name_28 = sub_2.getName();
                _builder.append(_name_28, "\t\t");
                _builder.append("\");");
                _builder.newLineIfNotEmpty();
              }
            }
          }
        }
      }
      _builder.append("\t\t");
      _builder.newLine();
      _builder.append("\t\t");
      _builder.append("// wiring");
      _builder.newLine();
      {
        EList<Wire> _wires = wired.getWires();
        for(final Wire wire : _wires) {
          _builder.append("\t\t");
          String _xifexpression_5 = null;
          boolean _isDataDriven = wire.isDataDriven();
          if (_isDataDriven) {
            _xifexpression_5 = "DataPortBase";
          } else {
            _xifexpression_5 = "InterfaceItemBase";
          }
          _builder.append(_xifexpression_5, "\t\t");
          _builder.append(".connect(this, \"");
          EList<String> _path1 = wire.getPath1();
          String _join = IterableExtensions.join(_path1, "/");
          _builder.append(_join, "\t\t");
          _builder.append("\", \"");
          EList<String> _path2 = wire.getPath2();
          String _join_1 = IterableExtensions.join(_path2, "/");
          _builder.append(_join_1, "\t\t");
          _builder.append("\");");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.append("\t\t");
      _builder.newLine();
      {
        boolean _or_1 = false;
        ComponentCommunicationType _commType = ac.getCommType();
        boolean _equals_1 = Objects.equal(_commType, ComponentCommunicationType.ASYNCHRONOUS);
        if (_equals_1) {
          _or_1 = true;
        } else {
          ComponentCommunicationType _commType_1 = ac.getCommType();
          boolean _equals_2 = Objects.equal(_commType_1, ComponentCommunicationType.DATA_DRIVEN);
          _or_1 = _equals_2;
        }
        if (_or_1) {
          _builder.append("\t\t");
          _builder.append("// activate polling for data-driven communication");
          _builder.newLine();
          _builder.append("\t\t");
          _builder.append("RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(getThread()).addPollingMessageReceiver(this);");
          _builder.newLine();
        }
      }
      _builder.append("\t\t");
      _builder.newLine();
      {
        boolean _notEquals_5 = (!Objects.equal(ctor, null));
        if (_notEquals_5) {
          _builder.append("\t\t");
          _builder.append("{");
          _builder.newLine();
          _builder.append("\t\t");
          _builder.append("\t");
          _builder.append("// user defined constructor body");
          _builder.newLine();
          _builder.append("\t\t");
          _builder.append("\t");
          AbstractGenerator _instance_1 = AbstractGenerator.getInstance();
          DetailCode _detailCode_1 = ctor.getDetailCode();
          String _translatedCode_1 = _instance_1.getTranslatedCode(_detailCode_1);
          _builder.append(_translatedCode_1, "\t\t\t");
          _builder.newLineIfNotEmpty();
          _builder.append("\t\t");
          _builder.append("}");
          _builder.newLine();
        }
      }
      _builder.newLine();
      {
        boolean _or_2 = false;
        List<Attribute> _dynConfigReadAttributes_2 = this.dataConfigExt.getDynConfigReadAttributes(ac);
        boolean _isEmpty_2 = _dynConfigReadAttributes_2.isEmpty();
        boolean _not_2 = (!_isEmpty_2);
        if (_not_2) {
          _or_2 = true;
        } else {
          List<Attribute> _dynConfigWriteAttributes = this.dataConfigExt.getDynConfigWriteAttributes(ac);
          boolean _isEmpty_3 = _dynConfigWriteAttributes.isEmpty();
          boolean _not_3 = (!_isEmpty_3);
          _or_2 = _not_3;
        }
        if (_or_2) {
          {
            List<Attribute> _dynConfigReadAttributes_3 = this.dataConfigExt.getDynConfigReadAttributes(ac);
            for(final Attribute a_1 : _dynConfigReadAttributes_3) {
              _builder.append("\t\t");
              _builder.append("lock_");
              String _name_29 = a_1.getName();
              _builder.append(_name_29, "\t\t");
              _builder.append(" = new DynConfigLock();");
              _builder.newLineIfNotEmpty();
            }
          }
        }
      }
      _builder.append("\t");
      _builder.append("}");
      _builder.newLine();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      EList<Attribute> _attributes_3 = ac.getAttributes();
      List<Attribute> _dynConfigReadAttributes_4 = this.dataConfigExt.getDynConfigReadAttributes(ac);
      List<Attribute> _minus = this._roomExtensions.<Attribute>minus(_attributes_3, _dynConfigReadAttributes_4);
      String _name_30 = ac.getName();
      CharSequence _attributeSettersGettersImplementation = this._procedureHelpers.attributeSettersGettersImplementation(_minus, _name_30);
      _builder.append(_attributeSettersGettersImplementation, "\t");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      CharSequence _genDynConfigGetterSetter = this.configGenAddon.genDynConfigGetterSetter(ac);
      _builder.append(_genDynConfigGetterSetter, "\t");
      _builder.newLineIfNotEmpty();
      _builder.append("\t");
      _builder.newLine();
      _builder.append("\t");
      _builder.append("//--------------------- port getters");
      _builder.newLine();
      {
        List<Port> _endPorts_2 = this._roomHelpers.getEndPorts(ac);
        for(final Port ep_2 : _endPorts_2) {
          _builder.append("\t");
          String _portClassName_6 = this._roomExtensions.getPortClassName(ep_2);
          String _name_31 = ep_2.getName();
          String _name_32 = ac.getName();
          CharSequence _terImplementation = this._procedureHelpers.getterImplementation(_portClassName_6, _name_31, _name_32);
          _builder.append(_terImplementation, "\t");
          _builder.newLineIfNotEmpty();
        }
      }
      {
        EList<SAP> _serviceAccessPoints_2 = ac.getServiceAccessPoints();
        for(final SAP sap_2 : _serviceAccessPoints_2) {
          _builder.append("\t");
          String _portClassName_7 = this._roomExtensions.getPortClassName(sap_2);
          String _name_33 = sap_2.getName();
          String _name_34 = ac.getName();
          CharSequence _terImplementation_1 = this._procedureHelpers.getterImplementation(_portClassName_7, _name_33, _name_34);
          _builder.append(_terImplementation_1, "\t");
          _builder.newLineIfNotEmpty();
        }
      }
      {
        EList<ServiceImplementation> _serviceImplementations_2 = ac.getServiceImplementations();
        for(final ServiceImplementation svc_2 : _serviceImplementations_2) {
          _builder.append("\t");
          String _portClassName_8 = this._roomExtensions.getPortClassName(svc_2);
          SPP _spp_4 = svc_2.getSpp();
          String _name_35 = _spp_4.getName();
          String _name_36 = ac.getName();
          CharSequence _terImplementation_2 = this._procedureHelpers.getterImplementation(_portClassName_8, _name_35, _name_36);
          _builder.append(_terImplementation_2, "\t");
          _builder.newLineIfNotEmpty();
        }
      }
      _builder.newLine();
      _builder.append("\t");
      _builder.append("//--------------------- lifecycle functions");
      _builder.newLine();
      {
        boolean _overridesStop = this._roomExtensions.overridesStop(ac);
        boolean _not_4 = (!_overridesStop);
        if (_not_4) {
          {
            if (manualBehavior) {
              _builder.append("\t");
              _builder.append("public abstract void stop();");
              _builder.newLine();
            } else {
              _builder.append("\t");
              _builder.append("public void stop(){");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("stopUser();");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("super.stop();");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("}");
              _builder.newLine();
            }
          }
        }
      }
      _builder.append("\t");
      _builder.newLine();
      {
        if (manualBehavior) {
          _builder.append("\t");
          _builder.append("public abstract void destroy();");
          _builder.newLine();
        } else {
          _builder.append("\t");
          _builder.append("public void destroy(){");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("\t");
          _builder.append("if(this.getClass() == ");
          _builder.append(clsname, "\t\t");
          _builder.append(".class)");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.append("\t\t");
          _builder.append("dtor();");
          _builder.newLine();
          {
            GlobalSettings _settings_6 = Main.getSettings();
            boolean _generateMSCInstrumentation_2 = _settings_6.generateMSCInstrumentation();
            if (_generateMSCInstrumentation_2) {
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("DebuggingService.getInstance().addMessageActorDestroy(this);");
              _builder.newLine();
            }
          }
          {
            boolean _or_3 = false;
            ComponentCommunicationType _commType_2 = ac.getCommType();
            boolean _equals_3 = Objects.equal(_commType_2, ComponentCommunicationType.ASYNCHRONOUS);
            if (_equals_3) {
              _or_3 = true;
            } else {
              ComponentCommunicationType _commType_3 = ac.getCommType();
              boolean _equals_4 = Objects.equal(_commType_3, ComponentCommunicationType.DATA_DRIVEN);
              _or_3 = _equals_4;
            }
            if (_or_3) {
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(getThread()).removePollingMessageReceiver(this);");
              _builder.newLine();
            }
          }
          _builder.append("\t");
          _builder.append("\t");
          _builder.append("super.destroy();");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("}");
          _builder.newLine();
        }
      }
      _builder.newLine();
      {
        if (manualBehavior) {
          _builder.append("\t");
          _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {");
          _builder.newLine();
          {
            List<InterfaceItem> _allInterfaceItems = this._roomHelpers.getAllInterfaceItems(ac);
            boolean _hasElements = false;
            for(final InterfaceItem ifitem : _allInterfaceItems) {
              if (!_hasElements) {
                _hasElements = true;
              } else {
                _builder.appendImmediate("else ", "\t\t");
              }
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("if (ifitem==");
              String _name_37 = ifitem.getName();
              _builder.append(_name_37, "\t\t");
              _builder.append(") {");
              _builder.newLineIfNotEmpty();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("switch (evt) {");
              _builder.newLine();
              {
                List<Message> _incoming = this._roomHelpers.getIncoming(ifitem);
                for(final Message msg : _incoming) {
                  _builder.append("\t");
                  _builder.append("\t");
                  _builder.append("\t\t");
                  _builder.append("case ");
                  ProtocolClass _protocolClass = this._roomHelpers.getProtocolClass(msg);
                  String _name_38 = _protocolClass.getName();
                  _builder.append(_name_38, "\t\t\t\t");
                  _builder.append(".");
                  String _xifexpression_6 = null;
                  boolean _isIncoming = this._roomExtensions.isIncoming(msg);
                  if (_isIncoming) {
                    _xifexpression_6 = "IN_";
                  } else {
                    _xifexpression_6 = "OUT_";
                  }
                  _builder.append(_xifexpression_6, "\t\t\t\t");
                  String _name_39 = msg.getName();
                  _builder.append(_name_39, "\t\t\t\t");
                  _builder.append(":");
                  _builder.newLineIfNotEmpty();
                  {
                    VarDecl _data = msg.getData();
                    boolean _notEquals_6 = (!Objects.equal(_data, null));
                    if (_notEquals_6) {
                      _builder.append("\t");
                      _builder.append("\t");
                      _builder.append("\t\t");
                      _builder.append("\t");
                      _builder.append("{");
                      String _typedDataDefinition = this._javaExtensions.getTypedDataDefinition(msg);
                      _builder.append(_typedDataDefinition, "\t\t\t\t\t");
                      _builder.newLineIfNotEmpty();
                    }
                  }
                  _builder.append("\t");
                  _builder.append("\t");
                  _builder.append("\t\t");
                  _builder.append("\t");
                  _builder.append("on_");
                  String _name_40 = ifitem.getName();
                  _builder.append(_name_40, "\t\t\t\t\t");
                  _builder.append("_");
                  String _name_41 = msg.getName();
                  _builder.append(_name_41, "\t\t\t\t\t");
                  _builder.append("(ifitem");
                  {
                    VarDecl _data_1 = msg.getData();
                    boolean _notEquals_7 = (!Objects.equal(_data_1, null));
                    if (_notEquals_7) {
                      _builder.append(", ");
                      VarDecl _data_2 = msg.getData();
                      String _name_42 = _data_2.getName();
                      _builder.append(_name_42, "\t\t\t\t\t");
                    }
                  }
                  _builder.append(");");
                  _builder.newLineIfNotEmpty();
                  _builder.append("\t");
                  _builder.append("\t");
                  _builder.append("\t\t");
                  _builder.append("\t");
                  _builder.append("break;");
                  _builder.newLine();
                  {
                    VarDecl _data_3 = msg.getData();
                    boolean _notEquals_8 = (!Objects.equal(_data_3, null));
                    if (_notEquals_8) {
                      _builder.append("\t");
                      _builder.append("\t");
                      _builder.append("\t\t");
                      _builder.append("\t");
                      _builder.append("}");
                      _builder.newLine();
                    }
                  }
                }
              }
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("}");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("}");
              _builder.newLine();
            }
          }
          _builder.append("\t");
          _builder.append("}");
          _builder.newLine();
          {
            List<InterfaceItem> _allInterfaceItems_1 = this._roomHelpers.getAllInterfaceItems(ac);
            for(final InterfaceItem ifitem_1 : _allInterfaceItems_1) {
              {
                List<Message> _incoming_1 = this._roomHelpers.getIncoming(ifitem_1);
                for(final Message msg_1 : _incoming_1) {
                  _builder.append("\t");
                  _builder.append("protected void on_");
                  String _name_43 = ifitem_1.getName();
                  _builder.append(_name_43, "\t");
                  _builder.append("_");
                  String _name_44 = msg_1.getName();
                  _builder.append(_name_44, "\t");
                  _builder.append("(InterfaceItemBase ifitem");
                  {
                    VarDecl _data_4 = msg_1.getData();
                    boolean _notEquals_9 = (!Objects.equal(_data_4, null));
                    if (_notEquals_9) {
                      VarDecl _data_5 = msg_1.getData();
                      String[] _generateArglistAndTypedData = this._javaExtensions.generateArglistAndTypedData(_data_5);
                      String _get = _generateArglistAndTypedData[2];
                      _builder.append(_get, "\t");
                    }
                  }
                  _builder.append(") {}");
                  _builder.newLineIfNotEmpty();
                }
              }
            }
          }
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("public abstract void executeInitTransition();");
          _builder.newLine();
        } else {
          {
            boolean _hasNonEmptyStateMachine = this._roomHelpers.hasNonEmptyStateMachine(ac);
            if (_hasNonEmptyStateMachine) {
              _builder.append("\t");
              CharSequence _genStateMachine = this._stateMachineGen.genStateMachine(xpac);
              _builder.append(_genStateMachine, "\t");
              _builder.newLineIfNotEmpty();
              {
                ComponentCommunicationType _commType_4 = ac.getCommType();
                boolean _equals_5 = Objects.equal(_commType_4, ComponentCommunicationType.DATA_DRIVEN);
                if (_equals_5) {
                  _builder.append("\t");
                  _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object generic_data) {");
                  _builder.newLine();
                  _builder.append("\t");
                  _builder.append("\t");
                  _builder.append("handleSystemEvent(ifitem, evt, generic_data);");
                  _builder.newLine();
                  _builder.append("\t");
                  _builder.append("}");
                  _builder.newLine();
                }
              }
              {
                boolean _or_4 = false;
                ComponentCommunicationType _commType_5 = ac.getCommType();
                boolean _equals_6 = Objects.equal(_commType_5, ComponentCommunicationType.ASYNCHRONOUS);
                if (_equals_6) {
                  _or_4 = true;
                } else {
                  ComponentCommunicationType _commType_6 = ac.getCommType();
                  boolean _equals_7 = Objects.equal(_commType_6, ComponentCommunicationType.DATA_DRIVEN);
                  _or_4 = _equals_7;
                }
                if (_or_4) {
                  _builder.append("\t");
                  _builder.append("@Override");
                  _builder.newLine();
                  _builder.append("\t");
                  _builder.append("public void receive(Message msg) {");
                  _builder.newLine();
                  {
                    ComponentCommunicationType _commType_7 = ac.getCommType();
                    boolean _equals_8 = Objects.equal(_commType_7, ComponentCommunicationType.ASYNCHRONOUS);
                    if (_equals_8) {
                      _builder.append("\t");
                      _builder.append("\t");
                      _builder.append("receiveEvent(null, -1, null);");
                      _builder.newLine();
                    } else {
                      _builder.append("\t");
                      _builder.append("\t");
                      _builder.append("receiveEventInternal();");
                      _builder.newLine();
                    }
                  }
                  _builder.append("\t");
                  _builder.append("}");
                  _builder.newLine();
                }
              }
            } else {
              StateGraph _stateMachine = xpac.getStateMachine();
              boolean _isEmpty_4 = this._roomHelpers.isEmpty(_stateMachine);
              if (_isEmpty_4) {
                _builder.append("\t");
                _builder.append("//--------------------- no state machine");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("public void receiveEvent(InterfaceItemBase ifitem, int evt, Object data) {");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("\t");
                _builder.append("handleSystemEvent(ifitem, evt, data);");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("}");
                _builder.newLine();
                _builder.append("\t");
                _builder.newLine();
                _builder.append("\t");
                _builder.append("public void executeInitTransition() {}");
                _builder.newLine();
              }
            }
          }
        }
      }
      _builder.append("\t");
      _builder.newLine();
      {
        GlobalSettings _settings_7 = Main.getSettings();
        boolean _isGeneratePersistenceInterface_2 = _settings_7.isGeneratePersistenceInterface();
        if (_isGeneratePersistenceInterface_2) {
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("@Override");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("public void saveObject(ObjectOutput output) throws IOException {");
          _builder.newLine();
          {
            boolean _hasStateMachine = xpac.hasStateMachine();
            if (_hasStateMachine) {
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("// state and history");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("output.writeInt(getState());");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("for (int h: history) output.writeInt(h);");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.newLine();
            }
          }
          _builder.append("\t");
          _builder.append("\t");
          _builder.append("saveAttributes(output);");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("}");
          _builder.newLine();
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("protected void saveAttributes(ObjectOutput output) throws IOException {");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("\t");
          CharSequence _genSaveImpl = this.genSaveImpl(xpac);
          _builder.append(_genSaveImpl, "\t\t");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.append("}");
          _builder.newLine();
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("@Override");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("public void loadObject(ObjectInput input) throws IOException, ClassNotFoundException {");
          _builder.newLine();
          {
            boolean _hasStateMachine_1 = xpac.hasStateMachine();
            if (_hasStateMachine_1) {
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("// state and history");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("setState(input.readInt());");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("for (int i=0; i<history.length; ++i) history[i] = input.readInt();");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.newLine();
            }
          }
          _builder.append("\t");
          _builder.append("\t");
          _builder.append("loadAttributes(input);");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("}");
          _builder.newLine();
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("protected void loadAttributes(ObjectInput input) throws IOException, ClassNotFoundException {");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("\t");
          CharSequence _genLoadImpl = this.genLoadImpl(xpac);
          _builder.append(_genLoadImpl, "\t\t");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.append("}");
          _builder.newLine();
        }
      }
      {
        GlobalSettings _settings_8 = Main.getSettings();
        boolean _isGenerateStoreDataObj_2 = _settings_8.isGenerateStoreDataObj();
        if (_isGenerateStoreDataObj_2) {
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("protected void store(IActorClassDataObject obj) {");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("\t");
          _builder.append("if (!(obj instanceof ");
          _builder.append(dataObjClass, "\t\t");
          _builder.append("))");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.append("\t\t");
          _builder.append("return;");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("\t");
          _builder.append(dataObjClass, "\t\t");
          _builder.append(" dataObject = (");
          _builder.append(dataObjClass, "\t\t");
          _builder.append(") obj;");
          _builder.newLineIfNotEmpty();
          {
            ActorClass _actorBase_2 = ac.getActorBase();
            boolean _notEquals_10 = (!Objects.equal(_actorBase_2, null));
            if (_notEquals_10) {
              _builder.append("\t");
              _builder.append("\t");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("super.store(dataObject);");
              _builder.newLine();
            }
          }
          {
            boolean _hasNonEmptyStateMachine_1 = this._roomHelpers.hasNonEmptyStateMachine(ac);
            if (_hasNonEmptyStateMachine_1) {
              _builder.append("\t");
              _builder.append("\t");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("dataObject.setState(getState());");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("dataObject.setHistory(Arrays.copyOf(history, history.length));");
              _builder.newLine();
            }
          }
          {
            EList<Attribute> _attributes_4 = ac.getAttributes();
            boolean _isEmpty_5 = _attributes_4.isEmpty();
            boolean _not_5 = (!_isEmpty_5);
            if (_not_5) {
              _builder.append("\t");
              _builder.append("\t");
              _builder.newLine();
              {
                EList<Attribute> _attributes_5 = ac.getAttributes();
                for(final Attribute att : _attributes_5) {
                  {
                    RefableType _type_6 = att.getType();
                    DataType _type_7 = _type_6.getType();
                    boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(_type_7);
                    if (_isEnumerationOrPrimitive) {
                      {
                        int _size = att.getSize();
                        boolean _greaterThan_1 = (_size > 1);
                        if (_greaterThan_1) {
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("dataObject.set");
                          String _name_45 = att.getName();
                          String _firstUpper = StringExtensions.toFirstUpper(_name_45);
                          _builder.append(_firstUpper, "\t\t");
                          _builder.append("(Arrays.copyOf(");
                          String _name_46 = att.getName();
                          _builder.append(_name_46, "\t\t");
                          _builder.append(", ");
                          String _name_47 = att.getName();
                          _builder.append(_name_47, "\t\t");
                          _builder.append(".length));");
                          _builder.newLineIfNotEmpty();
                        } else {
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("dataObject.set");
                          String _name_48 = att.getName();
                          String _firstUpper_1 = StringExtensions.toFirstUpper(_name_48);
                          _builder.append(_firstUpper_1, "\t\t");
                          _builder.append("(");
                          String _name_49 = att.getName();
                          _builder.append(_name_49, "\t\t");
                          _builder.append(");");
                          _builder.newLineIfNotEmpty();
                        }
                      }
                    } else {
                      {
                        int _size_1 = att.getSize();
                        boolean _greaterThan_2 = (_size_1 > 1);
                        if (_greaterThan_2) {
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("{");
                          _builder.newLine();
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("\t");
                          RefableType _type_8 = att.getType();
                          DataType _type_9 = _type_8.getType();
                          String _name_50 = _type_9.getName();
                          _builder.append(_name_50, "\t\t\t");
                          _builder.append("[] arr = Arrays.copyOf(");
                          String _name_51 = att.getName();
                          _builder.append(_name_51, "\t\t\t");
                          _builder.append(", ");
                          String _name_52 = att.getName();
                          _builder.append(_name_52, "\t\t\t");
                          _builder.append(".length);");
                          _builder.newLineIfNotEmpty();
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("for(int i=0; i<arr.length; ++i) arr[i] = arr[i].deepCopy();");
                          _builder.newLine();
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("dataObject.set");
                          String _name_53 = att.getName();
                          String _firstUpper_2 = StringExtensions.toFirstUpper(_name_53);
                          _builder.append(_firstUpper_2, "\t\t\t");
                          _builder.append("(arr);");
                          _builder.newLineIfNotEmpty();
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("}");
                          _builder.newLine();
                        } else {
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("dataObject.set");
                          String _name_54 = att.getName();
                          String _firstUpper_3 = StringExtensions.toFirstUpper(_name_54);
                          _builder.append(_firstUpper_3, "\t\t");
                          _builder.append("(");
                          String _name_55 = att.getName();
                          _builder.append(_name_55, "\t\t");
                          _builder.append(".deepCopy());");
                          _builder.newLineIfNotEmpty();
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          _builder.append("\t");
          _builder.append("}");
          _builder.newLine();
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("protected void restore(IActorClassDataObject obj) {");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("\t");
          _builder.append("if (!(obj instanceof ");
          _builder.append(dataObjClass, "\t\t");
          _builder.append("))");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.append("\t\t");
          _builder.append("return;");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("\t");
          _builder.append(dataObjClass, "\t\t");
          _builder.append(" dataObject = (");
          _builder.append(dataObjClass, "\t\t");
          _builder.append(") obj;");
          _builder.newLineIfNotEmpty();
          {
            ActorClass _actorBase_3 = ac.getActorBase();
            boolean _notEquals_11 = (!Objects.equal(_actorBase_3, null));
            if (_notEquals_11) {
              _builder.append("\t");
              _builder.append("\t");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("super.restore(dataObject);");
              _builder.newLine();
            }
          }
          {
            boolean _hasNonEmptyStateMachine_2 = this._roomHelpers.hasNonEmptyStateMachine(ac);
            if (_hasNonEmptyStateMachine_2) {
              _builder.append("\t");
              _builder.append("\t");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("setState(dataObject.getState());");
              _builder.newLine();
              _builder.append("\t");
              _builder.append("\t");
              _builder.append("history = Arrays.copyOf(dataObject.getHistory(), dataObject.getHistory().length);");
              _builder.newLine();
            }
          }
          {
            EList<Attribute> _attributes_6 = ac.getAttributes();
            boolean _isEmpty_6 = _attributes_6.isEmpty();
            boolean _not_6 = (!_isEmpty_6);
            if (_not_6) {
              _builder.append("\t");
              _builder.append("\t");
              _builder.newLine();
              {
                EList<Attribute> _attributes_7 = ac.getAttributes();
                for(final Attribute att_1 : _attributes_7) {
                  {
                    RefableType _type_10 = att_1.getType();
                    DataType _type_11 = _type_10.getType();
                    boolean _isEnumerationOrPrimitive_1 = this._typeHelpers.isEnumerationOrPrimitive(_type_11);
                    if (_isEnumerationOrPrimitive_1) {
                      {
                        int _size_2 = att_1.getSize();
                        boolean _greaterThan_3 = (_size_2 > 1);
                        if (_greaterThan_3) {
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("set");
                          String _name_56 = att_1.getName();
                          String _firstUpper_4 = StringExtensions.toFirstUpper(_name_56);
                          _builder.append(_firstUpper_4, "\t\t");
                          _builder.append("(Arrays.copyOf(dataObject.get");
                          String _name_57 = att_1.getName();
                          String _firstUpper_5 = StringExtensions.toFirstUpper(_name_57);
                          _builder.append(_firstUpper_5, "\t\t");
                          _builder.append("(), ");
                          String _name_58 = att_1.getName();
                          _builder.append(_name_58, "\t\t");
                          _builder.append(".length));");
                          _builder.newLineIfNotEmpty();
                        } else {
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("set");
                          String _name_59 = att_1.getName();
                          String _firstUpper_6 = StringExtensions.toFirstUpper(_name_59);
                          _builder.append(_firstUpper_6, "\t\t");
                          _builder.append("(dataObject.get");
                          String _name_60 = att_1.getName();
                          String _firstUpper_7 = StringExtensions.toFirstUpper(_name_60);
                          _builder.append(_firstUpper_7, "\t\t");
                          _builder.append("());");
                          _builder.newLineIfNotEmpty();
                        }
                      }
                    } else {
                      {
                        int _size_3 = att_1.getSize();
                        boolean _greaterThan_4 = (_size_3 > 1);
                        if (_greaterThan_4) {
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("{");
                          _builder.newLine();
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("\t");
                          RefableType _type_12 = att_1.getType();
                          DataType _type_13 = _type_12.getType();
                          String _name_61 = _type_13.getName();
                          _builder.append(_name_61, "\t\t\t");
                          _builder.append("[] arr = Arrays.copyOf(dataObject.get");
                          String _name_62 = att_1.getName();
                          String _firstUpper_8 = StringExtensions.toFirstUpper(_name_62);
                          _builder.append(_firstUpper_8, "\t\t\t");
                          _builder.append("(), ");
                          String _name_63 = att_1.getName();
                          _builder.append(_name_63, "\t\t\t");
                          _builder.append(".length);");
                          _builder.newLineIfNotEmpty();
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("for(int i=0; i<arr.length; ++i) arr[i] = arr[i].deepCopy();");
                          _builder.newLine();
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("set");
                          String _name_64 = att_1.getName();
                          String _firstUpper_9 = StringExtensions.toFirstUpper(_name_64);
                          _builder.append(_firstUpper_9, "\t\t\t");
                          _builder.append("(arr);");
                          _builder.newLineIfNotEmpty();
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("}");
                          _builder.newLine();
                        } else {
                          _builder.append("\t");
                          _builder.append("\t");
                          _builder.append("set");
                          String _name_65 = att_1.getName();
                          String _firstUpper_10 = StringExtensions.toFirstUpper(_name_65);
                          _builder.append(_firstUpper_10, "\t\t");
                          _builder.append("(dataObject.get");
                          String _name_66 = att_1.getName();
                          String _firstUpper_11 = StringExtensions.toFirstUpper(_name_66);
                          _builder.append(_firstUpper_11, "\t\t");
                          _builder.append("().deepCopy());");
                          _builder.newLineIfNotEmpty();
                        }
                      }
                    }
                  }
                }
              }
            }
          }
          _builder.append("\t");
          _builder.append("}");
          _builder.newLine();
          _builder.append("\t");
          _builder.newLine();
          _builder.append("\t");
          _builder.append("protected ");
          _builder.append(dataObjClass, "\t");
          _builder.append(" newDataObject() {");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.append("\t");
          _builder.append("return new ");
          _builder.append(dataObjClass, "\t\t");
          _builder.append("();");
          _builder.newLineIfNotEmpty();
          _builder.append("\t");
          _builder.append("}");
          _builder.newLine();
        }
      }
      _builder.append("};");
      _builder.newLine();
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  private CharSequence genSaveImpl(final ExpandedActorClass xpac) {
    CharSequence _xblockexpression = null;
    {
      final ActorClass ac = xpac.getActorClass();
      StringConcatenation _builder = new StringConcatenation();
      {
        ActorClass _actorBase = ac.getActorBase();
        boolean _notEquals = (!Objects.equal(_actorBase, null));
        if (_notEquals) {
          _builder.append("super.saveAttributes(output);");
          _builder.newLine();
          _builder.newLine();
        }
      }
      {
        EList<Attribute> _attributes = ac.getAttributes();
        boolean _isEmpty = _attributes.isEmpty();
        boolean _not = (!_isEmpty);
        if (_not) {
          {
            EList<Attribute> _attributes_1 = ac.getAttributes();
            for(final Attribute att : _attributes_1) {
              {
                RefableType _type = att.getType();
                DataType _type_1 = _type.getType();
                boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(_type_1);
                if (_isEnumerationOrPrimitive) {
                  String _genSavePrimitive = this.genSavePrimitive(att);
                  _builder.append(_genSavePrimitive, "");
                  _builder.newLineIfNotEmpty();
                } else {
                  {
                    int _size = att.getSize();
                    boolean _greaterThan = (_size > 1);
                    if (_greaterThan) {
                      _builder.append("for (");
                      RefableType _type_2 = att.getType();
                      DataType _type_3 = _type_2.getType();
                      String _name = _type_3.getName();
                      _builder.append(_name, "");
                      _builder.append(" v: ");
                      String _name_1 = att.getName();
                      _builder.append(_name_1, "");
                      _builder.append(") output.writeObject(v);");
                      _builder.newLineIfNotEmpty();
                    } else {
                      _builder.append("output.writeObject(");
                      String _name_2 = att.getName();
                      _builder.append(_name_2, "");
                      _builder.append(");");
                      _builder.newLineIfNotEmpty();
                    }
                  }
                }
              }
            }
          }
        }
      }
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  private CharSequence genLoadImpl(final ExpandedActorClass xpac) {
    CharSequence _xblockexpression = null;
    {
      final ActorClass ac = xpac.getActorClass();
      StringConcatenation _builder = new StringConcatenation();
      {
        ActorClass _actorBase = ac.getActorBase();
        boolean _notEquals = (!Objects.equal(_actorBase, null));
        if (_notEquals) {
          _builder.append("super.loadAttributes(input);");
          _builder.newLine();
          _builder.newLine();
        }
      }
      {
        EList<Attribute> _attributes = ac.getAttributes();
        boolean _isEmpty = _attributes.isEmpty();
        boolean _not = (!_isEmpty);
        if (_not) {
          {
            EList<Attribute> _attributes_1 = ac.getAttributes();
            for(final Attribute att : _attributes_1) {
              {
                RefableType _type = att.getType();
                DataType _type_1 = _type.getType();
                boolean _isEnumerationOrPrimitive = this._typeHelpers.isEnumerationOrPrimitive(_type_1);
                if (_isEnumerationOrPrimitive) {
                  String _genLoadPrimitive = this.genLoadPrimitive(att);
                  _builder.append(_genLoadPrimitive, "");
                  _builder.newLineIfNotEmpty();
                } else {
                  {
                    int _size = att.getSize();
                    boolean _greaterThan = (_size > 1);
                    if (_greaterThan) {
                      _builder.append("for (int i=0; i< ");
                      String _name = att.getName();
                      _builder.append(_name, "");
                      _builder.append(".length; ++i) ");
                      String _name_1 = att.getName();
                      _builder.append(_name_1, "");
                      _builder.append("[i] = (");
                      RefableType _type_2 = att.getType();
                      DataType _type_3 = _type_2.getType();
                      String _name_2 = _type_3.getName();
                      _builder.append(_name_2, "");
                      _builder.append(") input.readObject();");
                      _builder.newLineIfNotEmpty();
                    } else {
                      String _name_3 = att.getName();
                      _builder.append(_name_3, "");
                      _builder.append(" = (");
                      RefableType _type_4 = att.getType();
                      DataType _type_5 = _type_4.getType();
                      String _name_4 = _type_5.getName();
                      _builder.append(_name_4, "");
                      _builder.append(") input.readObject();");
                      _builder.newLineIfNotEmpty();
                    }
                  }
                }
              }
            }
          }
        }
      }
      _xblockexpression = _builder;
    }
    return _xblockexpression;
  }
  
  private String genSavePrimitive(final Attribute att) {
    String _xblockexpression = null;
    {
      String _xifexpression = null;
      boolean _and = false;
      RefableType _type = att.getType();
      DataType _type_1 = _type.getType();
      if (!(_type_1 instanceof EnumerationType)) {
        _and = false;
      } else {
        RefableType _type_2 = att.getType();
        DataType _type_3 = _type_2.getType();
        PrimitiveType _primitiveType = ((EnumerationType) _type_3).getPrimitiveType();
        boolean _equals = Objects.equal(_primitiveType, null);
        _and = _equals;
      }
      if (_and) {
        _xifexpression = "int";
      } else {
        RefableType _type_4 = att.getType();
        DataType _type_5 = _type_4.getType();
        _xifexpression = this._typeHelpers.typeName(_type_5);
      }
      final String type = _xifexpression;
      final String method = this.getSaveMethod(type);
      String _xifexpression_1 = null;
      int _size = att.getSize();
      boolean _greaterThan = (_size > 0);
      if (_greaterThan) {
        String _name = att.getName();
        String _plus = ((("for (" + type) + " v: ") + _name);
        String _plus_1 = (_plus + ") output.");
        String _plus_2 = (_plus_1 + method);
        _xifexpression_1 = (_plus_2 + "(v);");
      } else {
        String _name_1 = att.getName();
        String _plus_3 = ((("output." + method) + "(") + _name_1);
        _xifexpression_1 = (_plus_3 + ");");
      }
      _xblockexpression = _xifexpression_1;
    }
    return _xblockexpression;
  }
  
  private String getSaveMethod(final String type) {
    String _switchResult = null;
    boolean _matched = false;
    if (!_matched) {
      if (Objects.equal(type, "boolean")) {
        _matched=true;
        _switchResult = "writeBoolean";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "char")) {
        _matched=true;
        _switchResult = "writeChar";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "byte")) {
        _matched=true;
        _switchResult = "writeByte";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "short")) {
        _matched=true;
        _switchResult = "writeShort";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "int")) {
        _matched=true;
        _switchResult = "write";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "long")) {
        _matched=true;
        _switchResult = "writeLong";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "float")) {
        _matched=true;
        _switchResult = "writeFloat";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "double")) {
        _matched=true;
        _switchResult = "writeDouble";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "String")) {
        _matched=true;
        _switchResult = "writeUTF";
      }
    }
    return _switchResult;
  }
  
  private String genLoadPrimitive(final Attribute att) {
    String _xblockexpression = null;
    {
      String _xifexpression = null;
      boolean _and = false;
      RefableType _type = att.getType();
      DataType _type_1 = _type.getType();
      if (!(_type_1 instanceof EnumerationType)) {
        _and = false;
      } else {
        RefableType _type_2 = att.getType();
        DataType _type_3 = _type_2.getType();
        PrimitiveType _primitiveType = ((EnumerationType) _type_3).getPrimitiveType();
        boolean _equals = Objects.equal(_primitiveType, null);
        _and = _equals;
      }
      if (_and) {
        _xifexpression = "int";
      } else {
        RefableType _type_4 = att.getType();
        DataType _type_5 = _type_4.getType();
        _xifexpression = this._typeHelpers.typeName(_type_5);
      }
      final String type = _xifexpression;
      final String method = this.getLoadMethod(type);
      String _xifexpression_1 = null;
      int _size = att.getSize();
      boolean _greaterThan = (_size > 0);
      if (_greaterThan) {
        String _name = att.getName();
        String _plus = ("for (int i=0; i<" + _name);
        String _plus_1 = (_plus + ".length; ++i) ");
        String _name_1 = att.getName();
        String _plus_2 = (_plus_1 + _name_1);
        String _plus_3 = (_plus_2 + "[i] = input.");
        String _plus_4 = (_plus_3 + method);
        _xifexpression_1 = (_plus_4 + "();");
      } else {
        String _name_2 = att.getName();
        String _plus_5 = (_name_2 + " = input.");
        String _plus_6 = (_plus_5 + method);
        _xifexpression_1 = (_plus_6 + "();");
      }
      _xblockexpression = _xifexpression_1;
    }
    return _xblockexpression;
  }
  
  private String getLoadMethod(final String type) {
    String _switchResult = null;
    boolean _matched = false;
    if (!_matched) {
      if (Objects.equal(type, "boolean")) {
        _matched=true;
        _switchResult = "readBoolean";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "char")) {
        _matched=true;
        _switchResult = "readChar";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "byte")) {
        _matched=true;
        _switchResult = "readByte";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "short")) {
        _matched=true;
        _switchResult = "readShort";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "int")) {
        _matched=true;
        _switchResult = "read";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "long")) {
        _matched=true;
        _switchResult = "readLong";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "float")) {
        _matched=true;
        _switchResult = "readFloat";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "double")) {
        _matched=true;
        _switchResult = "readDouble";
      }
    }
    if (!_matched) {
      if (Objects.equal(type, "String")) {
        _matched=true;
        _switchResult = "readUTF";
      }
    }
    return _switchResult;
  }
}

Back to the top