You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@avro.apache.org by GitBox <gi...@apache.org> on 2022/06/30 12:11:07 UTC

[GitHub] [avro] KalleOlaviNiemitalo commented on a diff in pull request #1721: AVRO-3536: Inherit conversions for Union type

KalleOlaviNiemitalo commented on code in PR #1721:
URL: https://github.com/apache/avro/pull/1721#discussion_r910948234


##########
lang/java/avro/src/test/java/org/apache/avro/specific/TestUnionRecord.java:
##########
@@ -0,0 +1,306 @@
+/**
+ * Autogenerated by Avro
+ *
+ * DO NOT EDIT DIRECTLY
+ */
+package org.apache.avro.specific;
+
+import org.apache.avro.message.BinaryMessageDecoder;
+import org.apache.avro.message.BinaryMessageEncoder;
+import org.apache.avro.message.SchemaStore;
+
+@AvroGenerated
+public class TestUnionRecord extends SpecificRecordBase implements SpecificRecord {
+  private static final long serialVersionUID = -3829374192747523457L;
+
+  public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse(
+      "{\"type\":\"record\",\"name\":\"TestUnionRecord\",\"namespace\":\"org.apache.avro.specific\",\"fields\":[{\"name\":\"amount\",\"type\":[\"null\",{\"type\":\"bytes\",\"logicalType\":\"decimal\",\"precision\":31,\"scale\":8}],\"default\":null}]}");
+
+  public static org.apache.avro.Schema getClassSchema() {
+    return SCHEMA$;
+  }
+
+  private static final SpecificData MODEL$ = new SpecificData();
+  static {
+    MODEL$.addLogicalTypeConversion(new org.apache.avro.Conversions.DecimalConversion());
+  }
+
+  private static final BinaryMessageEncoder<TestUnionRecord> ENCODER = new BinaryMessageEncoder<TestUnionRecord>(MODEL$,
+      SCHEMA$);
+
+  private static final BinaryMessageDecoder<TestUnionRecord> DECODER = new BinaryMessageDecoder<TestUnionRecord>(MODEL$,
+      SCHEMA$);
+
+  /**
+   * Return the BinaryMessageEncoder instance used by this class.
+   * 
+   * @return the message encoder used by this class
+   */
+  public static BinaryMessageEncoder<TestUnionRecord> getEncoder() {
+    return ENCODER;
+  }
+
+  /**
+   * Return the BinaryMessageDecoder instance used by this class.
+   * 
+   * @return the message decoder used by this class
+   */
+  public static BinaryMessageDecoder<TestUnionRecord> getDecoder() {
+    return DECODER;
+  }
+
+  /**
+   * Create a new BinaryMessageDecoder instance for this class that uses the
+   * specified {@link SchemaStore}.
+   * 
+   * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
+   * @return a BinaryMessageDecoder instance for this class backed by the given
+   *         SchemaStore
+   */
+  public static BinaryMessageDecoder<TestUnionRecord> createDecoder(SchemaStore resolver) {
+    return new BinaryMessageDecoder<TestUnionRecord>(MODEL$, SCHEMA$, resolver);
+  }
+
+  /**
+   * Serializes this TestUnionRecord to a ByteBuffer.
+   * 
+   * @return a buffer holding the serialized data for this instance
+   * @throws java.io.IOException if this instance could not be serialized
+   */
+  public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
+    return ENCODER.encode(this);
+  }
+
+  /**
+   * Deserializes a TestUnionRecord from a ByteBuffer.
+   * 
+   * @param b a byte buffer holding serialized data for an instance of this class
+   * @return a TestUnionRecord instance decoded from the given buffer
+   * @throws java.io.IOException if the given bytes could not be deserialized into
+   *                             an instance of this class
+   */
+  public static TestUnionRecord fromByteBuffer(java.nio.ByteBuffer b) throws java.io.IOException {
+    return DECODER.decode(b);
+  }
+
+  private java.math.BigDecimal amount;
+
+  /**
+   * Default constructor. Note that this does not initialize fields to their
+   * default values from the schema. If that is desired then one should use
+   * <code>newBuilder()</code>.
+   */
+  public TestUnionRecord() {
+  }
+
+  /**
+   * All-args constructor.
+   * 
+   * @param amount The new value for amount
+   */
+  public TestUnionRecord(java.math.BigDecimal amount) {
+    this.amount = amount;
+  }
+
+  public SpecificData getSpecificData() {

Review Comment:
   There is a feature request https://issues.apache.org/jira/browse/AVRO-2774 for making the code generator add the Override annotations. So no need to file a new one for that.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org