Advanced Systems Design with Java, UML and MDA

Once a platform-specific design has been produced, it can be used as the basis for an implementation in executable code. In this chapter we show the mapping from a Java PSM to Java code. The process is similar for other related languages such as C++ or C #.
Starting from the PSM diagrams and module descriptions, class definitions in Java can be produced, with some degree of automation. Each construct in the PSM class diagram needs to be mapped to a programming language construct. Table 6.1 lists the main correspondences for Java.
| Class Diagram Element | Java Program Construct |
|---|---|
| class | class |
| abstract class | abstract class |
| interface | interface |
| guarded class | synchronised class |
| leaf class | final class |
| utility class | static class |
| inheritance | extends |
| interface inheritance | implements |
| static attribute | static (class) attribute |
| non-static attribute | instance attribute |
| readOnly attribute | final attribute |
| abstract operation | abstract method |
| static operation | static method |
| non-static operation | instance method |
| guarded operation | synchronised method |
| identity attribute | no direct translation |
| association | attribute of class/collection type |
| constraint | no direct translation |
From this table it can be seen that most of the class diagram elements map quite directly to corresponding Java elements, merely with different keywords being used ( final instead of readOnly, etc). However the last three cases are more difficult. An identity attribute has the constraint that no two objects of the class can have the same value for it. This means that the constructor...