X-Git-Url: https://juplo.de/gitweb/?p=demos%2Fmicroservices;a=blobdiff_plain;f=validate-user%2Fsrc%2Fmain%2Fjava%2Fde%2Ftrion%2Fmicroservices%2Favro%2FOrderAndUser.java;fp=validate-user%2Fsrc%2Fmain%2Fjava%2Fde%2Ftrion%2Fmicroservices%2Favro%2FOrderAndUser.java;h=0000000000000000000000000000000000000000;hp=d3b9cfb5a171f4522343786794173b7b5ccfd2f2;hb=525feeb10e1c653b8a88d50c472c034945bf4d6e;hpb=c095e577a546dd6270d9c0b062f2c8ffe8ad28f7 diff --git a/validate-user/src/main/java/de/trion/microservices/avro/OrderAndUser.java b/validate-user/src/main/java/de/trion/microservices/avro/OrderAndUser.java deleted file mode 100644 index d3b9cfb..0000000 --- a/validate-user/src/main/java/de/trion/microservices/avro/OrderAndUser.java +++ /dev/null @@ -1,516 +0,0 @@ -/** - * Autogenerated by Avro - * - * DO NOT EDIT DIRECTLY - */ -package de.trion.microservices.avro; - -import org.apache.avro.generic.GenericArray; -import org.apache.avro.specific.SpecificData; -import org.apache.avro.util.Utf8; -import org.apache.avro.message.BinaryMessageEncoder; -import org.apache.avro.message.BinaryMessageDecoder; -import org.apache.avro.message.SchemaStore; - -@org.apache.avro.specific.AvroGenerated -public class OrderAndUser extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { - private static final long serialVersionUID = 6432660008992245598L; - public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"OrderAndUser\",\"namespace\":\"de.trion.microservices.avro\",\"fields\":[{\"name\":\"order\",\"type\":{\"type\":\"record\",\"name\":\"Order\",\"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\"}]}},{\"name\":\"user\",\"type\":[\"null\",{\"type\":\"record\",\"name\":\"User\",\"fields\":[{\"name\":\"id\",\"type\":\"long\"},{\"name\":\"level\",\"type\":{\"type\":\"enum\",\"name\":\"CustomerLevel\",\"symbols\":[\"BRONZE\",\"SILVER\",\"GOLD\",\"UNWANTED\"]}},{\"name\":\"name\",\"type\":\"string\"}]}]}]}"); - public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } - - private static SpecificData MODEL$ = new SpecificData(); - - private static final BinaryMessageEncoder ENCODER = - new BinaryMessageEncoder(MODEL$, SCHEMA$); - - private static final BinaryMessageDecoder DECODER = - new BinaryMessageDecoder(MODEL$, SCHEMA$); - - /** - * Return the BinaryMessageEncoder instance used by this class. - * @return the message encoder used by this class - */ - public static BinaryMessageEncoder getEncoder() { - return ENCODER; - } - - /** - * Return the BinaryMessageDecoder instance used by this class. - * @return the message decoder used by this class - */ - public static BinaryMessageDecoder getDecoder() { - return DECODER; - } - - /** - * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. - * @param resolver a {@link SchemaStore} used to find schemas by fingerprint - * @return a BinaryMessageDecoder instance for this class backed by the given SchemaStore - */ - public static BinaryMessageDecoder createDecoder(SchemaStore resolver) { - return new BinaryMessageDecoder(MODEL$, SCHEMA$, resolver); - } - - /** - * Serializes this OrderAndUser to a ByteBuffer. - * @return a buffer holding the serialized data for this instance - * @throws java.io.IOException if this instance could not be serialized - */ - public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { - return ENCODER.encode(this); - } - - /** - * Deserializes a OrderAndUser from a ByteBuffer. - * @param b a byte buffer holding serialized data for an instance of this class - * @return a OrderAndUser instance decoded from the given buffer - * @throws java.io.IOException if the given bytes could not be deserialized into an instance of this class - */ - public static OrderAndUser fromByteBuffer( - java.nio.ByteBuffer b) throws java.io.IOException { - return DECODER.decode(b); - } - - @Deprecated public de.trion.microservices.avro.Order order; - @Deprecated public de.trion.microservices.avro.User user; - - /** - * Default constructor. Note that this does not initialize fields - * to their default values from the schema. If that is desired then - * one should use newBuilder(). - */ - public OrderAndUser() {} - - /** - * All-args constructor. - * @param order The new value for order - * @param user The new value for user - */ - public OrderAndUser(de.trion.microservices.avro.Order order, de.trion.microservices.avro.User user) { - this.order = order; - this.user = user; - } - - public org.apache.avro.specific.SpecificData getSpecificData() { return MODEL$; } - public org.apache.avro.Schema getSchema() { return SCHEMA$; } - // Used by DatumWriter. Applications should not call. - public java.lang.Object get(int field$) { - switch (field$) { - case 0: return order; - case 1: return user; - default: throw new org.apache.avro.AvroRuntimeException("Bad index"); - } - } - - // Used by DatumReader. Applications should not call. - @SuppressWarnings(value="unchecked") - public void put(int field$, java.lang.Object value$) { - switch (field$) { - case 0: order = (de.trion.microservices.avro.Order)value$; break; - case 1: user = (de.trion.microservices.avro.User)value$; break; - default: throw new org.apache.avro.AvroRuntimeException("Bad index"); - } - } - - /** - * Gets the value of the 'order' field. - * @return The value of the 'order' field. - */ - public de.trion.microservices.avro.Order getOrder() { - return order; - } - - - /** - * Sets the value of the 'order' field. - * @param value the value to set. - */ - public void setOrder(de.trion.microservices.avro.Order value) { - this.order = value; - } - - /** - * Gets the value of the 'user' field. - * @return The value of the 'user' field. - */ - public de.trion.microservices.avro.User getUser() { - return user; - } - - - /** - * Sets the value of the 'user' field. - * @param value the value to set. - */ - public void setUser(de.trion.microservices.avro.User value) { - this.user = value; - } - - /** - * Creates a new OrderAndUser RecordBuilder. - * @return A new OrderAndUser RecordBuilder - */ - public static de.trion.microservices.avro.OrderAndUser.Builder newBuilder() { - return new de.trion.microservices.avro.OrderAndUser.Builder(); - } - - /** - * Creates a new OrderAndUser RecordBuilder by copying an existing Builder. - * @param other The existing builder to copy. - * @return A new OrderAndUser RecordBuilder - */ - public static de.trion.microservices.avro.OrderAndUser.Builder newBuilder(de.trion.microservices.avro.OrderAndUser.Builder other) { - if (other == null) { - return new de.trion.microservices.avro.OrderAndUser.Builder(); - } else { - return new de.trion.microservices.avro.OrderAndUser.Builder(other); - } - } - - /** - * Creates a new OrderAndUser RecordBuilder by copying an existing OrderAndUser instance. - * @param other The existing instance to copy. - * @return A new OrderAndUser RecordBuilder - */ - public static de.trion.microservices.avro.OrderAndUser.Builder newBuilder(de.trion.microservices.avro.OrderAndUser other) { - if (other == null) { - return new de.trion.microservices.avro.OrderAndUser.Builder(); - } else { - return new de.trion.microservices.avro.OrderAndUser.Builder(other); - } - } - - /** - * RecordBuilder for OrderAndUser instances. - */ - public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase - implements org.apache.avro.data.RecordBuilder { - - private de.trion.microservices.avro.Order order; - private de.trion.microservices.avro.Order.Builder orderBuilder; - private de.trion.microservices.avro.User user; - private de.trion.microservices.avro.User.Builder userBuilder; - - /** Creates a new Builder */ - private Builder() { - super(SCHEMA$); - } - - /** - * Creates a Builder by copying an existing Builder. - * @param other The existing Builder to copy. - */ - private Builder(de.trion.microservices.avro.OrderAndUser.Builder other) { - super(other); - if (isValidValue(fields()[0], other.order)) { - this.order = data().deepCopy(fields()[0].schema(), other.order); - fieldSetFlags()[0] = other.fieldSetFlags()[0]; - } - if (other.hasOrderBuilder()) { - this.orderBuilder = de.trion.microservices.avro.Order.newBuilder(other.getOrderBuilder()); - } - if (isValidValue(fields()[1], other.user)) { - this.user = data().deepCopy(fields()[1].schema(), other.user); - fieldSetFlags()[1] = other.fieldSetFlags()[1]; - } - if (other.hasUserBuilder()) { - this.userBuilder = de.trion.microservices.avro.User.newBuilder(other.getUserBuilder()); - } - } - - /** - * Creates a Builder by copying an existing OrderAndUser instance - * @param other The existing instance to copy. - */ - private Builder(de.trion.microservices.avro.OrderAndUser other) { - super(SCHEMA$); - if (isValidValue(fields()[0], other.order)) { - this.order = data().deepCopy(fields()[0].schema(), other.order); - fieldSetFlags()[0] = true; - } - this.orderBuilder = null; - if (isValidValue(fields()[1], other.user)) { - this.user = data().deepCopy(fields()[1].schema(), other.user); - fieldSetFlags()[1] = true; - } - this.userBuilder = null; - } - - /** - * Gets the value of the 'order' field. - * @return The value. - */ - public de.trion.microservices.avro.Order getOrder() { - return order; - } - - - /** - * Sets the value of the 'order' field. - * @param value The value of 'order'. - * @return This builder. - */ - public de.trion.microservices.avro.OrderAndUser.Builder setOrder(de.trion.microservices.avro.Order value) { - validate(fields()[0], value); - this.orderBuilder = null; - this.order = value; - fieldSetFlags()[0] = true; - return this; - } - - /** - * Checks whether the 'order' field has been set. - * @return True if the 'order' field has been set, false otherwise. - */ - public boolean hasOrder() { - return fieldSetFlags()[0]; - } - - /** - * Gets the Builder instance for the 'order' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public de.trion.microservices.avro.Order.Builder getOrderBuilder() { - if (orderBuilder == null) { - if (hasOrder()) { - setOrderBuilder(de.trion.microservices.avro.Order.newBuilder(order)); - } else { - setOrderBuilder(de.trion.microservices.avro.Order.newBuilder()); - } - } - return orderBuilder; - } - - /** - * Sets the Builder instance for the 'order' field - * @param value The builder instance that must be set. - * @return This builder. - */ - public de.trion.microservices.avro.OrderAndUser.Builder setOrderBuilder(de.trion.microservices.avro.Order.Builder value) { - clearOrder(); - orderBuilder = value; - return this; - } - - /** - * Checks whether the 'order' field has an active Builder instance - * @return True if the 'order' field has an active Builder instance - */ - public boolean hasOrderBuilder() { - return orderBuilder != null; - } - - /** - * Clears the value of the 'order' field. - * @return This builder. - */ - public de.trion.microservices.avro.OrderAndUser.Builder clearOrder() { - order = null; - orderBuilder = null; - fieldSetFlags()[0] = false; - return this; - } - - /** - * Gets the value of the 'user' field. - * @return The value. - */ - public de.trion.microservices.avro.User getUser() { - return user; - } - - - /** - * Sets the value of the 'user' field. - * @param value The value of 'user'. - * @return This builder. - */ - public de.trion.microservices.avro.OrderAndUser.Builder setUser(de.trion.microservices.avro.User value) { - validate(fields()[1], value); - this.userBuilder = null; - this.user = value; - fieldSetFlags()[1] = true; - return this; - } - - /** - * Checks whether the 'user' field has been set. - * @return True if the 'user' field has been set, false otherwise. - */ - public boolean hasUser() { - return fieldSetFlags()[1]; - } - - /** - * Gets the Builder instance for the 'user' field and creates one if it doesn't exist yet. - * @return This builder. - */ - public de.trion.microservices.avro.User.Builder getUserBuilder() { - if (userBuilder == null) { - if (hasUser()) { - setUserBuilder(de.trion.microservices.avro.User.newBuilder(user)); - } else { - setUserBuilder(de.trion.microservices.avro.User.newBuilder()); - } - } - return userBuilder; - } - - /** - * Sets the Builder instance for the 'user' field - * @param value The builder instance that must be set. - * @return This builder. - */ - public de.trion.microservices.avro.OrderAndUser.Builder setUserBuilder(de.trion.microservices.avro.User.Builder value) { - clearUser(); - userBuilder = value; - return this; - } - - /** - * Checks whether the 'user' field has an active Builder instance - * @return True if the 'user' field has an active Builder instance - */ - public boolean hasUserBuilder() { - return userBuilder != null; - } - - /** - * Clears the value of the 'user' field. - * @return This builder. - */ - public de.trion.microservices.avro.OrderAndUser.Builder clearUser() { - user = null; - userBuilder = null; - fieldSetFlags()[1] = false; - return this; - } - - @Override - @SuppressWarnings("unchecked") - public OrderAndUser build() { - try { - OrderAndUser record = new OrderAndUser(); - if (orderBuilder != null) { - try { - record.order = this.orderBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("order")); - throw e; - } - } else { - record.order = fieldSetFlags()[0] ? this.order : (de.trion.microservices.avro.Order) defaultValue(fields()[0]); - } - if (userBuilder != null) { - try { - record.user = this.userBuilder.build(); - } catch (org.apache.avro.AvroMissingFieldException e) { - e.addParentField(record.getSchema().getField("user")); - throw e; - } - } else { - record.user = fieldSetFlags()[1] ? this.user : (de.trion.microservices.avro.User) defaultValue(fields()[1]); - } - return record; - } catch (org.apache.avro.AvroMissingFieldException e) { - throw e; - } catch (java.lang.Exception e) { - throw new org.apache.avro.AvroRuntimeException(e); - } - } - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumWriter - WRITER$ = (org.apache.avro.io.DatumWriter)MODEL$.createDatumWriter(SCHEMA$); - - @Override public void writeExternal(java.io.ObjectOutput out) - throws java.io.IOException { - WRITER$.write(this, SpecificData.getEncoder(out)); - } - - @SuppressWarnings("unchecked") - private static final org.apache.avro.io.DatumReader - READER$ = (org.apache.avro.io.DatumReader)MODEL$.createDatumReader(SCHEMA$); - - @Override public void readExternal(java.io.ObjectInput in) - throws java.io.IOException { - READER$.read(this, SpecificData.getDecoder(in)); - } - - @Override protected boolean hasCustomCoders() { return true; } - - @Override public void customEncode(org.apache.avro.io.Encoder out) - throws java.io.IOException - { - this.order.customEncode(out); - - if (this.user == null) { - out.writeIndex(0); - out.writeNull(); - } else { - out.writeIndex(1); - this.user.customEncode(out); - } - - } - - @Override public void customDecode(org.apache.avro.io.ResolvingDecoder in) - throws java.io.IOException - { - org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); - if (fieldOrder == null) { - if (this.order == null) { - this.order = new de.trion.microservices.avro.Order(); - } - this.order.customDecode(in); - - if (in.readIndex() != 1) { - in.readNull(); - this.user = null; - } else { - if (this.user == null) { - this.user = new de.trion.microservices.avro.User(); - } - this.user.customDecode(in); - } - - } else { - for (int i = 0; i < 2; i++) { - switch (fieldOrder[i].pos()) { - case 0: - if (this.order == null) { - this.order = new de.trion.microservices.avro.Order(); - } - this.order.customDecode(in); - break; - - case 1: - if (in.readIndex() != 1) { - in.readNull(); - this.user = null; - } else { - if (this.user == null) { - this.user = new de.trion.microservices.avro.User(); - } - this.user.customDecode(in); - } - break; - - default: - throw new java.io.IOException("Corrupt ResolvingDecoder."); - } - } - } - } -} - - - - - - - - - -