javaClass.addAnnotation(Deprecated.class);
JavaMethod accessor = new JavaMethod("getCount", int.class);
accessor.setMethodBody(
new MethodBody(accessor) {
@Override
public String toCode() {
return "return count;";
}
}
);
accessor.getModifiers().add(JavaModifier.PUBLIC);
accessor.getModifiers().add(JavaModifier.FINAL);
javaClass.addMethod(accessor);
JavaMethod mutator = new JavaMethod("setCount",
new Argument("i", int.class));
mutator.setMethodBody(
new MethodBody(mutator) {
@Override
public String toCode() {
return "count = i;";
}
}