
com.adgear.anoa.test.simple.SimpleAvro Maven / Gradle / Ivy
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.adgear.anoa.test.simple;
@org.apache.avro.specific.AvroGenerated
final public class SimpleAvro extends org.apache.avro.specific.SpecificRecordBase {
/** field #1 */
long foo;
/** field #2 */
java.nio.ByteBuffer bar;
/** field #3 */
double baz;
private boolean _frozen = false;
/** Default constructor, does not initialize fields to their default values from the schema. Only use this if you know what you are doing. */
public SimpleAvro() {}
public SimpleAvro freeze() {
_frozen = true;
return this;
}
@Override
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
@Override
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return foo;
case 1: return bar;
case 2: return baz;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/** Writes record to Avro Encoder. */
public void encode(org.apache.avro.io.Encoder _encoder) throws java.io.IOException {
_encoder.writeLong(foo);
_encoder.writeBytes(bar);
_encoder.writeDouble(baz);
}
// Used by DatumReader. Applications should not call.
@Override
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
if (_frozen) {
throw new org.apache.avro.AvroRuntimeException("this Anoa SpecificRecord instance has already been frozen.");
}
switch (field$) {
case 0: foo = (long) value$; break;
case 1: bar = (java.nio.ByteBuffer) value$; break;
case 2: baz = (double) value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/** Reads record from Avro Decoder. */
public SimpleAvro decode(org.apache.avro.io.Decoder _decoder) throws java.io.IOException {
if (_frozen) {
throw new org.apache.avro.AvroRuntimeException("this Anoa SpecificRecord instance has already been frozen.");
}
foo = _decoder.readLong();
bar = _decoder.readBytes(bar);
baz = _decoder.readDouble();
return freeze();
}
/**
* RecordBuilder for Avro instances.
*/
static public class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase implements org.apache.avro.data.RecordBuilder {
private long foo;
private java.nio.ByteBuffer bar;
private double baz;
public Builder() {
super(SimpleAvro.SCHEMA$);
}
public Builder(SimpleAvro.Builder other) {
super(other);
if (isValidValue(fields()[0], other.foo)) {
this.foo = data().deepCopy(fields()[0].schema(), other.foo);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.bar)) {
this.bar = data().deepCopy(fields()[1].schema(), other.bar);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.baz)) {
this.baz = data().deepCopy(fields()[2].schema(), other.baz);
fieldSetFlags()[2] = true;
}
}
public Builder(SimpleAvro other) {
super(SimpleAvro.SCHEMA$);
if (isValidValue(fields()[0], other.foo)) {
this.foo = data().deepCopy(fields()[0].schema(), other.foo);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.bar)) {
this.bar = data().deepCopy(fields()[1].schema(), other.bar);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.baz)) {
this.baz = data().deepCopy(fields()[2].schema(), other.baz);
fieldSetFlags()[2] = true;
}
}
/** Gets the value of the 'foo' field. */
public long getFoo() {
return foo;
}
/** Sets the value of the 'foo' field. */
public SimpleAvro.Builder setFoo(long value) {
validate(fields()[0], value);
this.foo = value;
fieldSetFlags()[0] = true;
return this;
}
/** Checks whether the 'foo' field has been set. */
public boolean hasFoo() {
return fieldSetFlags()[0];
}
/** Clears the value of the 'foo' field. */
public SimpleAvro.Builder clearFoo() {
fieldSetFlags()[0] = false;
return this;
}
/** Gets the value of the 'bar' field. */
public java.nio.ByteBuffer getBar() {
return bar;
}
/** Sets the value of the 'bar' field. */
public SimpleAvro.Builder setBar(java.nio.ByteBuffer value) {
validate(fields()[1], value);
this.bar = value;
fieldSetFlags()[1] = true;
return this;
}
/** Checks whether the 'bar' field has been set. */
public boolean hasBar() {
return fieldSetFlags()[1];
}
/** Clears the value of the 'bar' field. */
public SimpleAvro.Builder clearBar() {
bar = null;
fieldSetFlags()[1] = false;
return this;
}
/** Gets the value of the 'baz' field. */
public double getBaz() {
return baz;
}
/** Sets the value of the 'baz' field. */
public SimpleAvro.Builder setBaz(double value) {
validate(fields()[2], value);
this.baz = value;
fieldSetFlags()[2] = true;
return this;
}
/** Checks whether the 'baz' field has been set. */
public boolean hasBaz() {
return fieldSetFlags()[2];
}
/** Clears the value of the 'baz' field. */
public SimpleAvro.Builder clearBaz() {
fieldSetFlags()[2] = false;
return this;
}
@Deprecated
public double getBlab() {
return getBaz();
}
@Deprecated
public SimpleAvro.Builder setBlab(double value) {
return setBaz(value);
}
@Deprecated
public boolean hasBlab() {
return hasBaz();
}
@Deprecated
public SimpleAvro.Builder clearBlab() {
return clearBaz();
}
@Override
public SimpleAvro build() {
final SimpleAvro record;
try {
record = new SimpleAvro();
record.foo = fieldSetFlags()[0] ? this.foo : (long) defaultValue(fields()[0]);
record.bar = fieldSetFlags()[1] ? this.bar : (java.nio.ByteBuffer) defaultValue(fields()[1]);
record.baz = fieldSetFlags()[2] ? this.baz : (double) defaultValue(fields()[2]);
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
return record.freeze();
}
}
/** Creates a new SimpleAvro RecordBuilder. */
static public SimpleAvro.Builder newBuilder() {
return new SimpleAvro.Builder();
}
/** Creates a new SimpleAvro RecordBuilder by copying an existing SimpleAvro.Builder instance. */
static public SimpleAvro.Builder newBuilder(SimpleAvro.Builder other) {
return new SimpleAvro.Builder(other);
}
/** Creates a new SimpleAvro RecordBuilder by copying an existing SimpleAvro instance. */
static public SimpleAvro.Builder newBuilder(SimpleAvro other) {
return new SimpleAvro.Builder(other);
}
/** Returns Avro record schema. */
static public org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
static public final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"SimpleAvro\",\"namespace\":\"com.adgear.anoa.test.simple\",\"fields\":[{\"name\":\"foo\",\"type\":\"long\",\"doc\":\"field #1\",\"default\":0,\"ordinal_\":1},{\"name\":\"bar\",\"type\":\"bytes\",\"doc\":\"field #2\",\"default\":\"\",\"ordinal_\":2},{\"name\":\"baz\",\"type\":\"double\",\"doc\":\"field #3\",\"default\":0.0,\"aliases\":[\"blab\"],\"ordinal_\":3}]}");
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy