Aleksei Valikov wrote:
>
>
> * You're creating a new subclass for your "GetLabel"-enabled fields. I
> don't think it is a good design decision. You'll have to create
> subclasses for all field classes out there. Essentially, you don't
> need this: better iterate over outline/class outlines/field outlines
> and generate additional getters, you don't need special field
> subclasses for this. This will be much simpler.
> * Direct statements in code model are evil. Code model was especially
> developed to produce the code programmatically. Try something like
> method.body()._return(JExpr.lit(label)).
> * You can have special-purpose XML customization for your plugin.
> Imagine something like:
>
>
Thanks for the tip, you're absolutely correct...
@Override
public boolean run(Outline model, Options opt, ErrorHandler
errorHandler) {
for(ClassOutline co : model.getClasses()) {
JDefinedClass clazz = co.implClass;
for (FieldOutline field : co.getDeclaredFields()) {
CPropertyInfo prop = field.getPropertyInfo();
String methodLabel = prop.getName(true);
String label = prop.javadoc.isEmpty() ? methodLabel : prop.javadoc;
label = label.replaceAll("\n", "\\\\n");
System.out.println(label);
// [RESULT]
// String getXXXLabel() {
// return "label";
// }
JMethod getLabel = clazz.method(JMod.PUBLIC, String.class,
"get"+methodLabel+"Label");
getLabel.body()._return(JExpr.lit(label));
}
}
return true;
}
Looks a lot better and simpler than the rubbish I had :)
--
View this message in context: http://www.nabble.com/Problem-with-xs%3Aelement-%3Exs%3Aannotation-%3Exs%3Adocumentation-for-a-simple-type-tp22431465p22434655.html
Sent from the java.net - jaxb users mailing list archive at Nabble.com.