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 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$; }
21 private static SpecificData MODEL$ = new SpecificData();
23 private static final BinaryMessageEncoder<OrderValidation> ENCODER =
24 new BinaryMessageEncoder<OrderValidation>(MODEL$, SCHEMA$);
26 private static final BinaryMessageDecoder<OrderValidation> DECODER =
27 new BinaryMessageDecoder<OrderValidation>(MODEL$, SCHEMA$);
30 * Return the BinaryMessageEncoder instance used by this class.
31 * @return the message encoder used by this class
33 public static BinaryMessageEncoder<OrderValidation> getEncoder() {
38 * Return the BinaryMessageDecoder instance used by this class.
39 * @return the message decoder used by this class
41 public static BinaryMessageDecoder<OrderValidation> 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<OrderValidation> createDecoder(SchemaStore resolver) {
51 return new BinaryMessageDecoder<OrderValidation>(MODEL$, SCHEMA$, resolver);
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
59 public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException {
60 return ENCODER.encode(this);
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
69 public static OrderValidation fromByteBuffer(
70 java.nio.ByteBuffer b) throws java.io.IOException {
71 return DECODER.decode(b);
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;
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>.
84 public OrderValidation() {}
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
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;
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$) {
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");
113 // Used by DatumReader. Applications should not call.
114 @SuppressWarnings(value="unchecked")
115 public void put(int field$, java.lang.Object value$) {
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");
126 * Gets the value of the 'orderId' field.
127 * @return The value of the 'orderId' field.
129 public java.lang.CharSequence getOrderId() {
135 * Sets the value of the 'orderId' field.
136 * @param value the value to set.
138 public void setOrderId(java.lang.CharSequence value) {
139 this.orderId = value;
143 * Gets the value of the 'checkType' field.
144 * @return The value of the 'checkType' field.
146 public de.trion.microservices.avro.OrderValidationType getCheckType() {
152 * Sets the value of the 'checkType' field.
153 * @param value the value to set.
155 public void setCheckType(de.trion.microservices.avro.OrderValidationType value) {
156 this.checkType = value;
160 * Gets the value of the 'validationResult' field.
161 * @return The value of the 'validationResult' field.
163 public de.trion.microservices.avro.OrderValidationResult getValidationResult() {
164 return validationResult;
169 * Sets the value of the 'validationResult' field.
170 * @param value the value to set.
172 public void setValidationResult(de.trion.microservices.avro.OrderValidationResult value) {
173 this.validationResult = value;
177 * Gets the value of the 'messages' field.
178 * @return The value of the 'messages' field.
180 public java.util.List<java.lang.CharSequence> getMessages() {
186 * Sets the value of the 'messages' field.
187 * @param value the value to set.
189 public void setMessages(java.util.List<java.lang.CharSequence> value) {
190 this.messages = value;
194 * Creates a new OrderValidation RecordBuilder.
195 * @return A new OrderValidation RecordBuilder
197 public static de.trion.microservices.avro.OrderValidation.Builder newBuilder() {
198 return new de.trion.microservices.avro.OrderValidation.Builder();
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
206 public static de.trion.microservices.avro.OrderValidation.Builder newBuilder(de.trion.microservices.avro.OrderValidation.Builder other) {
208 return new de.trion.microservices.avro.OrderValidation.Builder();
210 return new de.trion.microservices.avro.OrderValidation.Builder(other);
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
219 public static de.trion.microservices.avro.OrderValidation.Builder newBuilder(de.trion.microservices.avro.OrderValidation other) {
221 return new de.trion.microservices.avro.OrderValidation.Builder();
223 return new de.trion.microservices.avro.OrderValidation.Builder(other);
228 * RecordBuilder for OrderValidation instances.
230 public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<OrderValidation>
231 implements org.apache.avro.data.RecordBuilder<OrderValidation> {
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;
238 /** Creates a new Builder */
244 * Creates a Builder by copying an existing Builder.
245 * @param other The existing Builder to copy.
247 private Builder(de.trion.microservices.avro.OrderValidation.Builder other) {
249 if (isValidValue(fields()[0], other.orderId)) {
250 this.orderId = data().deepCopy(fields()[0].schema(), other.orderId);
251 fieldSetFlags()[0] = other.fieldSetFlags()[0];
253 if (isValidValue(fields()[1], other.checkType)) {
254 this.checkType = data().deepCopy(fields()[1].schema(), other.checkType);
255 fieldSetFlags()[1] = other.fieldSetFlags()[1];
257 if (isValidValue(fields()[2], other.validationResult)) {
258 this.validationResult = data().deepCopy(fields()[2].schema(), other.validationResult);
259 fieldSetFlags()[2] = other.fieldSetFlags()[2];
261 if (isValidValue(fields()[3], other.messages)) {
262 this.messages = data().deepCopy(fields()[3].schema(), other.messages);
263 fieldSetFlags()[3] = other.fieldSetFlags()[3];
268 * Creates a Builder by copying an existing OrderValidation instance
269 * @param other The existing instance to copy.
271 private Builder(de.trion.microservices.avro.OrderValidation other) {
273 if (isValidValue(fields()[0], other.orderId)) {
274 this.orderId = data().deepCopy(fields()[0].schema(), other.orderId);
275 fieldSetFlags()[0] = true;
277 if (isValidValue(fields()[1], other.checkType)) {
278 this.checkType = data().deepCopy(fields()[1].schema(), other.checkType);
279 fieldSetFlags()[1] = true;
281 if (isValidValue(fields()[2], other.validationResult)) {
282 this.validationResult = data().deepCopy(fields()[2].schema(), other.validationResult);
283 fieldSetFlags()[2] = true;
285 if (isValidValue(fields()[3], other.messages)) {
286 this.messages = data().deepCopy(fields()[3].schema(), other.messages);
287 fieldSetFlags()[3] = true;
292 * Gets the value of the 'orderId' field.
295 public java.lang.CharSequence getOrderId() {
301 * Sets the value of the 'orderId' field.
302 * @param value The value of 'orderId'.
303 * @return This builder.
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;
313 * Checks whether the 'orderId' field has been set.
314 * @return True if the 'orderId' field has been set, false otherwise.
316 public boolean hasOrderId() {
317 return fieldSetFlags()[0];
322 * Clears the value of the 'orderId' field.
323 * @return This builder.
325 public de.trion.microservices.avro.OrderValidation.Builder clearOrderId() {
327 fieldSetFlags()[0] = false;
332 * Gets the value of the 'checkType' field.
335 public de.trion.microservices.avro.OrderValidationType getCheckType() {
341 * Sets the value of the 'checkType' field.
342 * @param value The value of 'checkType'.
343 * @return This builder.
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;
353 * Checks whether the 'checkType' field has been set.
354 * @return True if the 'checkType' field has been set, false otherwise.
356 public boolean hasCheckType() {
357 return fieldSetFlags()[1];
362 * Clears the value of the 'checkType' field.
363 * @return This builder.
365 public de.trion.microservices.avro.OrderValidation.Builder clearCheckType() {
367 fieldSetFlags()[1] = false;
372 * Gets the value of the 'validationResult' field.
375 public de.trion.microservices.avro.OrderValidationResult getValidationResult() {
376 return validationResult;
381 * Sets the value of the 'validationResult' field.
382 * @param value The value of 'validationResult'.
383 * @return This builder.
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;
393 * Checks whether the 'validationResult' field has been set.
394 * @return True if the 'validationResult' field has been set, false otherwise.
396 public boolean hasValidationResult() {
397 return fieldSetFlags()[2];
402 * Clears the value of the 'validationResult' field.
403 * @return This builder.
405 public de.trion.microservices.avro.OrderValidation.Builder clearValidationResult() {
406 validationResult = null;
407 fieldSetFlags()[2] = false;
412 * Gets the value of the 'messages' field.
415 public java.util.List<java.lang.CharSequence> getMessages() {
421 * Sets the value of the 'messages' field.
422 * @param value The value of 'messages'.
423 * @return This builder.
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;
433 * Checks whether the 'messages' field has been set.
434 * @return True if the 'messages' field has been set, false otherwise.
436 public boolean hasMessages() {
437 return fieldSetFlags()[3];
442 * Clears the value of the 'messages' field.
443 * @return This builder.
445 public de.trion.microservices.avro.OrderValidation.Builder clearMessages() {
447 fieldSetFlags()[3] = false;
452 @SuppressWarnings("unchecked")
453 public OrderValidation build() {
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]);
461 } catch (org.apache.avro.AvroMissingFieldException e) {
463 } catch (java.lang.Exception e) {
464 throw new org.apache.avro.AvroRuntimeException(e);
469 @SuppressWarnings("unchecked")
470 private static final org.apache.avro.io.DatumWriter<OrderValidation>
471 WRITER$ = (org.apache.avro.io.DatumWriter<OrderValidation>)MODEL$.createDatumWriter(SCHEMA$);
473 @Override public void writeExternal(java.io.ObjectOutput out)
474 throws java.io.IOException {
475 WRITER$.write(this, SpecificData.getEncoder(out));
478 @SuppressWarnings("unchecked")
479 private static final org.apache.avro.io.DatumReader<OrderValidation>
480 READER$ = (org.apache.avro.io.DatumReader<OrderValidation>)MODEL$.createDatumReader(SCHEMA$);
482 @Override public void readExternal(java.io.ObjectInput in)
483 throws java.io.IOException {
484 READER$.read(this, SpecificData.getDecoder(in));
487 @Override protected boolean hasCustomCoders() { return true; }
489 @Override public void customEncode(org.apache.avro.io.Encoder out)
490 throws java.io.IOException
492 out.writeString(this.orderId);
494 out.writeEnum(this.checkType.ordinal());
496 out.writeEnum(this.validationResult.ordinal());
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) {
508 if (actualSize0 != size0)
509 throw new java.util.ConcurrentModificationException("Array-size written was " + size0 + ", but element count was " + actualSize0 + ".");
513 @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in)
514 throws java.io.IOException
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);
520 this.checkType = de.trion.microservices.avro.OrderValidationType.values()[in.readEnum()];
522 this.validationResult = de.trion.microservices.avro.OrderValidationResult.values()[in.readEnum()];
524 long size0 = in.readArrayStart();
525 java.util.List<java.lang.CharSequence> a0 = this.messages;
527 a0 = new SpecificData.Array<java.lang.CharSequence>((int)size0, SCHEMA$.getField("messages").schema());
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);
540 for (int i = 0; i < 4; i++) {
541 switch (fieldOrder[i].pos()) {
543 this.orderId = in.readString(this.orderId instanceof Utf8 ? (Utf8)this.orderId : null);
547 this.checkType = de.trion.microservices.avro.OrderValidationType.values()[in.readEnum()];
551 this.validationResult = de.trion.microservices.avro.OrderValidationResult.values()[in.readEnum()];
555 long size0 = in.readArrayStart();
556 java.util.List<java.lang.CharSequence> a0 = this.messages;
558 a0 = new SpecificData.Array<java.lang.CharSequence>((int)size0, SCHEMA$.getField("messages").schema());
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);
572 throw new java.io.IOException("Corrupt ResolvingDecoder.");