Author: cutting
Date: Mon Dec 15 22:06:22 2014
New Revision: 1645771

URL: http://svn.apache.org/r1645771
Log:
AVRO-1619. Java: Improve javadoc comments in generated code.  Contributed by 
Niels Basjes.

Modified:
    avro/trunk/CHANGES.txt
    
avro/trunk/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
    avro/trunk/lang/java/tools/src/test/compiler/input/player.avsc
    
avro/trunk/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
    avro/trunk/lang/java/tools/src/test/compiler/output/Player.java

Modified: avro/trunk/CHANGES.txt
URL: 
http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1645771&r1=1645770&r2=1645771&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Mon Dec 15 22:06:22 2014
@@ -47,6 +47,9 @@ Trunk (not yet released)
 
     AVRO-1585. Java: Deprecate Jackson classes in public API. (tomwhite)
 
+    AVRO-1619. Java: Improve javadoc comments in generated code.
+    (Niels Basjes via cutting)
+
   BUG FIXES
 
     AVRO-1553. Java: MapReduce never uses MapOutputValueSchema (tomwhite)

Modified: 
avro/trunk/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
URL: 
http://svn.apache.org/viewvc/avro/trunk/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm?rev=1645771&r1=1645770&r2=1645771&view=diff
==============================================================================
--- 
avro/trunk/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
 (original)
+++ 
avro/trunk/lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm
 Mon Dec 15 22:06:22 2014
