In theory, an UML association consists of at least two association ends. eUML2 Modeler supports only the associations with two ends. All UML association data are stored in each association end, which corresponds a property. A property as an association end must is tagged by @uml.associationEnd. The other tags @uml.associationand @uml. associationStereotype are optional.
Here is an example of an association between Company and Employee:
The association has an UML stereotype of type Realization.
public class Employee
{ /**
* @uml.property name="company"
* @uml.associationEnd inverse="employees:database.Company"
* multiplicity="(0 1)"
* @uml.associationStereotype
* uml_id="Intermediate::Realization"
* @uml.association name="employment"
*/
private Company company; ... } public class Company
{
/**
* @uml.property name="employees"
* @uml.associationEnd inverse="company:database.Employee"
* multiplicity="(0 -1)"
* @uml.associationStereotype
* uml_id="Intermediate::Realization"
* @uml.association name="employment"
*/
private Collection employees; ... }
Let’s consider a complicate example: the n-ary qualified association. If all employees are classified by their positions, we have the following design.
public class Company
{
/**
* @uml.property name="employees"
* @uml.associationEnd inverse="company:model.Employee"
* qualifier="position:java.lang.String model.Employee"
* multiplicity="(0 -1)"
*/ private Map employeesMap; /**
* @uml.property name="employees"
*/ public Collection getEmployees(String key){ return (Collection) this.employeesMap.get(key); } ... }
public class Employee
{
/**
* @uml.property name="company"
* @uml.associationEnd inverse="employees:model.Company"
*/ private Company company; ... }
@uml.association (0…1)
Name |
Value Type |
Cardinality |
Default value |
Description |
Name |
String |
(0…1) |
“” |
The association name. |
@uml.associationStereotype (0…*)
Name |
Value Type |
Cardinality |
Default value |
Description |
uml_id |
String |
(1…1) |
|
It is the stereotype id from UML Profile for this association. |
identifier |
String |
(0…*) |
|
Each pair is used to store a value defined in the stereotype. |
@uml.associationEnd (1)
Name |
Value Type |
Cardinality |
Default value |
Description |
readOnly |
Boolean |
(0…1) |
“false” |
The value “true” indicates that the property can be read only. |
multiplicity |
String |
(0…1) |
“{0 1}”. |
The value contains two integer values enclosed by the brackets. The first is lower bound and the second is upper bound. |
dimension |
Integer |
(0…1) |
“0” |
This is an array dimension of Java field. It is another way to implement N-ary multiplicity. |
aggregation |
String |
(0…1) |
none |
The possible values are:
|
container |
String |
(0…1) |
java.util.Collection |
This attribute indicates the Java field type. It is necessary if the property is abstract and has n-ary multiplicity. In case of a qualified association with n-ary multiplicity, this attribute is used to specify the collection type. The old name “ javaType” still works. |
ordering |
String |
(0…1) |
“false” |
If the property is a collection, this attribute indicates whether the element is ordered. Two values of UML 1.x ca be used as well: “ordered” and “unordered” |
inverse |
String |
(0…1) |
|
This value indicates the inverse property. The value is composed of : <property name>:<qualified class name>. |
elementType |
String |
(0…1) |
|
This attribute is used to indicate the element type in collection. It is used only in unidirectional association. |
qualifier |
String |
(0…1) |
|
This attribute contains the qualifier definition if the association is qualified. It is composed of: <key name>:<qualified key type> <qualified value type> |