This approach
was therefore opposite to that of the previous CPL (Chapter 5) or other examples
described here that have a generator module for each domain concept. In the insurance
case the decision to use the same generator module for multiple domain concepts was
GENERATOR FOR JAVA 133
possible since the domain concepts were very similar and their main difference was
among the legal connections they could have (see Figs. 6.4 and 6.5).
As shown in the generator structure, a product had its own generator module. The
product concept was different from others since it created the product-speci?¬?c Java
class and acted as the main composite concept referring to other insurance-speci?¬?c
concepts. However, since the product concept was inherited from MOFClass and
Domain class (see Fig. 6.3), similar to other insurance-speci?¬?c modeling objects,
FIGURE 6.8 Structure of the generator
134 INSURANCE PRODUCTS
parts of the generators were the same. Therefore, those parts producing the common
MOFClass related code were put in their own generator modules for reuse. These
handled if the concept was a singleton, root, or leaf, and also produced code related to
constraints and operations. Listing 6.1 shows the generator for producing the
singleton code. In the generator de?¬?nition the ???multiplicity??? string in line 3 refers to
the property in a model element.
Pages:
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