Details
-
Type:
Improvement
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: documentation
-
Labels:None
-
Number of attachments :
Description
html doc for javabean properties (private field + public getter + public setter) should use the javadoc on the private field if any
Currently, the javadoc used is the one on the corresponding public getter, and the javadoc on the private field is ignored.
public getter/setters should be generated from the private fields, and code is 99% of times a simple pattern not worth reading at, so NO javadoc is used on these method patterns.
example in java:
public class MyPOJO {
/**
- field1 doc
- ...these field is very important in the model, so it is explained here...
*/
private int field1;
/** field2 doc */
private String field2;
//------------------
// the rest of the POJO class can be entierely generated
// example from eclipse:
// Menu> Source> generate empty constructor
// Menu> Source> generate getters & setters (without javadoc!)
...
public int getField1()
public void setField1(int value) { this.field1 = value; }
public String getField2() { return field2; }
public void setField2(String value) { this.field2 = value; }
...
}
it is not very elegant compared to C# syntaxic sugar "property .. { get; set; }", but it is "ok" for most java users
At least is is much better that the redundant/stupid javadocs like
/**
* this method is a standard javabean getter! it simply returns the value of the field <code>field1</code>
* here is an ugly copy&paste from the javadoc of the corresponding private field:
* ...these field is very important in the model, so it is explained here...
* @return field1
*/
public int getField1() { return field1; }
/**
- this method is a standard javabean setter! it simply set the value of the field <code>field1</code> using the parameter <code>value</code>
- @param value the value to set in the field <code>field1</code>
*/
public void setField1(int value) { this.field1 = value; }
if you are not convinced by these, have a look to the project lombok
at http://projectlombok.org/features/index.html
basically, you will simply write @Getter and @Setter, and the byte code compiled by javac + lombok annotation processors wil also contains the getter and setter methods automaticcaly (code generation at compile time, but in .class instead of .java)... Of course, there is no javadoc in the .class, only in sources (this is why @Annotations were introduced in jdk5)!
public class MyPOJO
{ /** * field1 doc * ...these field is very important in the model, so it is explained here... */ @Getter @Setter private int field1; }
Having looked into this issue, why not just make the fields be the JAXB accessors? Enunciate will then pick up the docs for those fields:
@javax.xml.bind.annotation.XmlAccessorType(javax.xml.bind.annotation.XmlAccessType.FIELD) public class MyPOJO { ... }