
com.adgear.anoa.test.nested.VariantAvro Maven / Gradle / Ivy
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package com.adgear.anoa.test.nested;
@org.apache.avro.specific.AvroGenerated
final public class VariantAvro extends org.apache.avro.specific.SpecificRecordBase {
int int_variant;
long long_variant;
float float_variant;
double double_variant;
boolean boolean_variant;
org.apache.avro.util.Utf8 string_variant;
java.nio.ByteBuffer bytes_variant;
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 VariantAvro() {}
public VariantAvro 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 int_variant;
case 1: return long_variant;
case 2: return float_variant;
case 3: return double_variant;
case 4: return boolean_variant;
case 5: return string_variant;
case 6: return bytes_variant;
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.writeInt(int_variant);
_encoder.writeLong(long_variant);
_encoder.writeFloat(float_variant);
_encoder.writeDouble(double_variant);
_encoder.writeBoolean(boolean_variant);
_encoder.writeString(string_variant);
_encoder.writeBytes(bytes_variant);
}
// 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: int_variant = (int) value$; break;
case 1: long_variant = (long) value$; break;
case 2: float_variant = (float) value$; break;
case 3: double_variant = (double) value$; break;
case 4: boolean_variant = (boolean) value$; break;
case 5: string_variant = (org.apache.avro.util.Utf8) value$; break;
case 6: bytes_variant = (java.nio.ByteBuffer) value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/** Reads record from Avro Decoder. */
public VariantAvro 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.");
}
int_variant = _decoder.readInt();
long_variant = _decoder.readLong();
float_variant = _decoder.readFloat();
double_variant = _decoder.readDouble();
boolean_variant = _decoder.readBoolean();
string_variant = _decoder.readString(string_variant);
bytes_variant = _decoder.readBytes(bytes_variant);
return freeze();
}
/**
* RecordBuilder for Avro instances.
*/
static public class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase implements org.apache.avro.data.RecordBuilder {
private int int_variant;
private long long_variant;
private float float_variant;
private double double_variant;
private boolean boolean_variant;
private org.apache.avro.util.Utf8 string_variant;
private java.nio.ByteBuffer bytes_variant;
public Builder() {
super(VariantAvro.SCHEMA$);
}
public Builder(VariantAvro.Builder other) {
super(other);
if (isValidValue(fields()[0], other.int_variant)) {
this.int_variant = data().deepCopy(fields()[0].schema(), other.int_variant);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.long_variant)) {
this.long_variant = data().deepCopy(fields()[1].schema(), other.long_variant);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.float_variant)) {
this.float_variant = data().deepCopy(fields()[2].schema(), other.float_variant);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.double_variant)) {
this.double_variant = data().deepCopy(fields()[3].schema(), other.double_variant);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.boolean_variant)) {
this.boolean_variant = data().deepCopy(fields()[4].schema(), other.boolean_variant);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.string_variant)) {
this.string_variant = data().deepCopy(fields()[5].schema(), other.string_variant);
fieldSetFlags()[5] = true;
}
if (isValidValue(fields()[6], other.bytes_variant)) {
this.bytes_variant = data().deepCopy(fields()[6].schema(), other.bytes_variant);
fieldSetFlags()[6] = true;
}
}
public Builder(VariantAvro other) {
super(VariantAvro.SCHEMA$);
if (isValidValue(fields()[0], other.int_variant)) {
this.int_variant = data().deepCopy(fields()[0].schema(), other.int_variant);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.long_variant)) {
this.long_variant = data().deepCopy(fields()[1].schema(), other.long_variant);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.float_variant)) {
this.float_variant = data().deepCopy(fields()[2].schema(), other.float_variant);
fieldSetFlags()[2] = true;
}
if (isValidValue(fields()[3], other.double_variant)) {
this.double_variant = data().deepCopy(fields()[3].schema(), other.double_variant);
fieldSetFlags()[3] = true;
}
if (isValidValue(fields()[4], other.boolean_variant)) {
this.boolean_variant = data().deepCopy(fields()[4].schema(), other.boolean_variant);
fieldSetFlags()[4] = true;
}
if (isValidValue(fields()[5], other.string_variant)) {
this.string_variant = data().deepCopy(fields()[5].schema(), other.string_variant);
fieldSetFlags()[5] = true;
}
if (isValidValue(fields()[6], other.bytes_variant)) {
this.bytes_variant = data().deepCopy(fields()[6].schema(), other.bytes_variant);
fieldSetFlags()[6] = true;
}
}
/** Gets the value of the 'int_variant' field. */
public int getIntVariant() {
return int_variant;
}
/** Sets the value of the 'int_variant' field. */
public VariantAvro.Builder setIntVariant(int value) {
validate(fields()[0], value);
this.int_variant = value;
fieldSetFlags()[0] = true;
return this;
}
/** Checks whether the 'int_variant' field has been set. */
public boolean hasIntVariant() {
return fieldSetFlags()[0];
}
/** Clears the value of the 'int_variant' field. */
public VariantAvro.Builder clearIntVariant() {
fieldSetFlags()[0] = false;
return this;
}
/** Gets the value of the 'long_variant' field. */
public long getLongVariant() {
return long_variant;
}
/** Sets the value of the 'long_variant' field. */
public VariantAvro.Builder setLongVariant(long value) {
validate(fields()[1], value);
this.long_variant = value;
fieldSetFlags()[1] = true;
return this;
}
/** Checks whether the 'long_variant' field has been set. */
public boolean hasLongVariant() {
return fieldSetFlags()[1];
}
/** Clears the value of the 'long_variant' field. */
public VariantAvro.Builder clearLongVariant() {
fieldSetFlags()[1] = false;
return this;
}
/** Gets the value of the 'float_variant' field. */
public float getFloatVariant() {
return float_variant;
}
/** Sets the value of the 'float_variant' field. */
public VariantAvro.Builder setFloatVariant(float value) {
validate(fields()[2], value);
this.float_variant = value;
fieldSetFlags()[2] = true;
return this;
}
/** Checks whether the 'float_variant' field has been set. */
public boolean hasFloatVariant() {
return fieldSetFlags()[2];
}
/** Clears the value of the 'float_variant' field. */
public VariantAvro.Builder clearFloatVariant() {
fieldSetFlags()[2] = false;
return this;
}
/** Gets the value of the 'double_variant' field. */
public double getDoubleVariant() {
return double_variant;
}
/** Sets the value of the 'double_variant' field. */
public VariantAvro.Builder setDoubleVariant(double value) {
validate(fields()[3], value);
this.double_variant = value;
fieldSetFlags()[3] = true;
return this;
}
/** Checks whether the 'double_variant' field has been set. */
public boolean hasDoubleVariant() {
return fieldSetFlags()[3];
}
/** Clears the value of the 'double_variant' field. */
public VariantAvro.Builder clearDoubleVariant() {
fieldSetFlags()[3] = false;
return this;
}
/** Gets the value of the 'boolean_variant' field. */
public boolean getBooleanVariant() {
return boolean_variant;
}
/** Sets the value of the 'boolean_variant' field. */
public VariantAvro.Builder setBooleanVariant(boolean value) {
validate(fields()[4], value);
this.boolean_variant = value;
fieldSetFlags()[4] = true;
return this;
}
/** Checks whether the 'boolean_variant' field has been set. */
public boolean hasBooleanVariant() {
return fieldSetFlags()[4];
}
/** Clears the value of the 'boolean_variant' field. */
public VariantAvro.Builder clearBooleanVariant() {
fieldSetFlags()[4] = false;
return this;
}
/** Gets the value of the 'string_variant' field. */
public org.apache.avro.util.Utf8 getStringVariant() {
return string_variant;
}
/** Sets the value of the 'string_variant' field. */
public VariantAvro.Builder setStringVariant(org.apache.avro.util.Utf8 value) {
validate(fields()[5], value);
this.string_variant = value;
fieldSetFlags()[5] = true;
return this;
}
/** Checks whether the 'string_variant' field has been set. */
public boolean hasStringVariant() {
return fieldSetFlags()[5];
}
/** Clears the value of the 'string_variant' field. */
public VariantAvro.Builder clearStringVariant() {
string_variant = null;
fieldSetFlags()[5] = false;
return this;
}
/** Gets the value of the 'bytes_variant' field. */
public java.nio.ByteBuffer getBytesVariant() {
return bytes_variant;
}
/** Sets the value of the 'bytes_variant' field. */
public VariantAvro.Builder setBytesVariant(java.nio.ByteBuffer value) {
validate(fields()[6], value);
this.bytes_variant = value;
fieldSetFlags()[6] = true;
return this;
}
/** Checks whether the 'bytes_variant' field has been set. */
public boolean hasBytesVariant() {
return fieldSetFlags()[6];
}
/** Clears the value of the 'bytes_variant' field. */
public VariantAvro.Builder clearBytesVariant() {
bytes_variant = null;
fieldSetFlags()[6] = false;
return this;
}
@Override
public VariantAvro build() {
final VariantAvro record;
try {
record = new VariantAvro();
record.int_variant = fieldSetFlags()[0] ? this.int_variant : (int) defaultValue(fields()[0]);
record.long_variant = fieldSetFlags()[1] ? this.long_variant : (long) defaultValue(fields()[1]);
record.float_variant = fieldSetFlags()[2] ? this.float_variant : (float) defaultValue(fields()[2]);
record.double_variant = fieldSetFlags()[3] ? this.double_variant : (double) defaultValue(fields()[3]);
record.boolean_variant = fieldSetFlags()[4] ? this.boolean_variant : (boolean) defaultValue(fields()[4]);
record.string_variant = fieldSetFlags()[5] ? this.string_variant : (org.apache.avro.util.Utf8) defaultValue(fields()[5]);
record.bytes_variant = fieldSetFlags()[6] ? this.bytes_variant : (java.nio.ByteBuffer) defaultValue(fields()[6]);
} catch (Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
return record.freeze();
}
}
/** Creates a new VariantAvro RecordBuilder. */
static public VariantAvro.Builder newBuilder() {
return new VariantAvro.Builder();
}
/** Creates a new VariantAvro RecordBuilder by copying an existing VariantAvro.Builder instance. */
static public VariantAvro.Builder newBuilder(VariantAvro.Builder other) {
return new VariantAvro.Builder(other);
}
/** Creates a new VariantAvro RecordBuilder by copying an existing VariantAvro instance. */
static public VariantAvro.Builder newBuilder(VariantAvro other) {
return new VariantAvro.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\":\"VariantAvro\",\"namespace\":\"com.adgear.anoa.test.nested\",\"fields\":[{\"name\":\"int_variant\",\"type\":{\"type\":\"int\",\"max\":4294967295,\"min\":0},\"default\":1,\"ordinal_\":10},{\"name\":\"long_variant\",\"type\":\"long\",\"default\":-1,\"ordinal_\":20},{\"name\":\"float_variant\",\"type\":{\"type\":\"float\",\"mantissa\":23},\"default\":-1.0,\"ordinal_\":30},{\"name\":\"double_variant\",\"type\":\"double\",\"default\":-1.0,\"ordinal_\":40},{\"name\":\"boolean_variant\",\"type\":\"boolean\",\"default\":true,\"ordinal_\":50},{\"name\":\"string_variant\",\"type\":\"string\",\"default\":\"foo\",\"ordinal_\":60},{\"name\":\"bytes_variant\",\"type\":\"bytes\",\"default\":\"\\u0001\\u0002\\u0003\",\"ordinal_\":70}]}");
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy