avro-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cutt...@apache.org
Subject svn commit: r1383645 - in /avro/trunk: CHANGES.txt lang/java/compiler/src/main/velocity/org/apache/avro/compiler/specific/templates/java/classic/record.vm lang/java/tools/src/test/compiler/output/Player.java
Date Tue, 11 Sep 2012 22:37:58 GMT
Author: cutting
Date: Tue Sep 11 22:37:58 2012
New Revision: 1383645

URL: http://svn.apache.org/viewvc?rev=1383645&view=rev
Log:
AVRO-1149. Java: Add a constructor to generated classes with all fields as parameters.  Contributed
by Gabriel Reid.

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/output/Player.java

Modified: avro/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/avro/trunk/CHANGES.txt?rev=1383645&r1=1383644&r2=1383645&view=diff
==============================================================================
--- avro/trunk/CHANGES.txt (original)
+++ avro/trunk/CHANGES.txt Tue Sep 11 22:37:58 2012
@@ -19,6 +19,9 @@ Avro 1.7.2 (unreleased)
     AVRO-1151. Netty Avro server should expose the number of connections
     currently open. (Hari Shreedharan via tomwhite)
 
+    AVRO-1149. Java: Add a constructor to generated classes with all
+    fields as parameters. (Gabriel Reid via cutting)
+
   BUG FIXES
 
     AVRO-1128. Java: Fix SpecificRecordBase#equals() to work for

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=1383645&r1=1383644&r2=1383645&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
Tue Sep 11 22:37:58 2012
@@ -47,6 +47,24 @@ public class ${this.mangle($schema.getNa
   public ${this.mangle($schema.getName())}(Object value, Throwable cause) {
     super(value, cause);
   }
+  
+#else
+#if ($schema.getFields().size() > 0)  
+
+  /**
+   * Default constructor.
+   */
+  public ${this.mangle($schema.getName())}() {}
+
+  /**
+   * All-args constructor.
+   */
+  public ${this.mangle($schema.getName())}(#foreach($field in $schema.getFields())${this.javaType($field.schema())}
${this.mangle($field.name())}#if($velocityCount < $schema.getFields().size()), #end#end)
{
+#foreach ($field in $schema.getFields())
+    this.${this.mangle($field.name())} = ${this.mangle($field.name())};
+#end
+  }
+#end
 
 #end
   public org.apache.avro.Schema getSchema() { return SCHEMA$; }

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=1383645&r1=1383644&r2=1383645&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 Tue Sep 11 22:37:58 2012
@@ -11,6 +11,22 @@ public class Player extends org.apache.a
   @Deprecated public java.lang.CharSequence first_name;
   @Deprecated public java.lang.CharSequence last_name;
   @Deprecated public java.util.List<avro.examples.baseball.Position> position;
+
+  /**
+   * Default constructor.
+   */
+  public Player() {}
+
+  /**
+   * All-args constructor.
+   */
+  public Player(java.lang.Integer number, java.lang.CharSequence first_name, java.lang.CharSequence
last_name, java.util.List<avro.examples.baseball.Position> position) {
+    this.number = number;
+    this.first_name = first_name;
+    this.last_name = last_name;
+    this.position = position;
+  }
+
   public org.apache.avro.Schema getSchema() { return SCHEMA$; }
   // Used by DatumWriter.  Applications should not call. 
   public java.lang.Object get(int field$) {



Mime
View raw message