PDA

View Full Version : Custom getters



paramosyermos
Jul 22nd, 2009, 04:22 PM
I like to use custom getters to show full data. eg:
class Person {
String fisrtName;
String lastName;

// my custom getter
public String getFullName() {
return firstName + " " + lastName;
}
}

Which are the best options to add this kind of getters? Does @RooJavaBean support this?

Ben Alex
Jul 22nd, 2009, 05:35 PM
Roo's automatic getter/setter creators just follow the JavaBean standard in terms of exposing a single field. You're best off to just write the method inside your entity's normal .java file. It won't cause any Roo problems, and indeed you'll notice Roo's toString() add-on automatic detects your new getter and includes it in the generated toString() method!