Open GoogleCodeExporter opened 9 years ago
I can suggest to use something like the following to create getter and setter
method names in Methods.getter(field) and Methods.setter(field). It matches to
getter / setter names that are generated by Intellij Idea.
public static String getterName(JavaField field) {
if (field.getType().getKind() != JavaTypeKind.BOOLEAN) {
return field.getName().copy().insertPart(0, "get").toString();
}
final String firstPart = field.getName().getParts()[0];
if (firstPart.equals("is")) {
return field.getName().toString();
}
return field.getName().copy().insertPart(0, "is").toString();
}
public static String setterName(JavaField field) {
if (field.getType().getKind() == JavaTypeKind.BOOLEAN && field.getName().getParts()[0].equals("is")) {
return field.getName().copy().replacePart(0, "set").toString();
}
return field.getName().copy().insertPart(0, "set").toString();
}
Original comment by ora...@gmail.com
on 1 Apr 2013 at 11:32
Original issue reported on code.google.com by
ora...@gmail.com
on 29 Mar 2013 at 10:27