Skip to content

Instantly share code, notes, and snippets.

@dsebastien
Created December 8, 2017 12:00
Show Gist options
  • Save dsebastien/303d8f432663bf93e728c2a47317d7d2 to your computer and use it in GitHub Desktop.
Save dsebastien/303d8f432663bf93e728c2a47317d7d2 to your computer and use it in GitHub Desktop.
/**
* Autogenerated by Avro
*
* DO NOT EDIT DIRECTLY
*/
package be.itsee.ecool.events.schemas.schools;
import org.apache.avro.specific.SpecificData;
import org.apache.avro.message.BinaryMessageEncoder;
import org.apache.avro.message.BinaryMessageDecoder;
import org.apache.avro.message.SchemaStore;
@SuppressWarnings("all")
/** Emitted when a school is created in the system. */
@org.apache.avro.specific.AvroGenerated
public class SchoolCreated extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
private static final long serialVersionUID = 5656177710451174395L;
public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"SchoolCreatedV1\",\"namespace\":\"be.itsee.ecool.events.schemas.schools\",\"doc\":\"Emitted when a school is created in the system.\",\"fields\":[{\"name\":\"schoolId\",\"type\":\"string\",\"logicalType\":\"uuid\"},{\"name\":\"name\",\"type\":\"string\",\"default\":\"\"},{\"name\":\"description\",\"type\":\"string\",\"default\":\"\"}]}");
public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
private static SpecificData MODEL$ = new SpecificData();
private static final BinaryMessageEncoder<SchoolCreated> ENCODER =
new BinaryMessageEncoder<SchoolCreated>(MODEL$, SCHEMA$);
private static final BinaryMessageDecoder<SchoolCreated> DECODER =
new BinaryMessageDecoder<SchoolCreated>(MODEL$, SCHEMA$);
/**
* Return the BinaryMessageDecoder instance used by this class.
*/
public static BinaryMessageDecoder<SchoolCreated> 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
*/
public static BinaryMessageDecoder<SchoolCreated> createDecoder(SchemaStore resolver) {
return new BinaryMessageDecoder<SchoolCreated>(MODEL$, SCHEMA$, resolver);
}
/** Serializes this SchoolCreatedV1 to a ByteBuffer. */
public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
return ENCODER.encode(this);
}
/** Deserializes a SchoolCreatedV1 from a ByteBuffer. */
public static SchoolCreated fromByteBuffer(
java.nio.ByteBuffer b) throws java.io.IOException {
return DECODER.decode(b);
}
@Deprecated public java.lang.CharSequence schoolId;
@Deprecated public java.lang.CharSequence name;
@Deprecated public java.lang.CharSequence description;
/**
* 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 SchoolCreated() {}
/**
* All-args constructor.
* @param schoolId The new value for schoolId
* @param name The new value for name
* @param description The new value for description
*/
public SchoolCreated(java.lang.CharSequence schoolId, java.lang.CharSequence name, java.lang.CharSequence description) {
this.schoolId = schoolId;
this.name = name;
this.description = description;
}
public org.apache.avro.Schema getSchema() { return SCHEMA$; }
// Used by DatumWriter. Applications should not call.
public java.lang.Object get(int field$) {
switch (field$) {
case 0: return schoolId;
case 1: return name;
case 2: return description;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
// Used by DatumReader. Applications should not call.
@SuppressWarnings(value="unchecked")
public void put(int field$, java.lang.Object value$) {
switch (field$) {
case 0: schoolId = (java.lang.CharSequence)value$; break;
case 1: name = (java.lang.CharSequence)value$; break;
case 2: description = (java.lang.CharSequence)value$; break;
default: throw new org.apache.avro.AvroRuntimeException("Bad index");
}
}
/**
* Gets the value of the 'schoolId' field.
* @return The value of the 'schoolId' field.
*/
public java.lang.CharSequence getSchoolId() {
return schoolId;
}
/**
* Sets the value of the 'schoolId' field.
* @param value the value to set.
*/
public void setSchoolId(java.lang.CharSequence value) {
this.schoolId = value;
}
/**
* Gets the value of the 'name' field.
* @return The value of the 'name' field.
*/
public java.lang.CharSequence getName() {
return name;
}
/**
* Sets the value of the 'name' field.
* @param value the value to set.
*/
public void setName(java.lang.CharSequence value) {
this.name = value;
}
/**
* Gets the value of the 'description' field.
* @return The value of the 'description' field.
*/
public java.lang.CharSequence getDescription() {
return description;
}
/**
* Sets the value of the 'description' field.
* @param value the value to set.
*/
public void setDescription(java.lang.CharSequence value) {
this.description = value;
}
/**
* Creates a new SchoolCreatedV1 RecordBuilder.
* @return A new SchoolCreatedV1 RecordBuilder
*/
public static be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder newBuilder() {
return new be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder();
}
/**
* Creates a new SchoolCreatedV1 RecordBuilder by copying an existing Builder.
* @param other The existing builder to copy.
* @return A new SchoolCreatedV1 RecordBuilder
*/
public static be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder newBuilder(be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder other) {
return new be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder(other);
}
/**
* Creates a new SchoolCreatedV1 RecordBuilder by copying an existing SchoolCreatedV1 instance.
* @param other The existing instance to copy.
* @return A new SchoolCreatedV1 RecordBuilder
*/
public static be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder newBuilder(be.itsee.ecool.events.schemas.schools.SchoolCreated other) {
return new be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder(other);
}
/**
* RecordBuilder for SchoolCreatedV1 instances.
*/
public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<SchoolCreated>
implements org.apache.avro.data.RecordBuilder<SchoolCreated> {
private java.lang.CharSequence schoolId;
private java.lang.CharSequence name;
private java.lang.CharSequence description;
/** Creates a new Builder */
private Builder() {
super(SCHEMA$);
}
/**
* Creates a Builder by copying an existing Builder.
* @param other The existing Builder to copy.
*/
private Builder(be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder other) {
super(other);
if (isValidValue(fields()[0], other.schoolId)) {
this.schoolId = data().deepCopy(fields()[0].schema(), other.schoolId);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.name)) {
this.name = data().deepCopy(fields()[1].schema(), other.name);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.description)) {
this.description = data().deepCopy(fields()[2].schema(), other.description);
fieldSetFlags()[2] = true;
}
}
/**
* Creates a Builder by copying an existing SchoolCreatedV1 instance
* @param other The existing instance to copy.
*/
private Builder(be.itsee.ecool.events.schemas.schools.SchoolCreated other) {
super(SCHEMA$);
if (isValidValue(fields()[0], other.schoolId)) {
this.schoolId = data().deepCopy(fields()[0].schema(), other.schoolId);
fieldSetFlags()[0] = true;
}
if (isValidValue(fields()[1], other.name)) {
this.name = data().deepCopy(fields()[1].schema(), other.name);
fieldSetFlags()[1] = true;
}
if (isValidValue(fields()[2], other.description)) {
this.description = data().deepCopy(fields()[2].schema(), other.description);
fieldSetFlags()[2] = true;
}
}
/**
* Gets the value of the 'schoolId' field.
* @return The value.
*/
public java.lang.CharSequence getSchoolId() {
return schoolId;
}
/**
* Sets the value of the 'schoolId' field.
* @param value The value of 'schoolId'.
* @return This builder.
*/
public be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder setSchoolId(java.lang.CharSequence value) {
validate(fields()[0], value);
this.schoolId = value;
fieldSetFlags()[0] = true;
return this;
}
/**
* Checks whether the 'schoolId' field has been set.
* @return True if the 'schoolId' field has been set, false otherwise.
*/
public boolean hasSchoolId() {
return fieldSetFlags()[0];
}
/**
* Clears the value of the 'schoolId' field.
* @return This builder.
*/
public be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder clearSchoolId() {
schoolId = null;
fieldSetFlags()[0] = false;
return this;
}
/**
* Gets the value of the 'name' field.
* @return The value.
*/
public java.lang.CharSequence getName() {
return name;
}
/**
* Sets the value of the 'name' field.
* @param value The value of 'name'.
* @return This builder.
*/
public be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder setName(java.lang.CharSequence value) {
validate(fields()[1], value);
this.name = value;
fieldSetFlags()[1] = true;
return this;
}
/**
* Checks whether the 'name' field has been set.
* @return True if the 'name' field has been set, false otherwise.
*/
public boolean hasName() {
return fieldSetFlags()[1];
}
/**
* Clears the value of the 'name' field.
* @return This builder.
*/
public be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder clearName() {
name = null;
fieldSetFlags()[1] = false;
return this;
}
/**
* Gets the value of the 'description' field.
* @return The value.
*/
public java.lang.CharSequence getDescription() {
return description;
}
/**
* Sets the value of the 'description' field.
* @param value The value of 'description'.
* @return This builder.
*/
public be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder setDescription(java.lang.CharSequence value) {
validate(fields()[2], value);
this.description = value;
fieldSetFlags()[2] = true;
return this;
}
/**
* Checks whether the 'description' field has been set.
* @return True if the 'description' field has been set, false otherwise.
*/
public boolean hasDescription() {
return fieldSetFlags()[2];
}
/**
* Clears the value of the 'description' field.
* @return This builder.
*/
public be.itsee.ecool.events.schemas.schools.SchoolCreated.Builder clearDescription() {
description = null;
fieldSetFlags()[2] = false;
return this;
}
@Override
@SuppressWarnings("unchecked")
public SchoolCreated build() {
try {
SchoolCreated record = new SchoolCreated();
record.schoolId = fieldSetFlags()[0] ? this.schoolId : (java.lang.CharSequence) defaultValue(fields()[0]);
record.name = fieldSetFlags()[1] ? this.name : (java.lang.CharSequence) defaultValue(fields()[1]);
record.description = fieldSetFlags()[2] ? this.description : (java.lang.CharSequence) defaultValue(fields()[2]);
return record;
} catch (java.lang.Exception e) {
throw new org.apache.avro.AvroRuntimeException(e);
}
}
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumWriter<SchoolCreated>
WRITER$ = (org.apache.avro.io.DatumWriter<SchoolCreated>)MODEL$.createDatumWriter(SCHEMA$);
@Override public void writeExternal(java.io.ObjectOutput out)
throws java.io.IOException {
WRITER$.write(this, SpecificData.getEncoder(out));
}
@SuppressWarnings("unchecked")
private static final org.apache.avro.io.DatumReader<SchoolCreated>
READER$ = (org.apache.avro.io.DatumReader<SchoolCreated>)MODEL$.createDatumReader(SCHEMA$);
@Override public void readExternal(java.io.ObjectInput in)
throws java.io.IOException {
READER$.read(this, SpecificData.getDecoder(in));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment