UML Reverse engineering detects automatically the getter/setter method of an attribute. It takes into account the prefix and suffix preferences of JDT. The name without prefix and suffix will be used as model name, named as property.
If methods have the implementations, the UML reverse engineering analyse the code to make sure that the getter method returns this attribute value and the setter changes this attribute value.
For example, with the prefix setting of "f", in the following Java class that contains an attribute name = fCompany, the property name will be "company"
public class Employee
{
private Company fCompany;
public Company getCompany()
{
return fCompany;
}
public void setCompany(Company company)
{
fCompany = company;
}
}
public class Company
{
...
}
After the reverse engineering process, we find UML role name = company, instead of fCompany. The diagram looks like this :
And the code become :
public class Employee
{
/**
* @uml.property name="company" * @uml.associationEnd multiplicity="(0 1)" ordering="ordered"
* elementType="company.Company"
*/
private Company fCompany;
/**
* @uml.property name="company"
*/
public Company getCompany()
{
return fCompany;
}
/**
* @uml.property name="company"
*/
public void setCompany(Company company)
{
fCompany = company;
}
}
In
case of the abstract method: class abstract method or interface method, there
is no code to analyse. So the only solution is to analyse the method name and
signature according to JDT definition. The setter method is ignored if a getter
method is missing in the class/interface.