@@ -106,7 +106,8 @@ public class ${this.mangle($schema.getNa
 #foreach ($field in $schema.getFields())
   /**
    * Gets the value of the '${this.mangle($field.name(), $schema.isError())}' 
field.
-#if ($field.doc())   * $field.doc()#end
+#if ($field.doc())   * $field.doc()
+#end
    */
   public ${this.javaType($field.schema())} ${this.generateGetMethod($schema, 
$field)}() {
     return ${this.mangle($field.name(), $schema.isError())};
@@ -115,7 +116,8 @@ public class ${this.mangle($schema.getNa
 #if ($this.createSetters)
   /**
    * Sets the value of the '${this.mangle($field.name(), $schema.isError())}' 
field.
-#if ($field.doc())   * $field.doc()#end
+#if ($field.doc())   * $field.doc()
+#end
    * @param value the value to set.
    */
   public void ${this.generateSetMethod($schema, 
$field)}(${this.javaType($field.schema())} value) {
@@ -205,25 +207,42 @@ public class ${this.mangle($schema.getNa
 #end
 
 #foreach ($field in $schema.getFields())
-    /** Gets the value of the '${this.mangle($field.name(), 
$schema.isError())}' field */
+    /**
+      * Gets the value of the '${this.mangle($field.name(), 
$schema.isError())}' field.
+#if ($field.doc())      * $field.doc()
+#end
+      */
     public ${this.javaType($field.schema())} ${this.generateGetMethod($schema, 
$field)}() {
       return ${this.mangle($field.name(), $schema.isError())};
     }
-    
-    /** Sets the value of the '${this.mangle($field.name(), 
$schema.isError())}' field */
+
+    /**
+      * Sets the value of the '${this.mangle($field.name(), 
$schema.isError())}' field.
+#if ($field.doc())      * $field.doc()
+#end
+      * @param value the value to set.
+      */
     public #if 
($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder
 ${this.generateSetMethod($schema, $field)}(${this.javaUnbox($field.schema())} 
value) {
       validate(fields()[$field.pos()], value);
       this.${this.mangle($field.name(), $schema.isError())} = value;
       fieldSetFlags()[$field.pos()] = true;
       return this; 
     }
-    
-    /** Checks whether the '${this.mangle($field.name(), $schema.isError())}' 
field has been set */
+
+    /** 
+      * Checks whether the '${this.mangle($field.name(), $schema.isError())}' 
field has been set.
+#if ($field.doc())      * $field.doc()
+#end
+      */
     public boolean ${this.generateHasMethod($schema, $field)}() {
       return fieldSetFlags()[$field.pos()];
     }
-    
-    /** Clears the value of the '${this.mangle($field.name(), 
$schema.isError())}' field */
+
+    /**
+      * Clears the value of the '${this.mangle($field.name(), 
$schema.isError())}' field.
+#if ($field.doc())      * $field.doc()
+#end
+      */
     public #if 
($schema.getNamespace())$schema.getNamespace().#end${this.mangle($schema.getName())}.Builder
 ${this.generateClearMethod($schema, $field)}() {
 #if (${this.isUnboxedJavaTypeNullable($field.schema())})
       ${this.mangle($field.name(), $schema.isError())} = null;

Modified: avro/trunk/lang/java/tools/src/test/compiler/input/player.avsc
URL: 
http://svn.apache.org/viewvc/avro/trunk/lang/java/tools/src/test/compiler/input/player.avsc?rev=1645771&r1=1645770&r2=1645771&view=diff
==============================================================================
--- avro/trunk/lang/java/tools/src/test/compiler/input/player.avsc (original)
+++ avro/trunk/lang/java/tools/src/test/compiler/input/player.avsc Mon Dec 15 
22:06:22 2014
@@ -1,6 +1,6 @@
 {"type":"record", "name":"Player", "namespace": 
"avro.examples.baseball","doc":"選手 is Japanese for player.",
   "fields": [
-   {"name": "number", "type": "int"},
+   {"name": "number", "type": "int", "doc": "The number of the player"},
    {"name": "first_name", "type": "string"},
    {"name": "last_name", "type": "string"},
    {"name": "position", "type": {"type": "array", "items": "Position"} }

Modified: 
avro/trunk/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
URL: 
http://svn.apache.org/viewvc/avro/trunk/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java?rev=1645771&r1=1645770&r2=1645771&view=diff
==============================================================================
--- 
avro/trunk/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
 (original)
+++ 
avro/trunk/lang/java/tools/src/test/compiler/output-string/avro/examples/baseball/Player.java
 Mon Dec 15 22:06:22 2014
@@ -9,8 +9,9 @@ package avro.examples.baseball;
 @org.apache.avro.specific.AvroGenerated
 public class Player extends org.apache.avro.specific.SpecificRecordBase 
implements org.apache.avro.specific.SpecificRecord {
   private static final long serialVersionUID = 3865593031278745715L;
-  public static final org.apache.avro.Schema SCHEMA$ = new 
org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Player\",\"namespace\":\"avro.examples.baseball\",\"doc\":\"選手
 is Japanese for 
player.\",\"fields\":[{\"name\":\"number\",\"type\":\"int\"},{\"name\":\"first_name\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"last_name\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"position\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"enum\",\"name\":\"Position\",\"symbols\":[\"P\",\"C\",\"B1\",\"B2\",\"B3\",\"SS\",\"LF\",\"CF\",\"RF\",\"DH\"]}}}]}");
+  public static final org.apache.avro.Schema SCHEMA$ = new 
org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Player\",\"namespace\":\"avro.examples.baseball\",\"doc\":\"選手
 is Japanese for 
player.\",\"fields\":[{\"name\":\"number\",\"type\":\"int\",\"doc\":\"The 
number of the 
player\"},{\"name\":\"first_name\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"last_name\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"position\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"enum\",\"name\":\"Position\",\"symbols\":[\"P\",\"C\",\"B1\",\"B2\",\"B3\",\"SS\",\"LF\",\"CF\",\"RF\",\"DH\"]}}}]}");
   public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
+  /** The number of the player */
   @Deprecated public int number;
   @Deprecated public java.lang.String first_name;
   @Deprecated public java.lang.String last_name;
@@ -58,6 +59,7 @@ public class Player extends org.apache.a
 
   /**
    * Gets the value of the 'number' field.
+   * The number of the player
    */
   public java.lang.Integer getNumber() {
     return number;
@@ -65,6 +67,7 @@ public class Player extends org.apache.a
 
   /**
    * Sets the value of the 'number' field.
+   * The number of the player
    * @param value the value to set.
    */
   public void setNumber(java.lang.Integer value) {
@@ -189,99 +192,139 @@ public class Player extends org.apache.a
       }
     }
 
-    /** Gets the value of the 'number' field */
+    /**
+      * Gets the value of the 'number' field.
+      * The number of the player
+      */
     public java.lang.Integer getNumber() {
       return number;
     }
-    
-    /** Sets the value of the 'number' field */
+
+    /**
+      * Sets the value of the 'number' field.
+      * The number of the player
+      * @param value the value to set.
+      */
     public avro.examples.baseball.Player.Builder setNumber(int value) {
       validate(fields()[0], value);
       this.number = value;
       fieldSetFlags()[0] = true;
       return this; 
     }
-    
-    /** Checks whether the 'number' field has been set */
+
+    /** 
+      * Checks whether the 'number' field has been set.
+      * The number of the player
+      */
     public boolean hasNumber() {
       return fieldSetFlags()[0];
     }
-    
-    /** Clears the value of the 'number' field */
+
+    /**
+      * Clears the value of the 'number' field.
+      * The number of the player
+      */
     public avro.examples.baseball.Player.Builder clearNumber() {
       fieldSetFlags()[0] = false;
       return this;
     }
 
-    /** Gets the value of the 'first_name' field */
+    /**
+      * Gets the value of the 'first_name' field.
+      */
     public java.lang.String getFirstName() {
       return first_name;
     }
-    
-    /** Sets the value of the 'first_name' field */
+
+    /**
+      * Sets the value of the 'first_name' field.
+      * @param value the value to set.
+      */
     public avro.examples.baseball.Player.Builder setFirstName(java.lang.String 
value) {
       validate(fields()[1], value);
       this.first_name = value;
       fieldSetFlags()[1] = true;
       return this; 
     }
-    
-    /** Checks whether the 'first_name' field has been set */
+
+    /** 
+      * Checks whether the 'first_name' field has been set.
+      */
     public boolean hasFirstName() {
       return fieldSetFlags()[1];
     }
-    
-    /** Clears the value of the 'first_name' field */
+
+    /**
+      * Clears the value of the 'first_name' field.
+      */
     public avro.examples.baseball.Player.Builder clearFirstName() {
       first_name = null;
       fieldSetFlags()[1] = false;
       return this;
     }
 
-    /** Gets the value of the 'last_name' field */
+    /**
+      * Gets the value of the 'last_name' field.
+      */
     public java.lang.String getLastName() {
       return last_name;
     }
-    
-    /** Sets the value of the 'last_name' field */
+
+    /**
+      * Sets the value of the 'last_name' field.
+      * @param value the value to set.
+      */
     public avro.examples.baseball.Player.Builder setLastName(java.lang.String 
value) {
       validate(fields()[2], value);
       this.last_name = value;
       fieldSetFlags()[2] = true;
       return this; 
     }
-    
-    /** Checks whether the 'last_name' field has been set */
+
+    /** 
+      * Checks whether the 'last_name' field has been set.
+      */
     public boolean hasLastName() {
       return fieldSetFlags()[2];
     }
-    
-    /** Clears the value of the 'last_name' field */
+
+    /**
+      * Clears the value of the 'last_name' field.
+      */
     public avro.examples.baseball.Player.Builder clearLastName() {
       last_name = null;
       fieldSetFlags()[2] = false;
       return this;
     }
 
-    /** Gets the value of the 'position' field */
+    /**
+      * Gets the value of the 'position' field.
+      */
     public java.util.List<avro.examples.baseball.Position> getPosition() {
       return position;
     }
-    
-    /** Sets the value of the 'position' field */
+
+    /**
+      * Sets the value of the 'position' field.
+      * @param value the value to set.
+      */
     public avro.examples.baseball.Player.Builder 
setPosition(java.util.List<avro.examples.baseball.Position> value) {
       validate(fields()[3], value);
       this.position = value;
       fieldSetFlags()[3] = true;
       return this; 
     }
-    
-    /** Checks whether the 'position' field has been set */
+
+    /** 
+      * Checks whether the 'position' field has been set.
+      */
     public boolean hasPosition() {
       return fieldSetFlags()[3];
     }
-    
-    /** Clears the value of the 'position' field */
+
+    /**
+      * Clears the value of the 'position' field.
+      */
     public avro.examples.baseball.Player.Builder clearPosition() {
       position = null;
       fieldSetFlags()[3] = false;

Modified: avro/trunk/lang/java/tools/src/test/compiler/output/Player.java
URL: 
http://svn.apache.org/viewvc/avro/trunk/lang/java/tools/src/test/compiler/output/Player.java?rev=1645771&r1=1645770&r2=1645771&view=diff
==============================================================================
--- avro/trunk/lang/java/tools/src/test/compiler/output/Player.java (original)
+++ avro/trunk/lang/java/tools/src/test/compiler/output/Player.java Mon Dec 15 
22:06:22 2014
@@ -9,8 +9,9 @@ package avro.examples.baseball;
 @org.apache.avro.specific.AvroGenerated
 public class Player extends org.apache.avro.specific.SpecificRecordBase 
implements org.apache.avro.specific.SpecificRecord {
   private static final long serialVersionUID = 3865593031278745715L;
-  public static final org.apache.avro.Schema SCHEMA$ = new 
org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Player\",\"namespace\":\"avro.examples.baseball\",\"doc\":\"選手
 is Japanese for 
player.\",\"fields\":[{\"name\":\"number\",\"type\":\"int\"},{\"name\":\"first_name\",\"type\":\"string\"},{\"name\":\"last_name\",\"type\":\"string\"},{\"name\":\"position\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"enum\",\"name\":\"Position\",\"symbols\":[\"P\",\"C\",\"B1\",\"B2\",\"B3\",\"SS\",\"LF\",\"CF\",\"RF\",\"DH\"]}}}]}");
+  public static final org.apache.avro.Schema SCHEMA$ = new 
org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Player\",\"namespace\":\"avro.examples.baseball\",\"doc\":\"選手
 is Japanese for 
player.\",\"fields\":[{\"name\":\"number\",\"type\":\"int\",\"doc\":\"The 
number of the 
player\"},{\"name\":\"first_name\",\"type\":\"string\"},{\"name\":\"last_name\",\"type\":\"string\"},{\"name\":\"position\",\"type\":{\"type\":\"array\",\"items\":{\"type\":\"enum\",\"name\":\"Position\",\"symbols\":[\"P\",\"C\",\"B1\",\"B2\",\"B3\",\"SS\",\"LF\",\"CF\",\"RF\",\"DH\"]}}}]}");
   public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
+  /** The number of the player */
   @Deprecated public int number;
   @Deprecated public java.lang.CharSequence first_name;
   @Deprecated public java.lang.CharSequence last_name;
@@ -58,6 +59,7 @@ public class Player extends org.apache.a
 
   /**
    * Gets the value of the 'number' field.
+   * The number of the player
    */
   public java.lang.Integer getNumber() {
     return number;
@@ -65,6 +67,7 @@ public class Player extends org.apache.a
 
   /**
    * Sets the value of the 'number' field.
+   * The number of the player
    * @param value the value to set.
    */
   public void setNumber(java.lang.Integer value) {
@@ -189,99 +192,139 @@ public class Player extends org.apache.a
       }
     }
 
-    /** Gets the value of the 'number' field */
+    /**
+      * Gets the value of the 'number' field.
+      * The number of the player
+      */
     public java.lang.Integer getNumber() {
       return number;
     }
-    
-    /** Sets the value of the 'number' field */
+
+    /**
+      * Sets the value of the 'number' field.
+      * The number of the player
+      * @param value the value to set.
+      */
     public avro.examples.baseball.Player.Builder setNumber(int value) {
       validate(fields()[0], value);
       this.number = value;
       fieldSetFlags()[0] = true;
       return this; 
     }
-    
-    /** Checks whether the 'number' field has been set */
+
+    /** 
+      * Checks whether the 'number' field has been set.
+      * The number of the player
+      */
     public boolean hasNumber() {
       return fieldSetFlags()[0];
     }
-    
-    /** Clears the value of the 'number' field */
+
+    /**
+      * Clears the value of the 'number' field.
+      * The number of the player
+      */
     public avro.examples.baseball.Player.Builder clearNumber() {
       fieldSetFlags()[0] = false;
       return this;
     }
 
-    /** Gets the value of the 'first_name' field */
+    /**
+      * Gets the value of the 'first_name' field.
+      */
     public java.lang.CharSequence getFirstName() {
       return first_name;
     }
-    
-    /** Sets the value of the 'first_name' field */
+
+    /**
+      * Sets the value of the 'first_name' field.
+      * @param value the value to set.
+      */
     public avro.examples.baseball.Player.Builder 
setFirstName(java.lang.CharSequence value) {
       validate(fields()[1], value);
       this.first_name = value;
       fieldSetFlags()[1] = true;
       return this; 
     }
-    
-    /** Checks whether the 'first_name' field has been set */
+
+    /** 
+      * Checks whether the 'first_name' field has been set.
+      */
     public boolean hasFirstName() {
       return fieldSetFlags()[1];
     }
-    
-    /** Clears the value of the 'first_name' field */
+
+    /**
+      * Clears the value of the 'first_name' field.
+      */
     public avro.examples.baseball.Player.Builder clearFirstName() {
       first_name = null;
       fieldSetFlags()[1] = false;
       return this;
     }
 
-    /** Gets the value of the 'last_name' field */
+    /**
+      * Gets the value of the 'last_name' field.
+      */
     public java.lang.CharSequence getLastName() {
       return last_name;
     }
-    
-    /** Sets the value of the 'last_name' field */
+
+    /**
+      * Sets the value of the 'last_name' field.
+      * @param value the value to set.
+      */
     public avro.examples.baseball.Player.Builder 
setLastName(java.lang.CharSequence value) {
       validate(fields()[2], value);
       this.last_name = value;
       fieldSetFlags()[2] = true;
       return this; 
     }
-    
-    /** Checks whether the 'last_name' field has been set */
+
+    /** 
+      * Checks whether the 'last_name' field has been set.
+      */
     public boolean hasLastName() {
       return fieldSetFlags()[2];
     }
-    
-    /** Clears the value of the 'last_name' field */
+
+    /**
+      * Clears the value of the 'last_name' field.
+      */
     public avro.examples.baseball.Player.Builder clearLastName() {
       last_name = null;
       fieldSetFlags()[2] = false;
       return this;
     }
 
-    /** Gets the value of the 'position' field */
+    /**
+      * Gets the value of the 'position' field.
+      */
     public java.util.List<avro.examples.baseball.Position> getPosition() {
       return position;
     }
-    
-    /** Sets the value of the 'position' field */
+
+    /**
+      * Sets the value of the 'position' field.
+      * @param value the value to set.
+      */
     public avro.examples.baseball.Player.Builder 
setPosition(java.util.List<avro.examples.baseball.Position> value) {
       validate(fields()[3], value);
       this.position = value;
       fieldSetFlags()[3] = true;
       return this; 
     }
-    
-    /** Checks whether the 'position' field has been set */
+
+    /** 
+      * Checks whether the 'position' field has been set.
+      */
     public boolean hasPosition() {
       return fieldSetFlags()[3];
     }
-    
-    /** Clears the value of the 'position' field */
+
+    /**
+      * Clears the value of the 'position' field.
+      */
     public avro.examples.baseball.Player.Builder clearPosition() {
       position = null;
       fieldSetFlags()[3] = false;


Reply via email to