|
| 1 | +/** |
| 2 | + * Autogenerated by Avro |
| 3 | + * |
| 4 | + * DO NOT EDIT DIRECTLY |
| 5 | + */ |
| 6 | +package org.springframework.cloud.contract.verifier.messaging.internal; |
| 7 | + |
| 8 | +import org.apache.avro.message.BinaryMessageDecoder; |
| 9 | +import org.apache.avro.message.BinaryMessageEncoder; |
| 10 | +import org.apache.avro.message.SchemaStore; |
| 11 | +import org.apache.avro.specific.SpecificData; |
| 12 | + |
| 13 | +/** Dummy Avro object for testing purposes */ |
| 14 | +@org.apache.avro.specific.AvroGenerated |
| 15 | +public class FooAvro extends org.apache.avro.specific.SpecificRecordBase |
| 16 | + implements org.apache.avro.specific.SpecificRecord { |
| 17 | + private static final long serialVersionUID = -2221379489582530192L; |
| 18 | + |
| 19 | + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse( |
| 20 | + "{\"type\":\"record\",\"name\":\"FooAvro\",\"namespace\":\"org.springframework.cloud.contract.verifier.messaging.internal\",\"doc\":\"Dummy Avro object for testing purposes\",\"fields\":[{\"name\":\"fooAvro\",\"type\":{\"type\":\"string\",\"avro.java.string\":\"String\"},\"doc\":\"foo field\"}]}"); |
| 21 | + |
| 22 | + public static org.apache.avro.Schema getClassSchema() { |
| 23 | + return SCHEMA$; |
| 24 | + } |
| 25 | + |
| 26 | + private static final SpecificData MODEL$ = new SpecificData(); |
| 27 | + |
| 28 | + private static final BinaryMessageEncoder<FooAvro> ENCODER = new BinaryMessageEncoder<>( |
| 29 | + MODEL$, SCHEMA$); |
| 30 | + |
| 31 | + private static final BinaryMessageDecoder<FooAvro> DECODER = new BinaryMessageDecoder<>( |
| 32 | + MODEL$, SCHEMA$); |
| 33 | + |
| 34 | + /** |
| 35 | + * Return the BinaryMessageEncoder instance used by this class. |
| 36 | + * @return the message encoder used by this class |
| 37 | + */ |
| 38 | + public static BinaryMessageEncoder<FooAvro> getEncoder() { |
| 39 | + return ENCODER; |
| 40 | + } |
| 41 | + |
| 42 | + /** |
| 43 | + * Return the BinaryMessageDecoder instance used by this class. |
| 44 | + * @return the message decoder used by this class |
| 45 | + */ |
| 46 | + public static BinaryMessageDecoder<FooAvro> getDecoder() { |
| 47 | + return DECODER; |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * Create a new BinaryMessageDecoder instance for this class that uses the specified |
| 52 | + * {@link SchemaStore}. |
| 53 | + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint |
| 54 | + * @return a BinaryMessageDecoder instance for this class backed by the given |
| 55 | + * SchemaStore |
| 56 | + */ |
| 57 | + public static BinaryMessageDecoder<FooAvro> createDecoder(SchemaStore resolver) { |
| 58 | + return new BinaryMessageDecoder<>(MODEL$, SCHEMA$, resolver); |
| 59 | + } |
| 60 | + |
| 61 | + /** |
| 62 | + * Serializes this FooAvro to a ByteBuffer. |
| 63 | + * @return a buffer holding the serialized data for this instance |
| 64 | + * @throws java.io.IOException if this instance could not be serialized |
| 65 | + */ |
| 66 | + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { |
| 67 | + return ENCODER.encode(this); |
| 68 | + } |
| 69 | + |
| 70 | + /** |
| 71 | + * Deserializes a FooAvro from a ByteBuffer. |
| 72 | + * @param b a byte buffer holding serialized data for an instance of this class |
| 73 | + * @return a FooAvro instance decoded from the given buffer |
| 74 | + * @throws java.io.IOException if the given bytes could not be deserialized into an |
| 75 | + * instance of this class |
| 76 | + */ |
| 77 | + public static FooAvro fromByteBuffer(java.nio.ByteBuffer b) |
| 78 | + throws java.io.IOException { |
| 79 | + return DECODER.decode(b); |
| 80 | + } |
| 81 | + |
| 82 | + /** foo field */ |
| 83 | + private java.lang.String fooAvro; |
| 84 | + |
| 85 | + /** |
| 86 | + * Default constructor. Note that this does not initialize fields to their default |
| 87 | + * values from the schema. If that is desired then one should use |
| 88 | + * <code>newBuilder()</code>. |
| 89 | + */ |
| 90 | + public FooAvro() { |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * All-args constructor. |
| 95 | + * @param fooAvro foo field |
| 96 | + */ |
| 97 | + public FooAvro(java.lang.String fooAvro) { |
| 98 | + this.fooAvro = fooAvro; |
| 99 | + } |
| 100 | + |
| 101 | + @Override |
| 102 | + public org.apache.avro.specific.SpecificData getSpecificData() { |
| 103 | + return MODEL$; |
| 104 | + } |
| 105 | + |
| 106 | + @Override |
| 107 | + public org.apache.avro.Schema getSchema() { |
| 108 | + return SCHEMA$; |
| 109 | + } |
| 110 | + |
| 111 | + // Used by DatumWriter. Applications should not call. |
| 112 | + @Override |
| 113 | + public java.lang.Object get(int field$) { |
| 114 | + switch (field$) { |
| 115 | + case 0: |
| 116 | + return fooAvro; |
| 117 | + default: |
| 118 | + throw new IndexOutOfBoundsException("Invalid index: " + field$); |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + // Used by DatumReader. Applications should not call. |
| 123 | + @Override |
| 124 | + @SuppressWarnings(value = "unchecked") |
| 125 | + public void put(int field$, java.lang.Object value$) { |
| 126 | + switch (field$) { |
| 127 | + case 0: |
| 128 | + fooAvro = value$ != null ? value$.toString() : null; |
| 129 | + break; |
| 130 | + default: |
| 131 | + throw new IndexOutOfBoundsException("Invalid index: " + field$); |
| 132 | + } |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * Gets the value of the 'fooAvro' field. |
| 137 | + * @return foo field |
| 138 | + */ |
| 139 | + public java.lang.String getFooAvro() { |
| 140 | + return fooAvro; |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * Sets the value of the 'fooAvro' field. foo field |
| 145 | + * @param value the value to set. |
| 146 | + */ |
| 147 | + public void setFooAvro(java.lang.String value) { |
| 148 | + this.fooAvro = value; |
| 149 | + } |
| 150 | + |
| 151 | + /** |
| 152 | + * Creates a new FooAvro RecordBuilder. |
| 153 | + * @return A new FooAvro RecordBuilder |
| 154 | + */ |
| 155 | + public static org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder newBuilder() { |
| 156 | + return new org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder(); |
| 157 | + } |
| 158 | + |
| 159 | + /** |
| 160 | + * Creates a new FooAvro RecordBuilder by copying an existing Builder. |
| 161 | + * @param other The existing builder to copy. |
| 162 | + * @return A new FooAvro RecordBuilder |
| 163 | + */ |
| 164 | + public static org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder newBuilder( |
| 165 | + org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder other) { |
| 166 | + if (other == null) { |
| 167 | + return new org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder(); |
| 168 | + } |
| 169 | + else { |
| 170 | + return new org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder( |
| 171 | + other); |
| 172 | + } |
| 173 | + } |
| 174 | + |
| 175 | + /** |
| 176 | + * Creates a new FooAvro RecordBuilder by copying an existing FooAvro instance. |
| 177 | + * @param other The existing instance to copy. |
| 178 | + * @return A new FooAvro RecordBuilder |
| 179 | + */ |
| 180 | + public static org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder newBuilder( |
| 181 | + org.springframework.cloud.contract.verifier.messaging.internal.FooAvro other) { |
| 182 | + if (other == null) { |
| 183 | + return new org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder(); |
| 184 | + } |
| 185 | + else { |
| 186 | + return new org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder( |
| 187 | + other); |
| 188 | + } |
| 189 | + } |
| 190 | + |
| 191 | + /** |
| 192 | + * RecordBuilder for FooAvro instances. |
| 193 | + */ |
| 194 | + @org.apache.avro.specific.AvroGenerated |
| 195 | + public static class Builder |
| 196 | + extends org.apache.avro.specific.SpecificRecordBuilderBase<FooAvro> |
| 197 | + implements org.apache.avro.data.RecordBuilder<FooAvro> { |
| 198 | + |
| 199 | + /** foo field */ |
| 200 | + private java.lang.String fooAvro; |
| 201 | + |
| 202 | + /** Creates a new Builder */ |
| 203 | + private Builder() { |
| 204 | + super(SCHEMA$, MODEL$); |
| 205 | + } |
| 206 | + |
| 207 | + /** |
| 208 | + * Creates a Builder by copying an existing Builder. |
| 209 | + * @param other The existing Builder to copy. |
| 210 | + */ |
| 211 | + private Builder( |
| 212 | + org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder other) { |
| 213 | + super(other); |
| 214 | + if (isValidValue(fields()[0], other.fooAvro)) { |
| 215 | + this.fooAvro = data().deepCopy(fields()[0].schema(), other.fooAvro); |
| 216 | + fieldSetFlags()[0] = other.fieldSetFlags()[0]; |
| 217 | + } |
| 218 | + } |
| 219 | + |
| 220 | + /** |
| 221 | + * Creates a Builder by copying an existing FooAvro instance |
| 222 | + * @param other The existing instance to copy. |
| 223 | + */ |
| 224 | + private Builder( |
| 225 | + org.springframework.cloud.contract.verifier.messaging.internal.FooAvro other) { |
| 226 | + super(SCHEMA$, MODEL$); |
| 227 | + if (isValidValue(fields()[0], other.fooAvro)) { |
| 228 | + this.fooAvro = data().deepCopy(fields()[0].schema(), other.fooAvro); |
| 229 | + fieldSetFlags()[0] = true; |
| 230 | + } |
| 231 | + } |
| 232 | + |
| 233 | + /** |
| 234 | + * Gets the value of the 'fooAvro' field. foo field |
| 235 | + * @return The value. |
| 236 | + */ |
| 237 | + public java.lang.String getFooAvro() { |
| 238 | + return fooAvro; |
| 239 | + } |
| 240 | + |
| 241 | + /** |
| 242 | + * Sets the value of the 'fooAvro' field. foo field |
| 243 | + * @param value The value of 'fooAvro'. |
| 244 | + * @return This builder. |
| 245 | + */ |
| 246 | + public org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder setFooAvro( |
| 247 | + java.lang.String value) { |
| 248 | + validate(fields()[0], value); |
| 249 | + this.fooAvro = value; |
| 250 | + fieldSetFlags()[0] = true; |
| 251 | + return this; |
| 252 | + } |
| 253 | + |
| 254 | + /** |
| 255 | + * Checks whether the 'fooAvro' field has been set. foo field |
| 256 | + * @return True if the 'fooAvro' field has been set, false otherwise. |
| 257 | + */ |
| 258 | + public boolean hasFooAvro() { |
| 259 | + return fieldSetFlags()[0]; |
| 260 | + } |
| 261 | + |
| 262 | + /** |
| 263 | + * Clears the value of the 'fooAvro' field. foo field |
| 264 | + * @return This builder. |
| 265 | + */ |
| 266 | + public org.springframework.cloud.contract.verifier.messaging.internal.FooAvro.Builder clearFooAvro() { |
| 267 | + fooAvro = null; |
| 268 | + fieldSetFlags()[0] = false; |
| 269 | + return this; |
| 270 | + } |
| 271 | + |
| 272 | + @Override |
| 273 | + @SuppressWarnings("unchecked") |
| 274 | + public FooAvro build() { |
| 275 | + try { |
| 276 | + FooAvro record = new FooAvro(); |
| 277 | + record.fooAvro = fieldSetFlags()[0] ? |
| 278 | + this.fooAvro : |
| 279 | + (java.lang.String) defaultValue(fields()[0]); |
| 280 | + return record; |
| 281 | + } |
| 282 | + catch (org.apache.avro.AvroMissingFieldException e) { |
| 283 | + throw e; |
| 284 | + } |
| 285 | + catch (java.lang.Exception e) { |
| 286 | + throw new org.apache.avro.AvroRuntimeException(e); |
| 287 | + } |
| 288 | + } |
| 289 | + } |
| 290 | + |
| 291 | + @SuppressWarnings("unchecked") |
| 292 | + private static final org.apache.avro.io.DatumWriter<FooAvro> WRITER$ = (org.apache.avro.io.DatumWriter<FooAvro>) MODEL$.createDatumWriter( |
| 293 | + SCHEMA$); |
| 294 | + |
| 295 | + @Override |
| 296 | + public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException { |
| 297 | + WRITER$.write(this, SpecificData.getEncoder(out)); |
| 298 | + } |
| 299 | + |
| 300 | + @SuppressWarnings("unchecked") |
| 301 | + private static final org.apache.avro.io.DatumReader<FooAvro> READER$ = (org.apache.avro.io.DatumReader<FooAvro>) MODEL$.createDatumReader( |
| 302 | + SCHEMA$); |
| 303 | + |
| 304 | + @Override |
| 305 | + public void readExternal(java.io.ObjectInput in) throws java.io.IOException { |
| 306 | + READER$.read(this, SpecificData.getDecoder(in)); |
| 307 | + } |
| 308 | + |
| 309 | + @Override |
| 310 | + protected boolean hasCustomCoders() { |
| 311 | + return true; |
| 312 | + } |
| 313 | + |
| 314 | + @Override |
| 315 | + public void customEncode(org.apache.avro.io.Encoder out) throws java.io.IOException { |
| 316 | + out.writeString(this.fooAvro); |
| 317 | + |
| 318 | + } |
| 319 | + |
| 320 | + @Override |
| 321 | + public void customDecode(org.apache.avro.io.ResolvingDecoder in) |
| 322 | + throws java.io.IOException { |
| 323 | + org.apache.avro.Schema.Field[] fieldOrder = in.readFieldOrderIfDiff(); |
| 324 | + if (fieldOrder == null) { |
| 325 | + this.fooAvro = in.readString(); |
| 326 | + |
| 327 | + } |
| 328 | + else { |
| 329 | + for (int i = 0; i < 1; i++) { |
| 330 | + switch (fieldOrder[i].pos()) { |
| 331 | + case 0: |
| 332 | + this.fooAvro = in.readString(); |
| 333 | + break; |
| 334 | + |
| 335 | + default: |
| 336 | + throw new java.io.IOException("Corrupt ResolvingDecoder."); |
| 337 | + } |
| 338 | + } |
| 339 | + } |
| 340 | + } |
| 341 | +} |
| 342 | + |
| 343 | + |
| 344 | + |
| 345 | + |
| 346 | + |
| 347 | + |
| 348 | + |
| 349 | + |
| 350 | + |
| 351 | + |
0 commit comments