Hi
I am now writing a xjc plugin adding a property named "id" to the java
file gennerated.
here is the fragment of java files gennerated with my plugin
..........................................
private long id;
public long getId() {
return id;
}
private void setId(long id) {
id = id;
}
..........................................
but my expected code is
..........................................
private long id;
public long getId() {
return this.id;
}
private void setId(long id) {
this.id = id;
}
..........................................
how can I get code expected?? Thanks.
here is the fragment of my plugin:
....................................
@Override
public boolean run(Outline outline, Options opt, ErrorHandler
errorHandler)
throws SAXException {
for (ClassOutline co : outline.getClasses()) {
JCodeModel codeModel = new JCodeModel();
JDefinedClass definedClass = co.implClass;
definedClass.annotate(Entity.class);
JFieldVar idFieldVar = definedClass.field(JMod.PRIVATE,
codeModel.LONG,"id");
JMethod getMethod = definedClass.method(JMod.PUBLIC,
codeModel.LONG,"getId");
JBlock getMethodblock =getMethod.body();
getMethodblock._return(idFieldVar);
JMethod setMethod = definedClass.method(JMod.PRIVATE,
codeModel.VOID,"setId");
JVar var =setMethod.param(codeModel.LONG, "id");
JBlock setMethodblock =setMethod.body();
}
......................................
Thanks.