|
| 1 | +/** |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | +/** |
| 19 | + * Autogenerated by Avro |
| 20 | + * |
| 21 | + * DO NOT EDIT DIRECTLY |
| 22 | + */ |
| 23 | +package org.apache.rocketmq.serializer.avro; |
| 24 | + |
| 25 | +import org.apache.avro.message.BinaryMessageDecoder; |
| 26 | +import org.apache.avro.message.BinaryMessageEncoder; |
| 27 | +import org.apache.avro.message.SchemaStore; |
| 28 | +import org.apache.avro.specific.SpecificData; |
| 29 | + |
| 30 | +@SuppressWarnings("all") |
| 31 | +@org.apache.avro.specific.AvroGenerated |
| 32 | +public class User extends org.apache.avro.specific.SpecificRecordBase implements org.apache.avro.specific.SpecificRecord { |
| 33 | + private static final long serialVersionUID = 3860209681772090087L; |
| 34 | + public static final org.apache.avro.Schema SCHEMA$ = new org.apache.avro.Schema.Parser().parse("{\"type\":\"record\",\"name\":\"User\",\"namespace\":\"org.apache.rocketmq.serializer.avro\",\"fields\":[{\"name\":\"name\",\"type\":\"string\"},{\"name\":\"age\",\"type\":\"int\"}]}"); |
| 35 | + public static org.apache.avro.Schema getClassSchema() { return SCHEMA$; } |
| 36 | + |
| 37 | + private static SpecificData MODEL$ = new SpecificData(); |
| 38 | + |
| 39 | + private static final BinaryMessageEncoder<User> ENCODER = |
| 40 | + new BinaryMessageEncoder<User>(MODEL$, SCHEMA$); |
| 41 | + |
| 42 | + private static final BinaryMessageDecoder<User> DECODER = |
| 43 | + new BinaryMessageDecoder<User>(MODEL$, SCHEMA$); |
| 44 | + |
| 45 | + /** |
| 46 | + * Return the BinaryMessageDecoder instance used by this class. |
| 47 | + */ |
| 48 | + public static BinaryMessageDecoder<User> getDecoder() { |
| 49 | + return DECODER; |
| 50 | + } |
| 51 | + |
| 52 | + /** |
| 53 | + * Create a new BinaryMessageDecoder instance for this class that uses the specified {@link SchemaStore}. |
| 54 | + * @param resolver a {@link SchemaStore} used to find schemas by fingerprint |
| 55 | + */ |
| 56 | + public static BinaryMessageDecoder<User> createDecoder(SchemaStore resolver) { |
| 57 | + return new BinaryMessageDecoder<User>(MODEL$, SCHEMA$, resolver); |
| 58 | + } |
| 59 | + |
| 60 | + /** Serializes this User to a ByteBuffer. */ |
| 61 | + public java.nio.ByteBuffer toByteBuffer() throws java.io.IOException { |
| 62 | + return ENCODER.encode(this); |
| 63 | + } |
| 64 | + |
| 65 | + /** Deserializes a User from a ByteBuffer. */ |
| 66 | + public static User fromByteBuffer( |
| 67 | + java.nio.ByteBuffer b) throws java.io.IOException { |
| 68 | + return DECODER.decode(b); |
| 69 | + } |
| 70 | + |
| 71 | + @Deprecated public CharSequence name; |
| 72 | + @Deprecated public int age; |
| 73 | + |
| 74 | + /** |
| 75 | + * Default constructor. Note that this does not initialize fields |
| 76 | + * to their default values from the schema. If that is desired then |
| 77 | + * one should use <code>newBuilder()</code>. |
| 78 | + */ |
| 79 | + public User() {} |
| 80 | + |
| 81 | + /** |
| 82 | + * All-args constructor. |
| 83 | + * @param name The new value for name |
| 84 | + * @param age The new value for age |
| 85 | + */ |
| 86 | + public User(CharSequence name, Integer age) { |
| 87 | + this.name = name; |
| 88 | + this.age = age; |
| 89 | + } |
| 90 | + |
| 91 | + public org.apache.avro.Schema getSchema() { return SCHEMA$; } |
| 92 | + // Used by DatumWriter. Applications should not call. |
| 93 | + public Object get(int field$) { |
| 94 | + switch (field$) { |
| 95 | + case 0: return name; |
| 96 | + case 1: return age; |
| 97 | + default: throw new org.apache.avro.AvroRuntimeException("Bad index"); |
| 98 | + } |
| 99 | + } |
| 100 | + |
| 101 | + // Used by DatumReader. Applications should not call. |
| 102 | + @SuppressWarnings(value="unchecked") |
| 103 | + public void put(int field$, Object value$) { |
| 104 | + switch (field$) { |
| 105 | + case 0: name = (CharSequence)value$; break; |
| 106 | + case 1: age = (Integer)value$; break; |
| 107 | + default: throw new org.apache.avro.AvroRuntimeException("Bad index"); |
| 108 | + } |
| 109 | + } |
| 110 | + |
| 111 | + /** |
| 112 | + * Gets the value of the 'name' field. |
| 113 | + * @return The value of the 'name' field. |
| 114 | + */ |
| 115 | + public CharSequence getName() { |
| 116 | + return name; |
| 117 | + } |
| 118 | + |
| 119 | + /** |
| 120 | + * Sets the value of the 'name' field. |
| 121 | + * @param value the value to set. |
| 122 | + */ |
| 123 | + public void setName(CharSequence value) { |
| 124 | + this.name = value; |
| 125 | + } |
| 126 | + |
| 127 | + /** |
| 128 | + * Gets the value of the 'age' field. |
| 129 | + * @return The value of the 'age' field. |
| 130 | + */ |
| 131 | + public Integer getAge() { |
| 132 | + return age; |
| 133 | + } |
| 134 | + |
| 135 | + /** |
| 136 | + * Sets the value of the 'age' field. |
| 137 | + * @param value the value to set. |
| 138 | + */ |
| 139 | + public void setAge(Integer value) { |
| 140 | + this.age = value; |
| 141 | + } |
| 142 | + |
| 143 | + /** |
| 144 | + * Creates a new User RecordBuilder. |
| 145 | + * @return A new User RecordBuilder |
| 146 | + */ |
| 147 | + public static User.Builder newBuilder() { |
| 148 | + return new User.Builder(); |
| 149 | + } |
| 150 | + |
| 151 | + /** |
| 152 | + * Creates a new User RecordBuilder by copying an existing Builder. |
| 153 | + * @param other The existing builder to copy. |
| 154 | + * @return A new User RecordBuilder |
| 155 | + */ |
| 156 | + public static User.Builder newBuilder(User.Builder other) { |
| 157 | + return new User.Builder(other); |
| 158 | + } |
| 159 | + |
| 160 | + /** |
| 161 | + * Creates a new User RecordBuilder by copying an existing User instance. |
| 162 | + * @param other The existing instance to copy. |
| 163 | + * @return A new User RecordBuilder |
| 164 | + */ |
| 165 | + public static User.Builder newBuilder(User other) { |
| 166 | + return new User.Builder(other); |
| 167 | + } |
| 168 | + |
| 169 | + /** |
| 170 | + * RecordBuilder for User instances. |
| 171 | + */ |
| 172 | + public static class Builder extends org.apache.avro.specific.SpecificRecordBuilderBase<User> |
| 173 | + implements org.apache.avro.data.RecordBuilder<User> { |
| 174 | + |
| 175 | + private CharSequence name; |
| 176 | + private int age; |
| 177 | + |
| 178 | + /** Creates a new Builder */ |
| 179 | + private Builder() { |
| 180 | + super(SCHEMA$); |
| 181 | + } |
| 182 | + |
| 183 | + /** |
| 184 | + * Creates a Builder by copying an existing Builder. |
| 185 | + * @param other The existing Builder to copy. |
| 186 | + */ |
| 187 | + private Builder(User.Builder other) { |
| 188 | + super(other); |
| 189 | + if (isValidValue(fields()[0], other.name)) { |
| 190 | + this.name = data().deepCopy(fields()[0].schema(), other.name); |
| 191 | + fieldSetFlags()[0] = true; |
| 192 | + } |
| 193 | + if (isValidValue(fields()[1], other.age)) { |
| 194 | + this.age = data().deepCopy(fields()[1].schema(), other.age); |
| 195 | + fieldSetFlags()[1] = true; |
| 196 | + } |
| 197 | + } |
| 198 | + |
| 199 | + /** |
| 200 | + * Creates a Builder by copying an existing User instance |
| 201 | + * @param other The existing instance to copy. |
| 202 | + */ |
| 203 | + private Builder(User other) { |
| 204 | + super(SCHEMA$); |
| 205 | + if (isValidValue(fields()[0], other.name)) { |
| 206 | + this.name = data().deepCopy(fields()[0].schema(), other.name); |
| 207 | + fieldSetFlags()[0] = true; |
| 208 | + } |
| 209 | + if (isValidValue(fields()[1], other.age)) { |
| 210 | + this.age = data().deepCopy(fields()[1].schema(), other.age); |
| 211 | + fieldSetFlags()[1] = true; |
| 212 | + } |
| 213 | + } |
| 214 | + |
| 215 | + /** |
| 216 | + * Gets the value of the 'name' field. |
| 217 | + * @return The value. |
| 218 | + */ |
| 219 | + public CharSequence getName() { |
| 220 | + return name; |
| 221 | + } |
| 222 | + |
| 223 | + /** |
| 224 | + * Sets the value of the 'name' field. |
| 225 | + * @param value The value of 'name'. |
| 226 | + * @return This builder. |
| 227 | + */ |
| 228 | + public User.Builder setName(CharSequence value) { |
| 229 | + validate(fields()[0], value); |
| 230 | + this.name = value; |
| 231 | + fieldSetFlags()[0] = true; |
| 232 | + return this; |
| 233 | + } |
| 234 | + |
| 235 | + /** |
| 236 | + * Checks whether the 'name' field has been set. |
| 237 | + * @return True if the 'name' field has been set, false otherwise. |
| 238 | + */ |
| 239 | + public boolean hasName() { |
| 240 | + return fieldSetFlags()[0]; |
| 241 | + } |
| 242 | + |
| 243 | + |
| 244 | + /** |
| 245 | + * Clears the value of the 'name' field. |
| 246 | + * @return This builder. |
| 247 | + */ |
| 248 | + public User.Builder clearName() { |
| 249 | + name = null; |
| 250 | + fieldSetFlags()[0] = false; |
| 251 | + return this; |
| 252 | + } |
| 253 | + |
| 254 | + /** |
| 255 | + * Gets the value of the 'age' field. |
| 256 | + * @return The value. |
| 257 | + */ |
| 258 | + public Integer getAge() { |
| 259 | + return age; |
| 260 | + } |
| 261 | + |
| 262 | + /** |
| 263 | + * Sets the value of the 'age' field. |
| 264 | + * @param value The value of 'age'. |
| 265 | + * @return This builder. |
| 266 | + */ |
| 267 | + public User.Builder setAge(int value) { |
| 268 | + validate(fields()[1], value); |
| 269 | + this.age = value; |
| 270 | + fieldSetFlags()[1] = true; |
| 271 | + return this; |
| 272 | + } |
| 273 | + |
| 274 | + /** |
| 275 | + * Checks whether the 'age' field has been set. |
| 276 | + * @return True if the 'age' field has been set, false otherwise. |
| 277 | + */ |
| 278 | + public boolean hasAge() { |
| 279 | + return fieldSetFlags()[1]; |
| 280 | + } |
| 281 | + |
| 282 | + |
| 283 | + /** |
| 284 | + * Clears the value of the 'age' field. |
| 285 | + * @return This builder. |
| 286 | + */ |
| 287 | + public User.Builder clearAge() { |
| 288 | + fieldSetFlags()[1] = false; |
| 289 | + return this; |
| 290 | + } |
| 291 | + |
| 292 | + @Override |
| 293 | + @SuppressWarnings("unchecked") |
| 294 | + public User build() { |
| 295 | + try { |
| 296 | + User record = new User(); |
| 297 | + record.name = fieldSetFlags()[0] ? this.name : (CharSequence) defaultValue(fields()[0]); |
| 298 | + record.age = fieldSetFlags()[1] ? this.age : (Integer) defaultValue(fields()[1]); |
| 299 | + return record; |
| 300 | + } catch (Exception e) { |
| 301 | + throw new org.apache.avro.AvroRuntimeException(e); |
| 302 | + } |
| 303 | + } |
| 304 | + } |
| 305 | + |
| 306 | + @SuppressWarnings("unchecked") |
| 307 | + private static final org.apache.avro.io.DatumWriter<User> |
| 308 | + WRITER$ = (org.apache.avro.io.DatumWriter<User>)MODEL$.createDatumWriter(SCHEMA$); |
| 309 | + |
| 310 | + @Override public void writeExternal(java.io.ObjectOutput out) |
| 311 | + throws java.io.IOException { |
| 312 | + WRITER$.write(this, SpecificData.getEncoder(out)); |
| 313 | + } |
| 314 | + |
| 315 | + @SuppressWarnings("unchecked") |
| 316 | + private static final org.apache.avro.io.DatumReader<User> |
| 317 | + READER$ = (org.apache.avro.io.DatumReader<User>)MODEL$.createDatumReader(SCHEMA$); |
| 318 | + |
| 319 | + @Override public void readExternal(java.io.ObjectInput in) |
| 320 | + throws java.io.IOException { |
| 321 | + READER$.read(this, SpecificData.getDecoder(in)); |
| 322 | + } |
| 323 | + |
| 324 | +} |
0 commit comments