Gemini has been designed to maintain relationships between objects. The examples the project pages provide is for a Company-to-Employee relationship, where the Company has many Employees and the Employees have one company. Through the use of the two annotations provided (@BidirectionalOne and @BidirectionalMany), the object relationships can be maintained by modifying one object instead of having to manually set the relationships.
For example, an Employee being added to a company might require two method calls:
// assume company and employee have been instantiated
// does the equivalent of company.getEmployees().add(employee);
company.addEmployee(employee);
employee.setCompany(company);
However, with Gemini, only the first or the second method call is required. The synchronicity is maintained by the annotation code, rather than mandating that the programmer call both mutators. The code for this is expressed as follows:
class CompanyBean implements Company {
@BidirectionalMany(oppositeName="company")
List employees = new LinkedList();
public List getEmployees() {return this.employees;}
public void addEmployee(Employee e) { getEmployees().add(e);
public void setEmployees(List employees) {this.employees = employees;}
}
class EmployeeBean implements Employee {
@BidirectionalOne(oppositeName="employees",
oppositeType=BidirectionalMany.class)
private Company company;
public Company getCompany() {return this.company;}
public void setCompany(Company company) {this.company = company;}
}
Gemini is dual-licensed, under the GPL and under a commercial license (which costs $23 USD). Building with Gemini requires AspectJ at build time, but not at runtime.
Do you think functionality like this might be useful?