TMP
[demos/microservices] / validate-user / src / main / java / de / trion / microservices / avro / OrderValidation.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 OrderValidation extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord {
17   private static final long serialVersionUID = 8233123483892962178L;
18   public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"OrderValidation\",\"namespace\":\"de.trion.microservices.avro\",\"fields\":[{\"name\":\"orderId\",\"type\":\"string\"},{\"name\":\"checkType\",\"type\":{\"type\":\"enum\",\"name\":\"OrderValidationType\",\"symbols\":[\"ORDER_DETAILS_CHECK\",\"ORDER_USER_CHECK\"]}},{\"name\":\"validationResult\",\"type\":{\"type\":\"enum\",\"name\":\"OrderValidationResult\",\"symbols\":[\"PASS\",\"FAIL\"]}},{\"name\":\"messages\",\"type\":{\"type\":\"array\",\"items\":\"string\"}}]}");
19   public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; }
20
21   private static SpecificData MODEL$ = new SpecificData();
22
23   private static final BinaryMessageEncoder<OrderValidation> ENCODER =
24       new BinaryMessageEncoder<OrderValidation>(MODEL$, SCHEMA$);
25
26   private static final BinaryMessageDecoder<OrderValidation> DECODER =
27       new BinaryMessageDecoder<OrderValidation>(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<OrderValidation> 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<OrderValidation> 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<OrderValidation> createDecoder(SchemaStore resolver) {
51     return new BinaryMessageDecoder<OrderValidation>(MODEL$, SCHEMA$, resolver);
52   }
53
54   /**
55    * Serializes this OrderValidation 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 OrderValidation from a ByteBuffer.
65    * @param b a byte buffer holding serialized data for an instance of this class
66    * @return a OrderValidation 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 OrderValidation fromByteBuffer(
70       java.nio.ByteBuffer b) throws java.io.IOException {
71     return DECODER.decode(b);
72   }
73
74   @Deprecated public java.lang.CharSequence orderId;
75   @Deprecated public de.trion.microservices.avro.OrderValidationType checkType;
76   @Deprecated public de.trion.microservices.avro.OrderValidationResult validationResult;
77   @Deprecated public java.util.List<java.lang.CharSequence> messages;
78
79   /**
80    * Default constructor.  Note that this does not initialize fields
81    * to their default values from the schema.  If that is desired then
82    * one should use <code>newBuilder()</code>.
83    */
84   public OrderValidation() {}
85
86   /**
87    * All-args constructor.
88    * @param orderId The new value for orderId
89    * @param checkType The new value for checkType
90    * @param validationResult The new value for validationResult
91    * @param messages The new value for messages
92    */
93   public OrderValidation(java.lang.CharSequence orderId, de.trion.microservices.avro.OrderValidationType checkType, de.trion.microservices.avro.OrderValidationResult validationResult, java.util.List<java.lang.CharSequence> messages) {
94     this.orderId = orderId;
95     this.checkType = checkType;
96     this.validationResult = validationResult;
97     this.messages = messages;
98   }
99
100   public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; }
101   public org.apache.avro.Schema getSchema() { return SCHEMA$; }
102   // Used by DatumWriter.  Applications should not call.
103   public java.lang.Object get(int field$) {
104     switch (field$) {
105     case 0: return orderId;
106     case 1: return checkType;
107     case 2: return validationResult;
108     case 3: return messages;
109     default: throw new org.apache.avro.AvroRuntimeException("Bad index");
110     }
111   }
112
113   // Used by DatumReader.  Applications should not call.
114   @SuppressWarnings(value="unchecked")
115   public void put(int field$, java.lang.Object value$) {
116     switch (field$) {
117     case 0: orderId = (java.lang.CharSequence)value$; break;
118     case 1: checkType = (de.trion.microservices.avro.OrderValidationType)value$; break;
119     case 2: validationResult = (de.trion.microservices.avro.OrderValidationResult)value$; break;
120     case 3: messages = (java.util.List<java.lang.CharSequence>)value$; break;
121     default: throw new org.apache.avro.AvroRuntimeException("Bad index");
122     }
123   }
124
125   /**
126    * Gets the value of the 'orderId' field.
127    * @return The value of the 'orderId' field.
128    */
129   public java.lang.CharSequence getOrderId() {
130     return orderId;
131   }
132
133
134   /**
135    * Sets the value of the 'orderId' field.
136    * @param value the value to set.
137    */
138   public void setOrderId(java.lang.CharSequence value) {
139     this.orderId = value;
140   }
141
142   /**
143    * Gets the value of the 'checkType' field.
144    * @return The value of the 'checkType' field.
145    */
146   public de.trion.microservices.avro.OrderValidationType getCheckType() {
147     return checkType;
148   }
149
150
151   /**
152    * Sets the value of the 'checkType' field.
153    * @param value the value to set.
154    */
155   public void setCheckType(de.trion.microservices.avro.OrderValidationType value) {
156     this.checkType = value;
157   }
158
159   /**
160    * Gets the value of the 'validationResult' field.
161    * @return The value of the 'validationResult' field.
162    */
163   public de.trion.microservices.avro.OrderValidationResult getValidationResult() {
164     return validationResult;
165   }
166
167
168   /**
169    * Sets the value of the 'validationResult' field.
170    * @param value the value to set.
171    */
172   public void setValidationResult(de.trion.microservices.avro.OrderValidationResult value) {
173     this.validationResult = value;
174   }
175
176   /**
177    * Gets the value of the 'messages' field.
178    * @return The value of the 'messages' field.
179    */
180   public java.util.List<java.lang.CharSequence> getMessages() {
181     return messages;
182   }
183
184
185   /**
186    * Sets the value of the 'messages' field.
187    * @param value the value to set.
188    */
189   public void setMessages(java.util.List<java.lang.CharSequence> value) {
190     this.messages = value;
191   }
192
193   /**
194    * Creates a new OrderValidation RecordBuilder.
195    * @return A new OrderValidation RecordBuilder
196    */
197   public static de.trion.microservices.avro.OrderValidation.Builder newBuilder() {
198     return new de.trion.microservices.avro.OrderValidation.Builder();
199   }
200
201   /**
202    * Creates a new OrderValidation RecordBuilder by copying an existing Builder.
203    * @param other The existing builder to copy.
204    * @return A new OrderValidation RecordBuilder
205    */
206   public static de.trion.microservices.avro.OrderValidation.Builder newBuilder(de.trion.microservices.avro.OrderValidation.Builder other) {
207     if (other == null) {
208       return new de.trion.microservices.avro.OrderValidation.Builder();
209     } else {
210       return new de.trion.microservices.avro.OrderValidation.Builder(other);
211     }
212   }
213
214   /**
215    * Creates a new OrderValidation RecordBuilder by copying an existing OrderValidation instance.
216    * @param other The existing instance to copy.
217    * @return A new OrderValidation RecordBuilder
218    */
219   public static de.trion.microservices.avro.OrderValidation.Builder newBuilder(de.trion.microservices.avro.OrderValidation other) {
220     if (other == null) {
221       return new de.trion.microservices.avro.OrderValidation.Builder();
222     } else {
223       return new de.trion.microservices.avro.OrderValidation.Builder(other);
224     }
225   }
226
227   /**
228    * RecordBuilder for OrderValidation instances.
229    */
230   public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<OrderValidation>
231     implements org.apache.avro.data.RecordBuilder<OrderValidation> {
232
233     private java.lang.CharSequence orderId;
234     private de.trion.microservices.avro.OrderValidationType checkType;
235     private de.trion.microservices.avro.OrderValidationResult validationResult;
236     private java.util.List<java.lang.CharSequence> messages;
237
238     /** Creates a new Builder */
239     private Builder() {
240       super(SCHEMA$);
241     }
242
243     /**
244      * Creates a Builder by copying an existing Builder.
245      * @param other The existing Builder to copy.
246      */
247     private Builder(de.trion.microservices.avro.OrderValidation.Builder other) {
248       super(other);
249       if (isValidValue(fields()[0], other.orderId)) {
250         this.orderId = data().deepCopy(fields()[0].schema(), other.orderId);
251         fieldSetFlags()[0] = other.fieldSetFlags()[0];
252       }
253       if (isValidValue(fields()[1], other.checkType)) {
254         this.checkType = data().deepCopy(fields()[1].schema(), other.checkType);
255         fieldSetFlags()[1] = other.fieldSetFlags()[1];
256       }
257       if (isValidValue(fields()[2], other.validationResult)) {
258         this.validationResult = data().deepCopy(fields()[2].schema(), other.validationResult);
259         fieldSetFlags()[2] = other.fieldSetFlags()[2];
260       }
261       if (isValidValue(fields()[3], other.messages)) {
262         this.messages = data().deepCopy(fields()[3].schema(), other.messages);
263         fieldSetFlags()[3] = other.fieldSetFlags()[3];
264       }
265     }
266
267     /**
268      * Creates a Builder by copying an existing OrderValidation instance
269      * @param other The existing instance to copy.
270      */
271     private Builder(de.trion.microservices.avro.OrderValidation other) {
272       super(SCHEMA$);
273       if (isValidValue(fields()[0], other.orderId)) {
274         this.orderId = data().deepCopy(fields()[0].schema(), other.orderId);
275         fieldSetFlags()[0] = true;
276       }
277       if (isValidValue(fields()[1], other.checkType)) {
278         this.checkType = data().deepCopy(fields()[1].schema(), other.checkType);
279         fieldSetFlags()[1] = true;
280       }
281       if (isValidValue(fields()[2], other.validationResult)) {
282         this.validationResult = data().deepCopy(fields()[2].schema(), other.validationResult);
283         fieldSetFlags()[2] = true;
284       }
285       if (isValidValue(fields()[3], other.messages)) {
286         this.messages = data().deepCopy(fields()[3].schema(), other.messages);
287         fieldSetFlags()[3] = true;
288       }
289     }
290
291     /**
292       * Gets the value of the 'orderId' field.
293       * @return The value.
294       */
295     public java.lang.CharSequence getOrderId() {
296       return orderId;
297     }
298
299
300     /**
301       * Sets the value of the 'orderId' field.
302       * @param value The value of 'orderId'.
303       * @return This builder.
304       */
305     public de.trion.microservices.avro.OrderValidation.Builder setOrderId(java.lang.CharSequence value) {
306       validate(fields()[0], value);
307       this.orderId = value;
308       fieldSetFlags()[0] = true;
309       return this;
310     }
311
312     /**
313       * Checks whether the 'orderId' field has been set.
314       * @return True if the 'orderId' field has been set, false otherwise.
315       */
316     public boolean hasOrderId() {
317       return fieldSetFlags()[0];
318     }
319
320
321     /**
322       * Clears the value of the 'orderId' field.
323       * @return This builder.
324       */
325     public de.trion.microservices.avro.OrderValidation.Builder clearOrderId() {
326       orderId = null;
327       fieldSetFlags()[0] = false;
328       return this;
329     }
330
331     /**
332       * Gets the value of the 'checkType' field.
333       * @return The value.
334       */
335     public de.trion.microservices.avro.OrderValidationType getCheckType() {
336       return checkType;
337     }
338
339
340     /**
341       * Sets the value of the 'checkType' field.
342       * @param value The value of 'checkType'.
343       * @return This builder.
344       */
345     public de.trion.microservices.avro.OrderValidation.Builder setCheckType(de.trion.microservices.avro.OrderValidationType value) {
346       validate(fields()[1], value);
347       this.checkType = value;
348       fieldSetFlags()[1] = true;
349       return this;
350     }
351
352     /**
353       * Checks whether the 'checkType' field has been set.
354       * @return True if the 'checkType' field has been set, false otherwise.
355       */
356     public boolean hasCheckType() {
357       return fieldSetFlags()[1];
358     }
359
360
361     /**
362       * Clears the value of the 'checkType' field.
363       * @return This builder.
364       */
365     public de.trion.microservices.avro.OrderValidation.Builder clearCheckType() {
366       checkType = null;
367       fieldSetFlags()[1] = false;
368       return this;
369     }
370
371     /**
372       * Gets the value of the 'validationResult' field.
373       * @return The value.
374       */
375     public de.trion.microservices.avro.OrderValidationResult getValidationResult() {
376       return validationResult;
377     }
378
379
380     /**
381       * Sets the value of the 'validationResult' field.
382       * @param value The value of 'validationResult'.
383       * @return This builder.
384       */
385     public de.trion.microservices.avro.OrderValidation.Builder setValidationResult(de.trion.microservices.avro.OrderValidationResult value) {
386       validate(fields()[2], value);
387       this.validationResult = value;
388       fieldSetFlags()[2] = true;
389       return this;
390     }
391
392     /**
393       * Checks whether the 'validationResult' field has been set.
394       * @return True if the 'validationResult' field has been set, false otherwise.
395       */
396     public boolean hasValidationResult() {
397       return fieldSetFlags()[2];
398     }
399
400
401     /**
402       * Clears the value of the 'validationResult' field.
403       * @return This builder.
404       */
405     public de.trion.microservices.avro.OrderValidation.Builder clearValidationResult() {
406       validationResult = null;
407       fieldSetFlags()[2] = false;
408       return this;
409     }
410
411     /**
412       * Gets the value of the 'messages' field.
413       * @return The value.
414       */
415     public java.util.List<java.lang.CharSequence> getMessages() {
416       return messages;
417     }
418
419
420     /**
421       * Sets the value of the 'messages' field.
422       * @param value The value of 'messages'.
423       * @return This builder.
424       */
425     public de.trion.microservices.avro.OrderValidation.Builder setMessages(java.util.List<java.lang.CharSequence> value) {
426       validate(fields()[3], value);
427       this.messages = value;
428       fieldSetFlags()[3] = true;
429       return this;
430     }
431
432     /**
433       * Checks whether the 'messages' field has been set.
434       * @return True if the 'messages' field has been set, false otherwise.
435       */
436     public boolean hasMessages() {
437       return fieldSetFlags()[3];
438     }
439
440
441     /**
442       * Clears the value of the 'messages' field.
443       * @return This builder.
444       */
445     public de.trion.microservices.avro.OrderValidation.Builder clearMessages() {
446       messages = null;
447       fieldSetFlags()[3] = false;
448       return this;
449     }
450
451     @Override
452     @SuppressWarnings("unchecked")
453     public OrderValidation build() {
454       try {
455         OrderValidation record = new OrderValidation();
456         record.orderId = fieldSetFlags()[0] ? this.orderId : (java.lang.CharSequence) defaultValue(fields()[0]);
457         record.checkType = fieldSetFlags()[1] ? this.checkType : (de.trion.microservices.avro.OrderValidationType) defaultValue(fields()[1]);
458         record.validationResult = fieldSetFlags()[2] ? this.validationResult : (de.trion.microservices.avro.OrderValidationResult) defaultValue(fields()[2]);
459         record.messages = fieldSetFlags()[3] ? this.messages : (java.util.List<java.lang.CharSequence>) defaultValue(fields()[3]);
460         return record;
461       } catch (org.apache.avro.AvroMissingFieldException e) {
462         throw e;
463       } catch (java.lang.Exception e) {
464         throw new org.apache.avro.AvroRuntimeException(e);
465       }
466     }
467   }
468
469   @SuppressWarnings("unchecked")
470   private static final org.apache.avro.io.DatumWriter<OrderValidation>
471     WRITER$ = (org.apache.avro.io.DatumWriter<OrderValidation>)MODEL$.createDatumWriter(SCHEMA$);
472
473   @Override public void writeExternal(java.io.ObjectOutput out)
474     throws java.io.IOException {
475     WRITER$.write(this, SpecificData.getEncoder(out));
476   }
477
478   @SuppressWarnings("unchecked")
479   private static final org.apache.avro.io.DatumReader<OrderValidation>
480     READER$ = (org.apache.avro.io.DatumReader<OrderValidation>)MODEL$.createDatumReader(SCHEMA$);
481
482   @Override public void readExternal(java.io.ObjectInput in)
483     throws java.io.IOException {
484     READER$.read(this, SpecificData.getDecoder(in));
485   }
486
487   @Override protected boolean hasCustomCoders() { return true; }
488
489   @Override public void customEncode(org.apache.avro.io.Encoder out)
490     throws java.io.IOException
491   {
492     out.writeString(this.orderId);
493
494     out.writeEnum(this.checkType.ordinal());
495
496     out.writeEnum(this.validationResult.ordinal());
497
498     long size0 = this.messages.size();
499     out.writeArrayStart();
500     out.setItemCount(size0);
501     long actualSize0 = 0;
502     for (java.lang.CharSequence e0: this.messages) {
503       actualSize0++;
504       out.startItem();
505       out.writeString(e0);
506     }
507     out.writeArrayEnd();
508     if (actualSize0 != size0)
509       throw new java.util.ConcurrentModificationException("Array-size written was " + size0 + ", but element count was " + actualSize0 + ".");
510
511   }
512
513   @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
514     throws java.io.IOException
515   {
516     org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff();
517     if (fieldOrder == null) {
518       this.orderId = in.readString(this.orderId instanceof Utf8 ? (Utf8)this.orderId : null);
519
520       this.checkType = de.trion.microservices.avro.OrderValidationType.values()[in.readEnum()];
521
522       this.validationResult = de.trion.microservices.avro.OrderValidationResult.values()[in.readEnum()];
523
524       long size0 = in.readArrayStart();
525       java.util.List<java.lang.CharSequence> a0 = this.messages;
526       if (a0 == null) {
527         a0 = new SpecificData.Array<java.lang.CharSequence>((int)size0, SCHEMA$.getField("messages").schema());
528         this.messages = a0;
529       } else a0.clear();
530       SpecificData.Array<java.lang.CharSequence> ga0 = (a0 instanceof SpecificData.Array ? (SpecificData.Array<java.lang.CharSequence>)a0 : null);
531       for ( ; 0 < size0; size0 = in.arrayNext()) {
532         for ( ; size0 != 0; size0--) {
533           java.lang.CharSequence e0 = (ga0 != null ? ga0.peek() : null);
534           e0 = in.readString(e0 instanceof Utf8 ? (Utf8)e0 : null);
535           a0.add(e0);
536         }
537       }
538
539     } else {
540       for (int i = 0; i < 4; i++) {
541         switch (fieldOrder[i].pos()) {
542         case 0:
543           this.orderId = in.readString(this.orderId instanceof Utf8 ? (Utf8)this.orderId : null);
544           break;
545
546         case 1:
547           this.checkType = de.trion.microservices.avro.OrderValidationType.values()[in.readEnum()];
548           break;
549
550         case 2:
551           this.validationResult = de.trion.microservices.avro.OrderValidationResult.values()[in.readEnum()];
552           break;
553
554         case 3:
555           long size0 = in.readArrayStart();
556           java.util.List<java.lang.CharSequence> a0 = this.messages;
557           if (a0 == null) {
558             a0 = new SpecificData.Array<java.lang.CharSequence>((int)size0, SCHEMA$.getField("messages").schema());
559             this.messages = a0;
560           } else a0.clear();
561           SpecificData.Array<java.lang.CharSequence> ga0 = (a0 instanceof SpecificData.Array ? (SpecificData.Array<java.lang.CharSequence>)a0 : null);
562           for ( ; 0 < size0; size0 = in.arrayNext()) {
563             for ( ; size0 != 0; size0--) {
564               java.lang.CharSequence e0 = (ga0 != null ? ga0.peek() : null);
565               e0 = in.readString(e0 instanceof Utf8 ? (Utf8)e0 : null);
566               a0.add(e0);
567             }
568           }
569           break;
570
571         default:
572           throw new java.io.IOException("Corrupt ResolvingDecoder.");
573         }
574       }
575     }
576   }
577 }
578
579
580
581
582
583
584
585
586
587