Skip to content

Commit 78da671

Browse files
author
Andrei Branza
committed
BAEL-8044 - Moved files to new package
1 parent 478823c commit 78da671

File tree

3 files changed

+681
-0
lines changed

3 files changed

+681
-0
lines changed

apache-libraries/parent.avro

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

0 commit comments

Comments
 (0)