|
| 1 | +/** |
| 2 | + * Autogenerated by Avro |
| 3 | + * |
| 4 | + * DO NOT EDIT DIRECTLY |
| 5 | + */ |
| 6 | +package com.example.kafka; |
| 7 | + |
| 8 | +import org.apache.avro.specific.SpecificData; |
| 9 | +import org.apache.avro.message.BinaryMessageEncoder; |
| 10 | +import org.apache.avro.message.BinaryMessageDecoder; |
| 11 | +import org.apache.avro.message.SchemaStore; |
| 12 | + |
| 13 | +@SuppressWarnings("all") |
| 14 | +@org.apache.avro.specific.AvroGenerated |
| 15 | +public class Thing extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { |
| 16 | + private static final long serialVersionUID = -719126663737953940L; |
| 17 | + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Thing\",\"namespace\":\"com.example.kafka\",\"fields\":[{\"name\":\"stringField\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"}},{\"name\":\"intField\",\"type\":\"int\"}]}"); |
| 18 | + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } |
| 19 | + |
| 20 | + private static SpecificData MODEL$ = new SpecificData(); |
| 21 | + |
| 22 | + private static final BinaryMessageEncoder<Thing> ENCODER = |
| 23 | + new BinaryMessageEncoder<Thing>(MODEL$, SCHEMA$); |
| 24 | + |
| 25 | + private static final BinaryMessageDecoder<Thing> DECODER = |
| 26 | + new BinaryMessageDecoder<Thing>(MODEL$, SCHEMA$); |
| 27 | + |
| 28 | + /** |
| 29 | + * Return the BinaryMessageDecoder instance used by this class. |
| 30 | + */ |
| 31 | + public static BinaryMessageDecoder<Thing> getDecoder() { |
| 32 | + return DECODER; |
| 33 | + } |
| 34 | + |
| 35 | + /** |
| 36 | + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. |
| 37 | + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint |
| 38 | + */ |
| 39 | + public static BinaryMessageDecoder<Thing> createDecoder(SchemaStore resolver) { |
| 40 | + return new BinaryMessageDecoder<Thing>(MODEL$, SCHEMA$, resolver); |
| 41 | + } |
| 42 | + |
| 43 | + /** Serializes this Thing to a ByteBuffer. */ |
| 44 | + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { |
| 45 | + return ENCODER.encode(this); |
| 46 | + } |
| 47 | + |
| 48 | + /** Deserializes a Thing from a ByteBuffer. */ |
| 49 | + public static Thing fromByteBuffer( |
| 50 | + java.nio.ByteBuffer b) throws java.io.IOException { |
| 51 | + return DECODER.decode(b); |
| 52 | + } |
| 53 | + |
| 54 | + @Deprecated public java.lang.String stringField; |
| 55 | + @Deprecated public int intField; |
| 56 | + |
| 57 | + /** |
| 58 | + * Default constructor. Note that this does not initialize fields |
| 59 | + * to their default values from the schema. If that is desired then |
| 60 | + * one should use <code>newBuilder()</code>. |
| 61 | + */ |
| 62 | + public Thing() {} |
| 63 | + |
| 64 | + /** |
| 65 | + * All-args constructor. |
| 66 | + * @param stringField The new value for stringField |
| 67 | + * @param intField The new value for intField |
| 68 | + */ |
| 69 | + public Thing(java.lang.String stringField, java.lang.Integer intField) { |
| 70 | + this.stringField = stringField; |
| 71 | + this.intField = intField; |
| 72 | + } |
| 73 | + |
| 74 | + public org.apache.avro.Schema getSchema() { return SCHEMA$; } |
| 75 | + // Used by DatumWriter. Applications should not call. |
| 76 | + public java.lang.Object get(int field$) { |
| 77 | + switch (field$) { |
| 78 | + case 0: return stringField; |
| 79 | + case 1: return intField; |
| 80 | + default: throw new org.apache.avro.AvroRuntimeException("Bad index"); |
| 81 | + } |
| 82 | + } |
| 83 | + |
| 84 | + // Used by DatumReader. Applications should not call. |
| 85 | + @SuppressWarnings(value="unchecked") |
| 86 | + public void put(int field$, java.lang.Object value$) { |
| 87 | + switch (field$) { |
| 88 | + case 0: stringField = (java.lang.String)value$; break; |
| 89 | + case 1: intField = (java.lang.Integer)value$; break; |
| 90 | + default: throw new org.apache.avro.AvroRuntimeException("Bad index"); |
| 91 | + } |
| 92 | + } |
| 93 | + |
| 94 | + /** |
| 95 | + * Gets the value of the 'stringField' field. |
| 96 | + * @return The value of the 'stringField' field. |
| 97 | + */ |
| 98 | + public java.lang.String getStringField() { |
| 99 | + return stringField; |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * Sets the value of the 'stringField' field. |
| 104 | + * @param value the value to set. |
| 105 | + */ |
| 106 | + public void setStringField(java.lang.String value) { |
| 107 | + this.stringField = value; |
| 108 | + } |
| 109 | + |
| 110 | + /** |
| 111 | + * Gets the value of the 'intField' field. |
| 112 | + * @return The value of the 'intField' field. |
| 113 | + */ |
| 114 | + public java.lang.Integer getIntField() { |
| 115 | + return intField; |
| 116 | + } |
| 117 | + |
| 118 | + /** |
| 119 | + * Sets the value of the 'intField' field. |
| 120 | + * @param value the value to set. |
| 121 | + */ |
| 122 | + public void setIntField(java.lang.Integer value) { |
| 123 | + this.intField = value; |
| 124 | + } |
| 125 | + |
| 126 | + /** |
| 127 | + * Creates a new Thing RecordBuilder. |
| 128 | + * @return A new Thing RecordBuilder |
| 129 | + */ |
| 130 | + public static com.example.kafka.Thing.Builder newBuilder() { |
| 131 | + return new com.example.kafka.Thing.Builder(); |
| 132 | + } |
| 133 | + |
| 134 | + /** |
| 135 | + * Creates a new Thing RecordBuilder by copying an existing Builder. |
| 136 | + * @param other The existing builder to copy. |
| 137 | + * @return A new Thing RecordBuilder |
| 138 | + */ |
| 139 | + public static com.example.kafka.Thing.Builder newBuilder(com.example.kafka.Thing.Builder other) { |
| 140 | + return new com.example.kafka.Thing.Builder(other); |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * Creates a new Thing RecordBuilder by copying an existing Thing instance. |
| 145 | + * @param other The existing instance to copy. |
| 146 | + * @return A new Thing RecordBuilder |
| 147 | + */ |
| 148 | + public static com.example.kafka.Thing.Builder newBuilder(com.example.kafka.Thing other) { |
| 149 | + return new com.example.kafka.Thing.Builder(other); |
| 150 | + } |
| 151 | + |
| 152 | + /** |
| 153 | + * RecordBuilder for Thing instances. |
| 154 | + */ |
| 155 | + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Thing> |
| 156 | + implements org.apache.avro.data.RecordBuilder<Thing> { |
| 157 | + |
| 158 | + private java.lang.String stringField; |
| 159 | + private int intField; |
| 160 | + |
| 161 | + /** Creates a new Builder */ |
| 162 | + private Builder() { |
| 163 | + super(SCHEMA$); |
| 164 | + } |
| 165 | + |
| 166 | + /** |
| 167 | + * Creates a Builder by copying an existing Builder. |
| 168 | + * @param other The existing Builder to copy. |
| 169 | + */ |
| 170 | + private Builder(com.example.kafka.Thing.Builder other) { |
| 171 | + super(other); |
| 172 | + if (isValidValue(fields()[0], other.stringField)) { |
| 173 | + this.stringField = data().deepCopy(fields()[0].schema(), other.stringField); |
| 174 | + fieldSetFlags()[0] = true; |
| 175 | + } |
| 176 | + if (isValidValue(fields()[1], other.intField)) { |
| 177 | + this.intField = data().deepCopy(fields()[1].schema(), other.intField); |
| 178 | + fieldSetFlags()[1] = true; |
| 179 | + } |
| 180 | + } |
| 181 | + |
| 182 | + /** |
| 183 | + * Creates a Builder by copying an existing Thing instance |
| 184 | + * @param other The existing instance to copy. |
| 185 | + */ |
| 186 | + private Builder(com.example.kafka.Thing other) { |
| 187 | + super(SCHEMA$); |
| 188 | + if (isValidValue(fields()[0], other.stringField)) { |
| 189 | + this.stringField = data().deepCopy(fields()[0].schema(), other.stringField); |
| 190 | + fieldSetFlags()[0] = true; |
| 191 | + } |
| 192 | + if (isValidValue(fields()[1], other.intField)) { |
| 193 | + this.intField = data().deepCopy(fields()[1].schema(), other.intField); |
| 194 | + fieldSetFlags()[1] = true; |
| 195 | + } |
| 196 | + } |
| 197 | + |
| 198 | + /** |
| 199 | + * Gets the value of the 'stringField' field. |
| 200 | + * @return The value. |
| 201 | + */ |
| 202 | + public java.lang.String getStringField() { |
| 203 | + return stringField; |
| 204 | + } |
| 205 | + |
| 206 | + /** |
| 207 | + * Sets the value of the 'stringField' field. |
| 208 | + * @param value The value of 'stringField'. |
| 209 | + * @return This builder. |
| 210 | + */ |
| 211 | + public com.example.kafka.Thing.Builder setStringField(java.lang.String value) { |
| 212 | + validate(fields()[0], value); |
| 213 | + this.stringField = value; |
| 214 | + fieldSetFlags()[0] = true; |
| 215 | + return this; |
| 216 | + } |
| 217 | + |
| 218 | + /** |
| 219 | + * Checks whether the 'stringField' field has been set. |
| 220 | + * @return True if the 'stringField' field has been set, false otherwise. |
| 221 | + */ |
| 222 | + public boolean hasStringField() { |
| 223 | + return fieldSetFlags()[0]; |
| 224 | + } |
| 225 | + |
| 226 | + |
| 227 | + /** |
| 228 | + * Clears the value of the 'stringField' field. |
| 229 | + * @return This builder. |
| 230 | + */ |
| 231 | + public com.example.kafka.Thing.Builder clearStringField() { |
| 232 | + stringField = null; |
| 233 | + fieldSetFlags()[0] = false; |
| 234 | + return this; |
| 235 | + } |
| 236 | + |
| 237 | + /** |
| 238 | + * Gets the value of the 'intField' field. |
| 239 | + * @return The value. |
| 240 | + */ |
| 241 | + public java.lang.Integer getIntField() { |
| 242 | + return intField; |
| 243 | + } |
| 244 | + |
| 245 | + /** |
| 246 | + * Sets the value of the 'intField' field. |
| 247 | + * @param value The value of 'intField'. |
| 248 | + * @return This builder. |
| 249 | + */ |
| 250 | + public com.example.kafka.Thing.Builder setIntField(int value) { |
| 251 | + validate(fields()[1], value); |
| 252 | + this.intField = value; |
| 253 | + fieldSetFlags()[1] = true; |
| 254 | + return this; |
| 255 | + } |
| 256 | + |
| 257 | + /** |
| 258 | + * Checks whether the 'intField' field has been set. |
| 259 | + * @return True if the 'intField' field has been set, false otherwise. |
| 260 | + */ |
| 261 | + public boolean hasIntField() { |
| 262 | + return fieldSetFlags()[1]; |
| 263 | + } |
| 264 | + |
| 265 | + |
| 266 | + /** |
| 267 | + * Clears the value of the 'intField' field. |
| 268 | + * @return This builder. |
| 269 | + */ |
| 270 | + public com.example.kafka.Thing.Builder clearIntField() { |
| 271 | + fieldSetFlags()[1] = false; |
| 272 | + return this; |
| 273 | + } |
| 274 | + |
| 275 | + @Override |
| 276 | + @SuppressWarnings("unchecked") |
| 277 | + public Thing build() { |
| 278 | + try { |
| 279 | + Thing record = new Thing(); |
| 280 | + record.stringField = fieldSetFlags()[0] ? this.stringField : (java.lang.String) defaultValue(fields()[0]); |
| 281 | + record.intField = fieldSetFlags()[1] ? this.intField : (java.lang.Integer) defaultValue(fields()[1]); |
| 282 | + return record; |
| 283 | + } catch (java.lang.Exception e) { |
| 284 | + throw new org.apache.avro.AvroRuntimeException(e); |
| 285 | + } |
| 286 | + } |
| 287 | + } |
| 288 | + |
| 289 | + @SuppressWarnings("unchecked") |
| 290 | + private static final org.apache.avro.io.DatumWriter<Thing> |
| 291 | + WRITER$ = (org.apache.avro.io.DatumWriter<Thing>)MODEL$.createDatumWriter(SCHEMA$); |
| 292 | + |
| 293 | + @Override public void writeExternal(java.io.ObjectOutput out) |
| 294 | + throws java.io.IOException { |
| 295 | + WRITER$.write(this, SpecificData.getEncoder(out)); |
| 296 | + } |
| 297 | + |
| 298 | + @SuppressWarnings("unchecked") |
| 299 | + private static final org.apache.avro.io.DatumReader<Thing> |
| 300 | + READER$ = (org.apache.avro.io.DatumReader<Thing>)MODEL$.createDatumReader(SCHEMA$); |
| 301 | + |
| 302 | + @Override public void readExternal(java.io.ObjectInput in) |
| 303 | + throws java.io.IOException { |
| 304 | + READER$.read(this, SpecificData.getDecoder(in)); |
| 305 | + } |
| 306 | + |
| 307 | +} |
0 commit comments