Class Diagrams
package corp;
import java.util.Date;
classdiagram MyCompany {
enum CorpKind { SOLE_PROPRIETOR, S_CORP, C_CORP, B_CORP, CLOSE_CORP, NON_PROFIT; }
abstract class Entity;
package people {
class Person extends Entity {
Date birthday;
List<String> nickNames;
-> Address [*] {ordered};
}
class Address {
String city;
String street;
int number;
}
}
class Company extends Entity {
CorpKind kind;
}
class Employee extends people.Person {
int salary;
}
class Share {
int value;
}
association [1..*] Company (employer) <-> Employee [*];
composition [1] Company <- Share [*];
association shareholding [1] Entity (shareholder) -- (owns) Share [*];
}
Comprehensive information
You can find comprehensive information on how to define types with cd4code [here][cd4analysis]. Moreover there are [several examples][examples] of cd4code models.
Special behavior of class diagram usage in MontiArc
There are some things that you should note when working with object oriented types in MontiArc:
Packages
Class diagrams themselves are defined within a package structure. However, they themselves also span a new package. E.g., take the following class diagram model:
package com.example;
classdiagram fingerprotection {
public enum FingerProtectionOrder {
PROTECT, PROTECTION_OFF;
}
}
FingerProtectionOrder
type will be located in the com.example.fingerprotection
package.
Note that the class diagram name becomes a part of the package name.
To use the type in MontiArc, one would be importing it at the beginning of the MontiArc model:
package com.example.window;
import com.example.fingerprotection.FingerProtectionOrder;
component WindowController { /*...*/ }
Calling constructors
compute {
personOutPort = Person.Person("Steven");
}
TypeName.methodName(/*arguments*/)
TypeName.TypeName(/*arguments*/)