Getter/setter method recognition



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.

Concrete methods

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.

public class Employee
{
    /**
     * @uml property=company associationEnd={multiplicity={(0 1)} ordering=ordered 
     * elementType=company.Company}
     */
    private Company fCompany;
    /**
     * @uml property=company
     */
    public Company getCompany()
    {
        return fCompany;
    }
 
    /**
     * @uml property=company
     */
    public void setCompany(Company company)
    {
        fCompany = company;
    }
}
 

Abstract methods

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.

 
Last update Fri Mar 05 14:18:13 CEST 2004 All text, graphics © 2002-2004 by Omondo