Cardinality detection

eUML2 Reverse Engineering Engine is capable to detect two groups of associations:

To classify an attribute type to one of the two groups; the key issue is container detection. In Java, there are two categories of containers: java.util.Collection and java.util.Map. eUML2 reverse engineering implements a mechanism to recognize not only the interface java.util.Collection and java.util.Map, but also their subtypes or implementation classes such as java.util.List, java.util.Vector, java.util.Hashtable.

Cardinality 0...1 or 1

For a simple reference, if the attribute is always initialised, the cardinality will be 1. Otherwise, it will be 0..1.

Examples of cardinality 0..1

Before Reverse Engineering

After Reverse Engineering

public class Company
{
	private Company company;
  public Company(Company company) {
  }
}
public class Company
{
  /**
   * @uml.property name="company"
   * @uml.associationEnd multiplicity="(0 1)"
   *         inverse="company:model.Employee"
   */
  private Company company;
  public Company(Company company) {
  }
}

Example of cardinality 1..1

Before Reverse Engineering

After Reverse Engineering

public class Company
{
	private Company company;
  public Company(Company company) {
     this.company = company;
  }
}
public class Company
{
  /**
   * @uml.property name="company"
   * @uml.associationEnd multiplicity="(1 1)"
   *         inverse="company:model.Employee"
   */
  private Company company;
  public Company(Company company) {
     this.company = company;
  }
}

 

Cardinality 0...*

A container has always the cardinality 0..*.

Example of collection

Before Reverse Engineering

After Reverse Engineering

public class Company
{
	private Collection employees = 
              new ArrayList();
}
public class Company
{
  /**
   * @uml.property name="employees"
   * @uml.associationEnd multiplicity="(0 -1)"
   *         inverse="company:model.Employee"
   */
	 private Collection employees = 
              new ArrayList();
}