TMP
[demos/microservices] / validate-user / src / main / java / de / trion / microservices / avro / Order.java
1 /**
2  * Autogenerated by Avro
3  *
4  * DO NOT EDIT DIRECTLY
5  */
6 package de.trion.microservices.avro;
7
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;
14
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$; }
20
21   private static SpecificData MODEL$ = new SpecificData();
22
23   private static final BinaryMessageEncoder<Order> ENCODER =
24       new BinaryMessageEncoder<Order>(MODEL$, SCHEMA$);
25
26   private static final BinaryMessageDecoder<Order> DECODER =
27       new BinaryMessageDecoder<Order>(MODEL$, SCHEMA$);
28
29   /**
30    * Return the BinaryMessageEncoder instance used by this class.
31    * @return the message encoder used by this class
32    */
33   public static BinaryMessageEncoder<Order> getEncoder() {
34     return ENCODER;
35   }
36
37   /**
38    * Return the BinaryMessageDecoder instance used by this class.
39    * @return the message decoder used by this class
40    */
41   public static BinaryMessageDecoder<Order> getDecoder() {
42     return DECODER;
43   }
44
45   /**
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
49    */
50   public static BinaryMessageDecoder<Order> createDecoder(SchemaStore resolver) {
51     return new BinaryMessageDecoder<Order>(MODEL$, SCHEMA$, resolver);
52   }
53
54   /**
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
58    */
59   public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
60     return ENCODER.encode(this);
61   }
62
63   /**
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
68    */
69   public static Order fromByteBuffer(
70       java.nio.ByteBuffer b) throws java.io.IOException {
71     return DECODER.decode(b);
72   }
73
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;
80
81   /**
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>.
85    */
86   public Order() {}
87
88   /**
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
96    */
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) {
98     this.id = id;
99     this.state = state;
100     this.customerId = customerId;
101     this.orderId = orderId;
102     this.productId = productId;
103     this.quantity = quantity;
104   }
105
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$) {
110     switch (field$) {
111     case 0: return id;
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");
118     }
119   }
120
121   // Used by DatumReader.  Applications should not call.
122   @SuppressWarnings(value="unchecked")
123   public void put(int field$, java.lang.Object value$) {
124     switch (field$) {
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");
132     }
133   }
134
135   /**
136    * Gets the value of the 'id' field.
137    * @return The value of the 'id' field.
138    */
139   public java.lang.CharSequence getId() {
140     return id;
141   }
142
143
144   /**
145    * Sets the value of the 'id' field.
146    * @param value the value to set.
147    */
148   public void setId(java.lang.CharSequence value) {
149     this.id = value;
150   }
151
152   /**
153    * Gets the value of the 'state' field.
154    * @return The value of the 'state' field.
155    */
156   public de.trion.microservices.avro.OrderState getState() {
157     return state;
158   }
159
160
161   /**
162    * Sets the value of the 'state' field.
163    * @param value the value to set.
164    */
165   public void setState(de.trion.microservices.avro.OrderState value) {
166     this.state = value;
167   }
168
169   /**
170    * Gets the value of the 'customerId' field.
171    * @return The value of the 'customerId' field.
172    */
173   public long getCustomerId() {
174     return customerId;
175   }
176
177
178   /**
179    * Sets the value of the 'customerId' field.
180    * @param value the value to set.
181    */
182   public void setCustomerId(long value) {
183     this.customerId = value;
184   }
185
186   /**
187    * Gets the value of the 'orderId' field.
188    * @return The value of the 'orderId' field.
189    */
190   public long getOrderId() {
191     return orderId;
192   }
193
194
195   /**
196    * Sets the value of the 'orderId' field.
197    * @param value the value to set.
198    */
199   public void setOrderId(long value) {
200     this.orderId = value;
201   }
202
203   /**
204    * Gets the value of the 'productId' field.
205    * @return The value of the 'productId' field.
206    */
207   public long getProductId() {
208     return productId;
209   }
210
211
212   /**
213    * Sets the value of the 'productId' field.
214    * @param value the value to set.
215    */
216   public void setProductId(long value) {
217     this.productId = value;
218   }
219
220   /**
221    * Gets the value of the 'quantity' field.
222    * @return The value of the 'quantity' field.
223    */
224   public int getQuantity() {
225     return quantity;
226   }
227
228
229   /**
230    * Sets the value of the 'quantity' field.
231    * @param value the value to set.
232    */
233   public void setQuantity(int value) {
234     this.quantity = value;
235   }
236
237   /**
238    * Creates a new Order RecordBuilder.
239    * @return A new Order RecordBuilder
240    */
241   public static de.trion.microservices.avro.Order.Builder newBuilder() {
242     return new de.trion.microservices.avro.Order.Builder();
243   }
244
245   /**
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
249    */
250   public static de.trion.microservices.avro.Order.Builder newBuilder(de.trion.microservices.avro.Order.Builder other) {
251     if (other == null) {
252       return new de.trion.microservices.avro.Order.Builder();
253     } else {
254       return new de.trion.microservices.avro.Order.Builder(other);
255     }
256   }
257
258   /**
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
262    */
263   public static de.trion.microservices.avro.Order.Builder newBuilder(de.trion.microservices.avro.Order other) {
264     if (other == null) {
265       return new de.trion.microservices.avro.Order.Builder();
266     } else {
267       return new de.trion.microservices.avro.Order.Builder(other);
268     }
269   }
270
271   /**
272    * RecordBuilder for Order instances.
273    */
274   public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<Order>
275     implements org.apache.avro.data.RecordBuilder<Order> {
276
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;
283
284     /** Creates a new Builder */
285     private Builder() {
286       super(SCHEMA$);
287     }
288
289     /**
290      * Creates a Builder by copying an existing Builder.
291      * @param other The existing Builder to copy.
292      */
293     private Builder(de.trion.microservices.avro.Order.Builder other) {
294       super(other);
295       if (isValidValue(fields()[0], other.id)) {
296         this.id = data().deepCopy(fields()[0].schema(), other.id);
297         fieldSetFlags()[0] = other.fieldSetFlags()[0];
298       }
299       if (isValidValue(fields()[1], other.state)) {
300         this.state = data().deepCopy(fields()[1].schema(), other.state);
301         fieldSetFlags()[1] = other.fieldSetFlags()[1];
302       }
303       if (isValidValue(fields()[2], other.customerId)) {
304         this.customerId = data().deepCopy(fields()[2].schema(), other.customerId);
305         fieldSetFlags()[2] = other.fieldSetFlags()[2];
306       }
307       if (isValidValue(fields()[3], other.orderId)) {
308         this.orderId = data().deepCopy(fields()[3].schema(), other.orderId);
309         fieldSetFlags()[3] = other.fieldSetFlags()[3];
310       }
311       if (isValidValue(fields()[4], other.productId)) {
312         this.productId = data().deepCopy(fields()[4].schema(), other.productId);
313         fieldSetFlags()[4] = other.fieldSetFlags()[4];
314       }
315       if (isValidValue(fields()[5], other.quantity)) {
316         this.quantity = data().deepCopy(fields()[5].schema(), other.quantity);
317         fieldSetFlags()[5] = other.fieldSetFlags()[5];
318       }
319     }
320
321     /**
322      * Creates a Builder by copying an existing Order instance
323      * @param other The existing instance to copy.
324      */
325     private Builder(de.trion.microservices.avro.Order other) {
326       super(SCHEMA$);
327       if (isValidValue(fields()[0], other.id)) {
328         this.id = data().deepCopy(fields()[0].schema(), other.id);
329         fieldSetFlags()[0] = true;
330       }
331       if (isValidValue(fields()[1], other.state)) {
332         this.state = data().deepCopy(fields()[1].schema(), other.state);
333         fieldSetFlags()[1] = true;
334       }
335       if (isValidValue(fields()[2], other.customerId)) {
336         this.customerId = data().deepCopy(fields()[2].schema(), other.customerId);
337         fieldSetFlags()[2] = true;
338       }
339       if (isValidValue(fields()[3], other.orderId)) {
340         this.orderId = data().deepCopy(fields()[3].schema(), other.orderId);
341         fieldSetFlags()[3] = true;
342       }
343       if (isValidValue(fields()[4], other.productId)) {
344         this.productId = data().deepCopy(fields()[4].schema(), other.productId);
345         fieldSetFlags()[4] = true;
346       }
347       if (isValidValue(fields()[5], other.quantity)) {
348         this.quantity = data().deepCopy(fields()[5].schema(), other.quantity);
349         fieldSetFlags()[5] = true;
350       }
351     }
352
353     /**
354       * Gets the value of the 'id' field.
355       * @return The value.
356       */
357     public java.lang.CharSequence getId() {
358       return id;
359     }
360
361
362     /**
363       * Sets the value of the 'id' field.
364       * @param value The value of 'id'.
365       * @return This builder.
366       */
367     public de.trion.microservices.avro.Order.Builder setId(java.lang.CharSequence value) {
368       validate(fields()[0], value);
369       this.id = value;
370       fieldSetFlags()[0] = true;
371       return this;
372     }
373
374     /**
375       * Checks whether the 'id' field has been set.
376       * @return True if the 'id' field has been set, false otherwise.
377       */
378     public boolean hasId() {
379       return fieldSetFlags()[0];
380     }
381
382
383     /**
384       * Clears the value of the 'id' field.
385       * @return This builder.
386       */
387     public de.trion.microservices.avro.Order.Builder clearId() {
388       id = null;
389       fieldSetFlags()[0] = false;
390       return this;
391     }
392
393     /**
394       * Gets the value of the 'state' field.
395       * @return The value.
396       */
397     public de.trion.microservices.avro.OrderState getState() {
398       return state;
399     }
400
401
402     /**
403       * Sets the value of the 'state' field.
404       * @param value The value of 'state'.
405       * @return This builder.
406       */
407     public de.trion.microservices.avro.Order.Builder setState(de.trion.microservices.avro.OrderState value) {
408       validate(fields()[1], value);
409       this.state = value;
410       fieldSetFlags()[1] = true;
411       return this;
412     }
413
414     /**
415       * Checks whether the 'state' field has been set.
416       * @return True if the 'state' field has been set, false otherwise.
417       */
418     public boolean hasState() {
419       return fieldSetFlags()[1];
420     }
421
422
423     /**
424       * Clears the value of the 'state' field.
425       * @return This builder.
426       */
427     public de.trion.microservices.avro.Order.Builder clearState() {
428       state = null;
429       fieldSetFlags()[1] = false;
430       return this;
431     }
432
433     /**
434       * Gets the value of the 'customerId' field.
435       * @return The value.
436       */
437     public long getCustomerId() {
438       return customerId;
439     }
440
441
442     /**
443       * Sets the value of the 'customerId' field.
444       * @param value The value of 'customerId'.
445       * @return This builder.
446       */
447     public de.trion.microservices.avro.Order.Builder setCustomerId(long value) {
448       validate(fields()[2], value);
449       this.customerId = value;
450       fieldSetFlags()[2] = true;
451       return this;
452     }
453
454     /**
455       * Checks whether the 'customerId' field has been set.
456       * @return True if the 'customerId' field has been set, false otherwise.
457       */
458     public boolean hasCustomerId() {
459       return fieldSetFlags()[2];
460     }
461
462
463     /**
464       * Clears the value of the 'customerId' field.
465       * @return This builder.
466       */
467     public de.trion.microservices.avro.Order.Builder clearCustomerId() {
468       fieldSetFlags()[2] = false;
469       return this;
470     }
471
472     /**
473       * Gets the value of the 'orderId' field.
474       * @return The value.
475       */
476     public long getOrderId() {
477       return orderId;
478     }
479
480
481     /**
482       * Sets the value of the 'orderId' field.
483       * @param value The value of 'orderId'.
484       * @return This builder.
485       */
486     public de.trion.microservices.avro.Order.Builder setOrderId(long value) {
487       validate(fields()[3], value);
488       this.orderId = value;
489       fieldSetFlags()[3] = true;
490       return this;
491     }
492
493     /**
494       * Checks whether the 'orderId' field has been set.
495       * @return True if the 'orderId' field has been set, false otherwise.
496       */
497     public boolean hasOrderId() {
498       return fieldSetFlags()[3];
499     }
500
501
502     /**
503       * Clears the value of the 'orderId' field.
504       * @return This builder.
505       */
506     public de.trion.microservices.avro.Order.Builder clearOrderId() {
507       fieldSetFlags()[3] = false;
508       return this;
509     }
510
511     /**
512       * Gets the value of the 'productId' field.
513       * @return The value.
514       */
515     public long getProductId() {
516       return productId;
517     }
518
519
520     /**
521       * Sets the value of the 'productId' field.
522       * @param value The value of 'productId'.
523       * @return This builder.
524       */
525     public de.trion.microservices.avro.Order.Builder setProductId(long value) {
526       validate(fields()[4], value);
527       this.productId = value;
528       fieldSetFlags()[4] = true;
529       return this;
530     }
531
532     /**
533       * Checks whether the 'productId' field has been set.
534       * @return True if the 'productId' field has been set, false otherwise.
535       */
536     public boolean hasProductId() {
537       return fieldSetFlags()[4];
538     }
539
540
541     /**
542       * Clears the value of the 'productId' field.
543       * @return This builder.
544       */
545     public de.trion.microservices.avro.Order.Builder clearProductId() {
546       fieldSetFlags()[4] = false;
547       return this;
548     }
549
550     /**
551       * Gets the value of the 'quantity' field.
552       * @return The value.
553       */
554     public int getQuantity() {
555       return quantity;
556     }
557
558
559     /**
560       * Sets the value of the 'quantity' field.
561       * @param value The value of 'quantity'.
562       * @return This builder.
563       */
564     public de.trion.microservices.avro.Order.Builder setQuantity(int value) {
565       validate(fields()[5], value);
566       this.quantity = value;
567       fieldSetFlags()[5] = true;
568       return this;
569     }
570
571     /**
572       * Checks whether the 'quantity' field has been set.
573       * @return True if the 'quantity' field has been set, false otherwise.
574       */
575     public boolean hasQuantity() {
576       return fieldSetFlags()[5];
577     }
578
579
580     /**
581       * Clears the value of the 'quantity' field.
582       * @return This builder.
583       */
584     public de.trion.microservices.avro.Order.Builder clearQuantity() {
585       fieldSetFlags()[5] = false;
586       return this;
587     }
588
589     @Override
590     @SuppressWarnings("unchecked")
591     public Order build() {
592       try {
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]);
600         return record;
601       } catch (org.apache.avro.AvroMissingFieldException e) {
602         throw e;
603       } catch (java.lang.Exception e) {
604         throw new org.apache.avro.AvroRuntimeException(e);
605       }
606     }
607   }
608
609   @SuppressWarnings("unchecked")
610   private static final org.apache.avro.io.DatumWriter<Order>
611     WRITER$ = (org.apache.avro.io.DatumWriter<Order>)MODEL$.createDatumWriter(SCHEMA$);
612
613   @Override public void writeExternal(java.io.ObjectOutput out)
614     throws java.io.IOException {
615     WRITER$.write(this, SpecificData.getEncoder(out));
616   }
617
618   @SuppressWarnings("unchecked")
619   private static final org.apache.avro.io.DatumReader<Order>
620     READER$ = (org.apache.avro.io.DatumReader<Order>)MODEL$.createDatumReader(SCHEMA$);
621
622   @Override public void readExternal(java.io.ObjectInput in)
623     throws java.io.IOException {
624     READER$.read(this, SpecificData.getDecoder(in));
625   }
626
627   @Override protected boolean hasCustomCoders() { return true; }
628
629   @Override public void customEncode(org.apache.avro.io.Encoder out)
630     throws java.io.IOException
631   {
632     out.writeString(this.id);
633
634     out.writeEnum(this.state.ordinal());
635
636     out.writeLong(this.customerId);
637
638     out.writeLong(this.orderId);
639
640     out.writeLong(this.productId);
641
642     out.writeInt(this.quantity);
643
644   }
645
646   @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
647     throws java.io.IOException
648   {
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);
652
653       this.state = de.trion.microservices.avro.OrderState.values()[in.readEnum()];
654
655       this.customerId = in.readLong();
656
657       this.orderId = in.readLong();
658
659       this.productId = in.readLong();
660
661       this.quantity = in.readInt();
662
663     } else {
664       for (int i = 0; i < 6; i++) {
665         switch (fieldOrder[i].pos()) {
666         case 0:
667           this.id = in.readString(this.id instanceof Utf8 ? (Utf8)this.id : null);
668           break;
669
670         case 1:
671           this.state = de.trion.microservices.avro.OrderState.values()[in.readEnum()];
672           break;
673
674         case 2:
675           this.customerId = in.readLong();
676           break;
677
678         case 3:
679           this.orderId = in.readLong();
680           break;
681
682         case 4:
683           this.productId = in.readLong();
684           break;
685
686         case 5:
687           this.quantity = in.readInt();
688           break;
689
690         default:
691           throw new java.io.IOException("Corrupt ResolvingDecoder.");
692         }
693       }
694     }
695   }
696 }
697
698
699
700
701
702
703
704
705
706