2 * Autogenerated by Avro
6 package de.trion.microservices.avro;
8 import org.apache.avro.generic.GenericArray;
9 import org.apache.avro.specific.SpecificData;
10 import org.apache.avro.util.Utf8;
11 import org.apache.avro.message.BinaryMessageEncoder;
12 import org.apache.avro.message.BinaryMessageDecoder;
13 import org.apache.avro.message.SchemaStore;
15 @org.apache.avro.specific.AvroGenerated
16 public class Order extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
17 private static final long serialVersionUID = 6161645617080332601L;
18 public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"Order\",\"namespace\":\"de.trion.microservices.avro\",\"fields\":[{\"name\":\"id\",\"type\":\"string\"},{\"name\":\"state\",\"type\":{\"type\":\"enum\",\"name\":\"OrderState\",\"symbols\":[\"CREATED\",\"APPROVED\",\"DECLINED\"],\"default\":\"CREATED\"}},{\"name\":\"customerId\",\"type\":\"long\"},{\"name\":\"orderId\",\"type\":\"long\"},{\"name\":\"productId\",\"type\":\"long\"},{\"name\":\"quantity\",\"type\":\"int\"}]}");
19 public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
21 private static SpecificData MODEL$ = new SpecificData();
23 private static final BinaryMessageEncoder<Order> ENCODER =
24 new BinaryMessageEncoder<Order>(MODEL$, SCHEMA$);
26 private static final BinaryMessageDecoder<Order> DECODER =
27 new BinaryMessageDecoder<Order>(MODEL$, SCHEMA$);
30 * Return the BinaryMessageEncoder instance used by this class.
31 * @return the message encoder used by this class
33 public static BinaryMessageEncoder<Order> getEncoder() {
38 * Return the BinaryMessageDecoder instance used by this class.
39 * @return the message decoder used by this class
41 public static BinaryMessageDecoder<Order> getDecoder() {
46 * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}.
47 * @param resolver a {@link SchemaStore} used to find schemas by fingerprint
48 * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore
50 public static BinaryMessageDecoder<Order> createDecoder(SchemaStore resolver) {
51 return new BinaryMessageDecoder<Order>(MODEL$, SCHEMA$, resolver);
55 * Serializes this Order to a ByteBuffer.
56 * @return a buffer holding the serialized data for this instance
57 * @throws java.io.IOException if this instance could not be serialized
59 public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
60 return ENCODER.encode(this);
64 * Deserializes a Order from a ByteBuffer.
65 * @param b a byte buffer holding serialized data for an instance of this class
66 * @return a Order instance decoded from the given buffer
67 * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class
69 public static Order fromByteBuffer(
70 java.nio.ByteBuffer b) throws java.io.IOException {
71 return DECODER.decode(b);
74 @Deprecated public java.lang.CharSequence id;
75 @Deprecated public de.trion.microservices.avro.OrderState state;
76 @Deprecated public long customerId;
77 @Deprecated public long orderId;
78 @Deprecated public long productId;
79 @Deprecated public int quantity;
82 * Default constructor. Note that this does not initialize fields
83 * to their default values from the schema. If that is desired then
84 * one should use <code>newBuilder()</code>.
89 * All-args constructor.
90 * @param id The new value for id
91 * @param state The new value for state
92 * @param customerId The new value for customerId
93 * @param orderId The new value for orderId
94 * @param productId The new value for productId
95 * @param quantity The new value for quantity
97 public Order(java.lang.CharSequence id, de.trion.microservices.avro.OrderState state, java.lang.Long customerId, java.lang.Long orderId, java.lang.Long productId, java.lang.Integer quantity) {
100 this.customerId = customerId;
101 this.orderId = orderId;
102 this.productId = productId;
103 this.quantity = quantity;
106 public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
107 public org.apache.avro.Schema getSchema() { return SCHEMA$; }
108 // Used by DatumWriter. Applications should not call.
109 public java.lang.Object get(int field$) {
112 case 1: return state;
113 case 2: return customerId;
114 case 3: return orderId;
115 case 4: return productId;
116 case 5: return quantity;
117 default: throw new org.apache.avro.AvroRuntimeException("Bad index");
121 // Used by DatumReader. Applications should not call.
122 @SuppressWarnings(value="unchecked")
123 public void put(int field$, java.lang.Object value$) {
125 case 0: id = (java.lang.CharSequence)value$; break;
126 case 1: state = (de.trion.microservices.avro.OrderState)value$; break;
127 case 2: customerId = (java.lang.Long)value$; break;
128 case 3: orderId = (java.lang.Long)value$; break;
129 case 4: productId = (java.lang.Long)value$; break;
130 case 5: quantity = (java.lang.Integer)value$; break;
131 default: throw new org.apache.avro.AvroRuntimeException("Bad index");
136 * Gets the value of the 'id' field.
137 * @return The value of the 'id' field.
139 public java.lang.CharSequence getId() {
145 * Sets the value of the 'id' field.
146 * @param value the value to set.
148 public void setId(java.lang.CharSequence value) {
153 * Gets the value of the 'state' field.
154 * @return The value of the 'state' field.
156 public de.trion.microservices.avro.OrderState getState() {
162 * Sets the value of the 'state' field.
163 * @param value the value to set.
165 public void setState(de.trion.microservices.avro.OrderState value) {
170 * Gets the value of the 'customerId' field.
171 * @return The value of the 'customerId' field.
173 public long getCustomerId() {
179 * Sets the value of the 'customerId' field.
180 * @param value the value to set.
182 public void setCustomerId(long value) {
183 this.customerId = value;
187 * Gets the value of the 'orderId' field.
188 * @return The value of the 'orderId' field.
190 public long getOrderId() {
196 * Sets the value of the 'orderId' field.
197 * @param value the value to set.
199 public void setOrderId(long value) {
200 this.orderId = value;
204 * Gets the value of the 'productId' field.
205 * @return The value of the 'productId' field.
207 public long getProductId() {
213 * Sets the value of the 'productId' field.
214 * @param value the value to set.
216 public void setProductId(long value) {
217 this.productId = value;
221 * Gets the value of the 'quantity' field.
222 * @return The value of the 'quantity' field.
224 public int getQuantity() {
230 * Sets the value of the 'quantity' field.
231 * @param value the value to set.
233 public void setQuantity(int value) {
234 this.quantity = value;
238 * Creates a new Order RecordBuilder.
239 * @return A new Order RecordBuilder
241 public static de.trion.microservices.avro.Order.Builder newBuilder() {
242 return new de.trion.microservices.avro.Order.Builder();
246 * Creates a new Order RecordBuilder by copying an existing Builder.
247 * @param other The existing builder to copy.
248 * @return A new Order RecordBuilder
250 public static de.trion.microservices.avro.Order.Builder newBuilder(de.trion.microservices.avro.Order.Builder other) {
252 return new de.trion.microservices.avro.Order.Builder();
254 return new de.trion.microservices.avro.Order.Builder(other);
259 * Creates a new Order RecordBuilder by copying an existing Order instance.
260 * @param other The existing instance to copy.
261 * @return A new Order RecordBuilder
263 public static de.trion.microservices.avro.Order.Builder newBuilder(de.trion.microservices.avro.Order other) {
265 return new de.trion.microservices.avro.Order.Builder();
267 return new de.trion.microservices.avro.Order.Builder(other);
272 * RecordBuilder for Order instances.
274 public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Order>
275 implements org.apache.avro.data.RecordBuilder<Order> {
277 private java.lang.CharSequence id;
278 private de.trion.microservices.avro.OrderState state;
279 private long customerId;
280 private long orderId;
281 private long productId;
282 private int quantity;
284 /** Creates a new Builder */
290 * Creates a Builder by copying an existing Builder.
291 * @param other The existing Builder to copy.
293 private Builder(de.trion.microservices.avro.Order.Builder other) {
295 if (isValidValue(fields()[0], other.id)) {
296 this.id = data().deepCopy(fields()[0].schema(), other.id);
297 fieldSetFlags()[0] = other.fieldSetFlags()[0];
299 if (isValidValue(fields()[1], other.state)) {
300 this.state = data().deepCopy(fields()[1].schema(), other.state);
301 fieldSetFlags()[1] = other.fieldSetFlags()[1];
303 if (isValidValue(fields()[2], other.customerId)) {
304 this.customerId = data().deepCopy(fields()[2].schema(), other.customerId);
305 fieldSetFlags()[2] = other.fieldSetFlags()[2];
307 if (isValidValue(fields()[3], other.orderId)) {
308 this.orderId = data().deepCopy(fields()[3].schema(), other.orderId);
309 fieldSetFlags()[3] = other.fieldSetFlags()[3];
311 if (isValidValue(fields()[4], other.productId)) {
312 this.productId = data().deepCopy(fields()[4].schema(), other.productId);
313 fieldSetFlags()[4] = other.fieldSetFlags()[4];
315 if (isValidValue(fields()[5], other.quantity)) {
316 this.quantity = data().deepCopy(fields()[5].schema(), other.quantity);
317 fieldSetFlags()[5] = other.fieldSetFlags()[5];
322 * Creates a Builder by copying an existing Order instance
323 * @param other The existing instance to copy.
325 private Builder(de.trion.microservices.avro.Order other) {
327 if (isValidValue(fields()[0], other.id)) {
328 this.id = data().deepCopy(fields()[0].schema(), other.id);
329 fieldSetFlags()[0] = true;
331 if (isValidValue(fields()[1], other.state)) {
332 this.state = data().deepCopy(fields()[1].schema(), other.state);
333 fieldSetFlags()[1] = true;
335 if (isValidValue(fields()[2], other.customerId)) {
336 this.customerId = data().deepCopy(fields()[2].schema(), other.customerId);
337 fieldSetFlags()[2] = true;
339 if (isValidValue(fields()[3], other.orderId)) {
340 this.orderId = data().deepCopy(fields()[3].schema(), other.orderId);
341 fieldSetFlags()[3] = true;
343 if (isValidValue(fields()[4], other.productId)) {
344 this.productId = data().deepCopy(fields()[4].schema(), other.productId);
345 fieldSetFlags()[4] = true;
347 if (isValidValue(fields()[5], other.quantity)) {
348 this.quantity = data().deepCopy(fields()[5].schema(), other.quantity);
349 fieldSetFlags()[5] = true;
354 * Gets the value of the 'id' field.
357 public java.lang.CharSequence getId() {
363 * Sets the value of the 'id' field.
364 * @param value The value of 'id'.
365 * @return This builder.
367 public de.trion.microservices.avro.Order.Builder setId(java.lang.CharSequence value) {
368 validate(fields()[0], value);
370 fieldSetFlags()[0] = true;
375 * Checks whether the 'id' field has been set.
376 * @return True if the 'id' field has been set, false otherwise.
378 public boolean hasId() {
379 return fieldSetFlags()[0];
384 * Clears the value of the 'id' field.
385 * @return This builder.
387 public de.trion.microservices.avro.Order.Builder clearId() {
389 fieldSetFlags()[0] = false;
394 * Gets the value of the 'state' field.
397 public de.trion.microservices.avro.OrderState getState() {
403 * Sets the value of the 'state' field.
404 * @param value The value of 'state'.
405 * @return This builder.
407 public de.trion.microservices.avro.Order.Builder setState(de.trion.microservices.avro.OrderState value) {
408 validate(fields()[1], value);
410 fieldSetFlags()[1] = true;
415 * Checks whether the 'state' field has been set.
416 * @return True if the 'state' field has been set, false otherwise.
418 public boolean hasState() {
419 return fieldSetFlags()[1];
424 * Clears the value of the 'state' field.
425 * @return This builder.
427 public de.trion.microservices.avro.Order.Builder clearState() {
429 fieldSetFlags()[1] = false;
434 * Gets the value of the 'customerId' field.
437 public long getCustomerId() {
443 * Sets the value of the 'customerId' field.
444 * @param value The value of 'customerId'.
445 * @return This builder.
447 public de.trion.microservices.avro.Order.Builder setCustomerId(long value) {
448 validate(fields()[2], value);
449 this.customerId = value;
450 fieldSetFlags()[2] = true;
455 * Checks whether the 'customerId' field has been set.
456 * @return True if the 'customerId' field has been set, false otherwise.
458 public boolean hasCustomerId() {
459 return fieldSetFlags()[2];
464 * Clears the value of the 'customerId' field.
465 * @return This builder.
467 public de.trion.microservices.avro.Order.Builder clearCustomerId() {
468 fieldSetFlags()[2] = false;
473 * Gets the value of the 'orderId' field.
476 public long getOrderId() {
482 * Sets the value of the 'orderId' field.
483 * @param value The value of 'orderId'.
484 * @return This builder.
486 public de.trion.microservices.avro.Order.Builder setOrderId(long value) {
487 validate(fields()[3], value);
488 this.orderId = value;
489 fieldSetFlags()[3] = true;
494 * Checks whether the 'orderId' field has been set.
495 * @return True if the 'orderId' field has been set, false otherwise.
497 public boolean hasOrderId() {
498 return fieldSetFlags()[3];
503 * Clears the value of the 'orderId' field.
504 * @return This builder.
506 public de.trion.microservices.avro.Order.Builder clearOrderId() {
507 fieldSetFlags()[3] = false;
512 * Gets the value of the 'productId' field.
515 public long getProductId() {
521 * Sets the value of the 'productId' field.
522 * @param value The value of 'productId'.
523 * @return This builder.
525 public de.trion.microservices.avro.Order.Builder setProductId(long value) {
526 validate(fields()[4], value);
527 this.productId = value;
528 fieldSetFlags()[4] = true;
533 * Checks whether the 'productId' field has been set.
534 * @return True if the 'productId' field has been set, false otherwise.
536 public boolean hasProductId() {
537 return fieldSetFlags()[4];
542 * Clears the value of the 'productId' field.
543 * @return This builder.
545 public de.trion.microservices.avro.Order.Builder clearProductId() {
546 fieldSetFlags()[4] = false;
551 * Gets the value of the 'quantity' field.
554 public int getQuantity() {
560 * Sets the value of the 'quantity' field.
561 * @param value The value of 'quantity'.
562 * @return This builder.
564 public de.trion.microservices.avro.Order.Builder setQuantity(int value) {
565 validate(fields()[5], value);
566 this.quantity = value;
567 fieldSetFlags()[5] = true;
572 * Checks whether the 'quantity' field has been set.
573 * @return True if the 'quantity' field has been set, false otherwise.
575 public boolean hasQuantity() {
576 return fieldSetFlags()[5];
581 * Clears the value of the 'quantity' field.
582 * @return This builder.
584 public de.trion.microservices.avro.Order.Builder clearQuantity() {
585 fieldSetFlags()[5] = false;
590 @SuppressWarnings("unchecked")
591 public Order build() {
593 Order record = new Order();
594 record.id = fieldSetFlags()[0] ? this.id : (java.lang.CharSequence) defaultValue(fields()[0]);
595 record.state = fieldSetFlags()[1] ? this.state : (de.trion.microservices.avro.OrderState) defaultValue(fields()[1]);
596 record.customerId = fieldSetFlags()[2] ? this.customerId : (java.lang.Long) defaultValue(fields()[2]);
597 record.orderId = fieldSetFlags()[3] ? this.orderId : (java.lang.Long) defaultValue(fields()[3]);
598 record.productId = fieldSetFlags()[4] ? this.productId : (java.lang.Long) defaultValue(fields()[4]);
599 record.quantity = fieldSetFlags()[5] ? this.quantity : (java.lang.Integer) defaultValue(fields()[5]);
601 } catch (org.apache.avro.AvroMissingFieldException e) {
603 } catch (java.lang.Exception e) {
604 throw new org.apache.avro.AvroRuntimeException(e);
609 @SuppressWarnings("unchecked")
610 private static final org.apache.avro.io.DatumWriter<Order>
611 WRITER$ = (org.apache.avro.io.DatumWriter<Order>)MODEL$.createDatumWriter(SCHEMA$);
613 @Override public void writeExternal(java.io.ObjectOutput out)
614 throws java.io.IOException {
615 WRITER$.write(this, SpecificData.getEncoder(out));
618 @SuppressWarnings("unchecked")
619 private static final org.apache.avro.io.DatumReader<Order>
620 READER$ = (org.apache.avro.io.DatumReader<Order>)MODEL$.createDatumReader(SCHEMA$);
622 @Override public void readExternal(java.io.ObjectInput in)
623 throws java.io.IOException {
624 READER$.read(this, SpecificData.getDecoder(in));
627 @Override protected boolean hasCustomCoders() { return true; }
629 @Override public void customEncode(org.apache.avro.io.Encoder out)
630 throws java.io.IOException
632 out.writeString(this.id);
634 out.writeEnum(this.state.ordinal());
636 out.writeLong(this.customerId);
638 out.writeLong(this.orderId);
640 out.writeLong(this.productId);
642 out.writeInt(this.quantity);
646 @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
647 throws java.io.IOException
649 org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
650 if (fieldOrder == null) {
651 this.id = in.readString(this.id instanceof Utf8 ? (Utf8)this.id : null);
653 this.state = de.trion.microservices.avro.OrderState.values()[in.readEnum()];
655 this.customerId = in.readLong();
657 this.orderId = in.readLong();
659 this.productId = in.readLong();
661 this.quantity = in.readInt();
664 for (int i = 0; i < 6; i++) {
665 switch (fieldOrder[i].pos()) {
667 this.id = in.readString(this.id instanceof Utf8 ? (Utf8)this.id : null);
671 this.state = de.trion.microservices.avro.OrderState.values()[in.readEnum()];
675 this.customerId = in.readLong();
679 this.orderId = in.readLong();
683 this.productId = in.readLong();
687 this.quantity = in.readInt();
691 throw new java.io.IOException("Corrupt ResolvingDecoder.");